Skip to content

Commit

Permalink
renamed indiviual tests to be more descriptive
Browse files Browse the repository at this point in the history
  • Loading branch information
jackschonherr committed Aug 26, 2024
1 parent 430f050 commit 92b1a1b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion ConsequencesTest/BoundingBoxTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace ConsequencesTest;
public class BoundingBoxTest
{
[Fact]
public void TestNSI()
public void NSIFormat_ArbitraryLocation_ReturnCorrectFormat()
{
Location upperLeft = new Location { X = -40, Y = 50 };
Location lowerRight = new Location { X = 60, Y = -50 };
Expand Down
4 changes: 2 additions & 2 deletions ConsequencesTest/ConsoleWriterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class ConsoleWrite
static ResultItem[] resultItems = { r1, r2, r3 };
Result res = new Result(resultItems);
[Fact]
public void TestHeaders()
public void Write_PrintsHeadersOnce()
{
string headers = "Depth,Velocity,ArrivalTime2ft\r\n";
string row1 = "1.03,2.02,1/1/0001 12:00:00 AM\r\n";
Expand All @@ -30,7 +30,7 @@ public void TestHeaders()
}

[Fact]
public void TestInvalidResult()
public void Write_InvalidRowWritten_ThrowsException()
{
// Result with headers that do not match res
ResultItem[] bad = { r1, r1, r3 };
Expand Down
12 changes: 6 additions & 6 deletions ConsequencesTest/DepthHazardTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ public class DepthHazardTest
IHazard dh = new DepthHazard(input);

[Fact]
public void TestHasCorrectParameter()
public void Has_ValidParameter_ReturnsTrue()
{
Assert.True(dh.Has(HazardParameter.Depth));
}

[Fact]
public void TestHasIncorrectParameter()
public void Has_InvalidParameter_ReturnsFalse()
{
Assert.False(dh.Has(HazardParameter.Velocity));
Assert.False(dh.Has(HazardParameter.ArrivalTime));
Expand All @@ -23,28 +23,28 @@ public void TestHasIncorrectParameter()
}

[Fact]
public void TestGetCorrectValue()
public void Get_ValidParameter_ReturnValue()
{
Assert.Equal(input, dh.Get<float>(HazardParameter.Depth));
}

[Fact]
public void TestGetIncorrectValue()
public void Get_ValidParameter_ValueNotEqualToRandom()
{
Assert.NotEqual(input + 0.1f, dh.Get<float>(HazardParameter.Depth));
Assert.NotEqual(input * 1.23f, dh.Get<float>(HazardParameter.Depth));
}

[Fact]
public void TestGetInvalidParameter()
public void Get_InvalidParameter_ThrowNotSupported()
{
Assert.Throws<NotSupportedException>(() => dh.Get<float>(HazardParameter.ArrivalTime));
Assert.Throws<NotSupportedException>(() => dh.Get<float>(HazardParameter.Velocity));

}

[Fact]
public void TestGetInvalidType()
public void Get_InvalidType_ThrowInvalidCast()
{
Assert.Throws<InvalidCastException>(() => dh.Get<int>(HazardParameter.Depth));
Assert.Throws<InvalidCastException>(() => dh.Get<string>(HazardParameter.Depth));
Expand Down
12 changes: 6 additions & 6 deletions ConsequencesTest/LifeLossHazardTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class LifeLossHazardTest
IHazard llh = new LifeLossHazard(depth, velocity, time);

[Fact]
public void TestHasCorrectParameter()
public void Has_ValidParameter_ReturnsTrue()
{
Assert.True(llh.Has(HazardParameter.Depth));
Assert.True(llh.Has(HazardParameter.Velocity));
Expand All @@ -19,38 +19,38 @@ public void TestHasCorrectParameter()
}

[Fact]
public void TestHasIncorrectParameter()
public void Has_InvalidParameter_ReturnsFalse()
{
Assert.False(llh.Has(HazardParameter.ArrivalTime));
// compound parameter, must have all individual parameters to pass
Assert.False(llh.Has(HazardParameter.ArrivalTime | HazardParameter.Depth));
}

[Fact]
public void TestGetCorrectValue()
public void Get_ValidParameter_ReturnValue()
{
Assert.Equal(depth, llh.Get<float>(HazardParameter.Depth));
Assert.Equal(velocity, llh.Get<float>(HazardParameter.Velocity));
Assert.Equal(time, llh.Get<DateTime>(HazardParameter.ArrivalTime2ft));
}

[Fact]
public void TestGetIncorrectValue()
public void Get_ValidParameter_ValueNotEqualToRandom()
{
Assert.NotEqual(depth + 0.1f, llh.Get<float>(HazardParameter.Depth));
Assert.NotEqual(velocity + 0.1f, llh.Get<float>(HazardParameter.Velocity));
Assert.NotEqual(DateTime.Now, llh.Get<DateTime>(HazardParameter.ArrivalTime2ft));
}

[Fact]
public void TestGetInvalidParameter()
public void Get_InvalidParameter_ThrowNotSupported()
{
Assert.Throws<NotSupportedException>(() => llh.Get<DateTime>(HazardParameter.ArrivalTime));
Assert.Throws<NotSupportedException>(() => llh.Get<float>(HazardParameter.Velocity | HazardParameter.Depth));
}

[Fact]
public void TestGetInvalidType()
public void Get_InvalidType_ThrowInvalidCast()
{
Assert.Throws<InvalidCastException>(() => llh.Get<int>(HazardParameter.Depth));
Assert.Throws<InvalidCastException>(() => llh.Get<string>(HazardParameter.Velocity));
Expand Down
4 changes: 2 additions & 2 deletions ConsequencesTest/RandomDepthHazardProviderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace ConsequencesTest;
public class RandomDepthHazardProviderTest
{
[Fact]
public void ExtentTest()
public void Extent_0000_CreateCorrectBox()
{
Location location1 = new Location { X = 0, Y = 0 };
Location location2 = new Location { X = 0, Y = 0 };
Expand All @@ -20,7 +20,7 @@ public void ExtentTest()
}

[Fact]
public void DepthTest()
public void Hazard_RandomDepthHazards_ConsistentDepthValues()
{
// seeded randomly generated depths to ensure consistency when testing
int seed = 26;
Expand Down
6 changes: 3 additions & 3 deletions ConsequencesTest/StructureTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace ConsequencesTest;
public class StructureTest
{
[Fact]
public void TestSimpleDepth()
public void Compute_SimpleDepth()
{
Structure s = new Structure();
IHazard dh = new DepthHazard(4.56f);
Expand All @@ -21,7 +21,7 @@ public void TestSimpleDepth()
}

[Fact]
public void TestDepthConsoleWriter()
public void Compute_ArrayDepth_CorrectConsoleOutput()
{
Structure s = new Structure();
DepthHazard[] depthHazardArray =
Expand Down Expand Up @@ -63,7 +63,7 @@ public void TestDepthConsoleWriter()


[Fact]
public void TestLifeLossConsoleWriter()
public void Compute_ArrayLifeLoss_CorrectConsoleOutput()
{
Structure s = new Structure();
LifeLossHazard[] lifeLossHazardArray =
Expand Down

0 comments on commit 92b1a1b

Please sign in to comment.