Skip to content

Commit

Permalink
Move unit tests to root namespace to avoid the need for so many using…
Browse files Browse the repository at this point in the history
… statements
  • Loading branch information
ekolis committed Jun 29, 2024
1 parent 184b290 commit 8fa29ab
Show file tree
Hide file tree
Showing 26 changed files with 107 additions and 138 deletions.
1 change: 1 addition & 0 deletions FrEee.Tests/FrEee.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
</ItemGroup>
<PropertyGroup>
<EnableSourceControlManagerQueries>false</EnableSourceControlManagerQueries>
<RootNamespace>FrEee</RootNamespace>
</PropertyGroup>
</Project>
3 changes: 1 addition & 2 deletions FrEee.Tests/Modding/FormulaTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
using FrEee.Processes.Combat;
using FrEee.Objects.Technology;
using FrEee.Objects.Vehicles;
using FrEee.Modding;
using FrEee.Modding.Templates;
using NUnit.Framework;
using System.Collections.Generic;
using System.Linq;
using FrEee.Objects.GameState;

namespace FrEee.Tests.Modding;
namespace FrEee.Modding;

/// <summary>
/// Tests data file formulas.
Expand Down
7 changes: 3 additions & 4 deletions FrEee.Tests/Modding/Loaders/ComponentLoaderTest.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using FrEee.Modding;
using FrEee.Extensions;
using FrEee.Extensions;
using NUnit.Framework;

namespace FrEee.Tests.Modding.Loaders;
namespace FrEee.Modding.Loaders;

/// <summary>
/// Summary description for ComponentLoaderTest
Expand Down Expand Up @@ -36,4 +35,4 @@ public void WeaponRangeBlindSpot()
Assert.AreEqual(2, w.WeaponInfo.MinRange.Value);
Assert.AreEqual(3, w.WeaponInfo.MaxRange.Value);
}
}
}
7 changes: 3 additions & 4 deletions FrEee.Tests/Modding/Loaders/LoaderTest.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using FrEee.Modding;
using NUnit.Framework;
using NUnit.Framework;

namespace FrEee.Tests.Modding.Loaders;
namespace FrEee.Modding.Loaders;

/// <summary>
/// Tests mod loaders.
Expand All @@ -26,4 +25,4 @@ public void LoadStockModWithoutErrors()
Mod.Load(null);
Assert.AreEqual(0, Mod.Errors.Count);
}
}
}
7 changes: 3 additions & 4 deletions FrEee.Tests/Modding/ScriptEngineTest.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using FrEee.Modding;
using System.Collections.Generic;
using NUnit.Framework;
using System.Collections.Generic;

namespace FrEee.Tests.Modding;
namespace FrEee.Modding;

//[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
public class ScriptEngineTest
Expand All @@ -23,4 +22,4 @@ public void EvaluateExpression()
variables.Add("y", 7);
Assert.AreEqual(42, PythonScriptEngine.EvaluateExpression<int>(expr, variables));
}
}
}
6 changes: 2 additions & 4 deletions FrEee.Tests/Modding/StockMod.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using FrEee.Modding;

namespace FrEee.Tests.Modding;
namespace FrEee.Modding;

/// <summary>
/// The stock FrEee mod.
Expand All @@ -18,4 +16,4 @@ public static Mod Instance
}

private static Mod instance;
}
}
7 changes: 3 additions & 4 deletions FrEee.Tests/Modding/Templates/GalaxyTemplateTest.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using FrEee.Modding.Templates;
using System.Drawing;
using NUnit.Framework;
using System.Drawing;

namespace FrEee.Tests.Modding;
namespace FrEee.Modding.Templates;

/// <summary>
/// Tests galaxy templates.
Expand Down Expand Up @@ -95,4 +94,4 @@ public void WarpPointAngularDistance()
Assert.IsFalse(GalaxyTemplate.AngleIsInRangeExclusive(-90, -30, 60));
Assert.IsFalse(GalaxyTemplate.AngleIsInRangeExclusive(270, -30, 60));
}
}
}
14 changes: 7 additions & 7 deletions FrEee.Tests/Objects/Abilities/AbilityTest.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using System.Drawing;
using FrEee.Extensions;
using FrEee.Modding.Abilities;
using FrEee.Modding.Templates;
using FrEee.Objects.Civilization;
using FrEee.Objects.GameState;
using FrEee.Objects.Space;
using FrEee.Objects.Technology;
using FrEee.Objects.Vehicles;
using FrEee.Modding.Templates;
using FrEee.Extensions;
using NUnit.Framework;
using System.Drawing;
using FrEee.Objects.Technology;
using FrEee.Objects.GameState;
using FrEee.Modding.Abilities;

