Enable nullability in unit tests

This commit is contained in:
dotMorten 2019-08-21 11:00:28 -07:00
parent cb39e30e1f
commit a8da94010a
4 changed files with 12 additions and 6 deletions

View file

@ -19,6 +19,8 @@
<TestProjectType>UnitTest</TestProjectType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>

View file

@ -13,12 +13,14 @@
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.17763.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<MinimumVisualStudioVersion>16</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<PackageCertificateKeyFile>NmeaParser.Tests.UWP_TemporaryKey.pfx</PackageCertificateKeyFile>
<UnitTestPlatformVersion Condition="'$(UnitTestPlatformVersion)' == ''">$(VisualStudioVersion)</UnitTestPlatformVersion>
<PackageCertificateThumbprint>D07B149B4E796AB0184B2E2FC9DDC1A2F5CA5A7E</PackageCertificateThumbprint>
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>

View file

@ -47,7 +47,7 @@ namespace NmeaParser.Tests.UWP
}
#endif
Frame rootFrame = Window.Current.Content as Frame;
Frame? rootFrame = Window.Current?.Content as Frame;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
@ -64,13 +64,15 @@ namespace NmeaParser.Tests.UWP
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
if (Window.Current != null)
Window.Current.Content = rootFrame;
}
Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.CreateDefaultUI();
// Ensure the current window is active
Window.Current.Activate();
if (Window.Current != null)
Window.Current.Activate();
Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.Run(e.Arguments);
}

View file

@ -26,7 +26,7 @@ namespace NmeaParser.Tests
{
Assert.IsTrue(e.IsMultipart, "IsMultiPart");
Assert.IsInstanceOfType(e.Message, typeof(NmeaParser.Nmea.Gsv));
var msg = e.Message as NmeaParser.Nmea.Gsv;
var msg = (NmeaParser.Nmea.Gsv)e.Message;
if (msg.TotalMessages == msg.MessageNumber)
{
Assert.IsNotNull(e.MessageParts);
@ -67,7 +67,7 @@ $GAGSV,4,4,14,19,82,349,40,1,44,220,40,4,24,314,38*5F";
{
Assert.IsTrue(e.IsMultipart, "IsMultiPart");
Assert.IsInstanceOfType(e.Message, typeof(NmeaParser.Nmea.Gsv));
var msg = e.Message as NmeaParser.Nmea.Gsv;
var msg = (NmeaParser.Nmea.Gsv)e.Message;
if (msg.TotalMessages == msg.MessageNumber)
{
Assert.IsNotNull(e.MessageParts);