Skip to content

Commit

Permalink
Moved tests into the correct project, removed errant references, and …
Browse files Browse the repository at this point in the history
…fixed bugs exposed by actually running the tests
  • Loading branch information
hughesjs committed May 6, 2024
1 parent f1dfc26 commit c17a6a4
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using System.Xml.Serialization;
using Shouldly;
using UniversalDiveDataFormat.ExtensionMethods;
using Xunit;
using UniversalDiveDataFormat.Models;

namespace UniversalDiveDataFormat.Models;
namespace UniversalDiveDataFormat.Tests.Models;

public class BuiltTests
{
private const string Xml = """
<built>
<shipyard>Blohm & Voss</shipyard>
<shipyard>Blohm &amp; Voss</shipyard>
<launchingdate>
<datetime>1943-06-14</datetime>
</launchingdate>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Xml.Serialization;
using Shouldly;
using UniversalDiveDataFormat.ExtensionMethods;
using Xunit;
using UniversalDiveDataFormat.Models;

namespace UniversalDiveDataFormat.Models;
namespace UniversalDiveDataFormat.Tests.Models;

public class DiveComputerAlarmTests
{
Expand All @@ -23,6 +23,6 @@ public void CanReadDcAlarm()
DiveComputerAlarm dcAlarm = serializer.Deserialize<DiveComputerAlarm>(Xml);
dcAlarm.PeriodInSeconds.ShouldBe(10.0f);
dcAlarm.AlarmType.ShouldBe(1);
dcAlarm.Acknowledge.ShouldBeNull();
dcAlarm.Acknowledge.ShouldNotBeNull();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using UniversalDiveDataFormat.ExtensionMethods;
using UniversalDiveDataFormat.Models;

namespace UniversalDiveDataFormat.Tests;
namespace UniversalDiveDataFormat.Tests.Models;

public class ExposureToAltitudeTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using UniversalDiveDataFormat.ExtensionMethods;
using UniversalDiveDataFormat.Models;

namespace UniversalDiveDataFormat.Tests;
namespace UniversalDiveDataFormat.Tests.Models;

public class GlobalAlarmsTests
{
Expand Down
23 changes: 23 additions & 0 deletions src/UniversalDiveDataFormat.Tests/Models/LaunchingDateTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Xml.Serialization;
using Shouldly;
using UniversalDiveDataFormat.ExtensionMethods;
using UniversalDiveDataFormat.Models;

namespace UniversalDiveDataFormat.Tests.Models;

public class LaunchingDateTests
{
private const string Xml = """
<launchingdate>
<datetime>1943-06-14</datetime>
</launchingdate>
""";

[Fact]
public void CanReadLaunchingDate()
{
XmlSerializer serializer = new(typeof(LaunchingDate));
LaunchingDate launchingDate = serializer.Deserialize<LaunchingDate>(Xml);
launchingDate.DateTime.ShouldBe(new(1943, 6, 14));
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using System.Xml.Serialization;
using Shouldly;
using UniversalDiveDataFormat.ExtensionMethods;
using Xunit;
using UniversalDiveDataFormat.Models;

namespace UniversalDiveDataFormat.Models;
namespace UniversalDiveDataFormat.Tests.Models;

public class SetDiveComputerAlarmTimeTests
{
private const string Xml = """
<setdcalarmtime>
<datetime>T14:37:00</datetime>
<datetime>2022-01-01T14:37:00</datetime>
<dcalarm>
<!-- duration 10 seconds -->
<period>10.0</period>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using UniversalDiveDataFormat.ExtensionMethods;
using UniversalDiveDataFormat.Models;

namespace UniversalDiveDataFormat.Tests;
namespace UniversalDiveDataFormat.Tests.Models;

public class SetDiveComputerDecoModelTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Xml.Serialization;
using Shouldly;
using UniversalDiveDataFormat.ExtensionMethods;
using Xunit;
using UniversalDiveDataFormat.Models;

namespace UniversalDiveDataFormat.Models;
namespace UniversalDiveDataFormat.Tests.Models;

public class ShipDimensionTests
{
Expand All @@ -13,7 +13,7 @@ public class ShipDimensionTests
<beam>12.6</beam>
<draught>5.7</draught>
<displacement>123456.7</displacement>
<tonnage>170000.0</tonnag>
<tonnage>170000.0</tonnage>
</shipdimension>
""";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Xml.Serialization;
using Shouldly;
using UniversalDiveDataFormat.ExtensionMethods;
using Xunit;
using UniversalDiveDataFormat.Models;

namespace UniversalDiveDataFormat.Models;
namespace UniversalDiveDataFormat.Tests.Models;

public class WreckTests
{
Expand All @@ -13,7 +13,7 @@ public class WreckTests
<shiptype>tanker</shiptype>
<nationality>German</nationality>
<built>
<shipyard>Blohm & Voss</shipyard>
<shipyard>Blohm &amp; Voss</shipyard>
<launchingdate>
<datetime>1943-06-14</datetime>
</launchingdate>
Expand All @@ -25,7 +25,7 @@ public class WreckTests
<displacement>123456.7</displacement>
</shipdimension>
<sunk>
<datetime>1985-05-24T15:46</datetime>
<datetime>1985-05-24T15:46:00</datetime>
</sunk>
<notes>
<!-- here additional remarks and/or photos, videos of the wreck -->
Expand Down
4 changes: 2 additions & 2 deletions src/UniversalDiveDataFormat/Models/LaunchingDate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace UniversalDiveDataFormat.Models;

[XmlRoot("LaunchingDate")]
[XmlRoot("launchingdate")]
public class LaunchingDate
{
[XmlElement("datetime")]
public DateTime? DateTime { get; init; }
public DateTime DateTime { get; init; }
}
6 changes: 6 additions & 0 deletions src/UniversalDiveDataFormat/Services/UddfDeserializer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace UniversalDiveDataFormat.Services;

public class UddfDeserializer
{

}
6 changes: 0 additions & 6 deletions src/UniversalDiveDataFormat/UniversalDiveDataFormat.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@

<ItemGroup>
<None Include="..\..\README.md" Pack="true" PackagePath="\"/>
<Reference Include="Shouldly">
<HintPath>..\..\..\..\.nuget\packages\shouldly\4.2.1\lib\net5.0\Shouldly.dll</HintPath>
</Reference>
<Reference Include="xunit.core">
<HintPath>..\..\..\..\.nuget\packages\xunit.extensibility.core\2.4.2\lib\netstandard1.1\xunit.core.dll</HintPath>
</Reference>
</ItemGroup>

</Project>

0 comments on commit c17a6a4

Please sign in to comment.