namespace FrEee.Tests.Objects.Abilities;
namespace FrEee.Objects.Abilities;

/// <summary>
/// Tests abilities and ability rules.
Expand Down
12 changes: 6 additions & 6 deletions FrEee.Tests/Objects/Orders/ConstructionTest.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using FrEee.Objects.Civilization;
using FrEee.Extensions;
using FrEee.Modding;
using FrEee.Objects.Civilization;
using FrEee.Objects.GameState;
using FrEee.Objects.Space;
using FrEee.Objects.Technology;
using FrEee.Modding;
using FrEee.Extensions;
using NUnit.Framework;
using FrEee.Objects.GameState;

namespace FrEee.Tests.Objects.Orders;
namespace FrEee.Objects.Orders;

/// <summary>
/// Tests construction queue capabilities.
Expand Down Expand Up @@ -63,4 +63,4 @@ public void NoPopNoBuild()
}

// TODO - test construction of facilities/units/ships
}
}
15 changes: 7 additions & 8 deletions FrEee.Tests/Objects/Space/MemoryTest.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using FrEee.Objects.Civilization;
using FrEee.Objects.Space;
using FrEee.Objects.Vehicles;
using FrEee.Modding;
using System.Drawing;
using FrEee.Extensions;
using NUnit.Framework;
using System.Drawing;
using FrEee.Modding;
using FrEee.Objects.Civilization;
using FrEee.Objects.GameState;
using FrEee.Objects.Vehicles;
using NUnit.Framework;

namespace FrEee.Tests.Objects.Space;
namespace FrEee.Objects.Space;

/// <summary>
/// Tests memory sight / fog of war.
Expand Down Expand Up @@ -143,4 +142,4 @@ private void ReturnSubmarine()
}

// TODO - create test for fogged ship reappearing
}
}
9 changes: 4 additions & 5 deletions FrEee.Tests/Objects/Technology/TechnologyTest.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using FrEee.Extensions;
using FrEee.Modding;
using FrEee.Objects.Civilization;
using FrEee.Objects.Commands;
using FrEee.Objects.GameState;
using FrEee.Processes;
using FrEee.Modding;
using FrEee.Extensions;
using NUnit.Framework;
using FrEee.Objects.GameState;
using FrEee.Objects.Technology;

namespace FrEee.Tests.Objects.Technology;
namespace FrEee.Objects.Technology;

public class TechnologyTest
{
Expand Down
10 changes: 5 additions & 5 deletions FrEee.Tests/Objects/Technology/WeaponInfoTest.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using FrEee.Processes.Combat;
using System.Linq;
using FrEee.Modding;
using NUnit.Framework;
using System.Linq;
using FrEee.Objects.GameState;
using FrEee.Processes.Combat;
using NUnit.Framework;

namespace FrEee.Tests.Objects.Technology;
namespace FrEee.Objects.Technology;

/// <summary>
/// Tests weapon info.
Expand Down Expand Up @@ -50,4 +50,4 @@ public void NonFormulaDamage()
Assert.AreEqual(20, ct.WeaponInfo.GetDamage(new Shot(null, comp, null, 4)));
Assert.AreEqual(0, ct.WeaponInfo.GetDamage(new Shot(null, comp, null, 6)));
}
}
}
19 changes: 9 additions & 10 deletions FrEee.Tests/Objects/Vehicles/CloakingTest.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
using FrEee.Objects.Civilization;
using FrEee.Objects.Space;
using FrEee.Objects.Vehicles;
using FrEee.Modding;
using System.Drawing;
using FrEee.Extensions;
using NUnit.Framework;
using System.Drawing;
using FrEee.Objects.Technology;
using FrEee.Objects.GameState;
using FrEee.Modding;
using FrEee.Modding.Abilities;
using FrEee.Objects.Civilization;
using FrEee.Objects.GameState;
using FrEee.Objects.Space;
using FrEee.Objects.Technology;
using NUnit.Framework;

namespace FrEee.Tests.Objects.Vehicles;
namespace FrEee.Objects.Vehicles;

/// <summary>
/// Tests cloaking of vehicles.
Expand Down Expand Up @@ -220,4 +219,4 @@ private void AddSensorAbility(IHull hull, string sightType, int level)
a.Values.Add(sightType);
a.Values.Add(level.ToString());
}
}
}
21 changes: 9 additions & 12 deletions FrEee.Tests/Objects/Vehicles/DamageTest.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
using FrEee.Modding.Abilities;
using FrEee.Objects.Civilization;
using FrEee.Objects.Space;
using FrEee.Objects.Technology;
using FrEee.Objects.Vehicles;
using System.Collections.Generic;
using System.Linq;
using FrEee.Extensions;
using FrEee.Modding;
using FrEee.Modding.Abilities;
using FrEee.Modding.Templates;
using FrEee.Extensions;
using NUnit.Framework;
using System.Collections.Generic;
using System.Linq;
using FrEee.Objects.Civilization;
using FrEee.Objects.GameState;
using FrEee.Extensions;
using FrEee.Objects.Technology;
using NUnit.Framework;

namespace FrEee.Tests.Objects.Vehicles;
namespace FrEee.Objects.Vehicles;

/// <summary>
/// Tests damage to vehicles.
Expand Down Expand Up @@ -113,4 +110,4 @@ private int GetExpectedSpeed(Ship ship)
+ ship.Components.Where(c => c.Hitpoints > 0).MaxOrDefault(c => c.GetAbilityValue("Extra Movement Generation").ToInt())
+ ship.Components.Where(c => c.Hitpoints > 0).MaxOrDefault(c => c.GetAbilityValue("Vehicle Speed").ToInt());
}
}
}
17 changes: 8 additions & 9 deletions FrEee.Tests/Objects/Vehicles/ResupplyTest.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
using FrEee.Objects.Civilization;
using FrEee.Objects.Space;
using FrEee.Objects.Technology;
using FrEee.Objects.Vehicles;
using System.Drawing;
using FrEee.Extensions;
using FrEee.Modding;
using FrEee.Modding.Templates;
using FrEee.Extensions;
using NUnit.Framework;
using System.Drawing;
using FrEee.Objects.Civilization;
using FrEee.Objects.GameState;
using FrEee.Objects.Space;
using FrEee.Objects.Technology;
using NUnit.Framework;

namespace FrEee.Tests.Objects.Vehicles;
namespace FrEee.Objects.Vehicles;

/// <summary>
/// Tests resupply of vehicles.
Expand Down Expand Up @@ -87,4 +86,4 @@ public void FleetResupply()
// TODO - test resupply depots

// TODO - test system wide resupply
}
}
16 changes: 7 additions & 9 deletions FrEee.Tests/Processes/Combat/DamageTypesTest.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using FrEee.Processes.Combat;
using FrEee.Objects.Vehicles;
using FrEee.Modding;
using FrEee.Extensions;
using NUnit.Framework;
using System;
using System;
using System.Linq;
using FrEee.Extensions;
using FrEee.Modding;
using FrEee.Objects.GameState;
using FrEee.Processes.Combat;
using FrEee.Objects.Vehicles;
using NUnit.Framework;

namespace FrEee.Tests.Processes.Combat;
namespace FrEee.Processes.Combat;

public class DamageTypesTest
{
Expand Down Expand Up @@ -176,4 +174,4 @@ private void TestDamage(Ship attacker, IDamageable defender, int dmg, int expect
else
Assert.IsTrue(defender.IsDestroyed);
}
}
}
6 changes: 3 additions & 3 deletions FrEee.Tests/Setup/GameSetupTest.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using FrEee.Modding;
using NUnit.Framework;
using FrEee.Objects.GameState;
using FrEee.Processes.Setup;
using NUnit.Framework;

namespace FrEee.Tests.Setup;
namespace FrEee.Setup;

public class GameSetupTest
{
Expand All @@ -15,4 +15,4 @@ public void Quickstart()
Mod.Current = Mod.Load(null);
Galaxy.Initialize(setup, null);
}
}
}
2 changes: 1 addition & 1 deletion FrEee.Tests/TestUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using FrEee.Modding;
using FrEee.Objects.GameState;

namespace FrEee.Tests;
namespace FrEee;

public static class TestUtilities
{
Expand Down
11 changes: 4 additions & 7 deletions FrEee.Tests/Utility/DataTest.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using FrEee.Utility;
using FrEee.Serialization;
using System.Collections.Generic;
using FrEee.Extensions;
using NUnit.Framework;
using System.Collections.Generic;
using FrEee.Serialization;
using FrEee.Utility;
using NUnit.Framework;

namespace FrEee.Tests.Utility;
namespace FrEee.Utility;

/// <summary>
/// Tests data operations.
Expand Down Expand Up @@ -199,4 +196,4 @@ public string SayHi()
return $"Hi, I'm {Name ?? "nobody"}!";
}
}
}
}
Loading

0 comments on commit 8fa29ab

Please sign in to comment.