NucuCar.Domain: Add tests for Guard class

This commit is contained in:
Denis-Cosmin Nutiu 2020-08-01 20:04:28 +03:00
parent 25d85dc526
commit 8bd7283316
4 changed files with 42 additions and 3 deletions

View file

@ -6,7 +6,6 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\NucuCar.Common\NucuCar.Common.csproj" />
<ProjectReference Include="..\NucuCar.Domain\NucuCar.Domain.csproj" />
</ItemGroup>

View file

@ -3,7 +3,7 @@ using System.Collections.Generic;
using NucuCar.Domain.Utilities;
using Xunit;
namespace NucuCar.UnitTests.NucuCar.Common.Tests
namespace NucuCar.UnitTests.NucuCar.Domain.Tests
{
public class ConnectionStringParserTest
{

View file

@ -0,0 +1,40 @@
using System;
using NucuCar.Domain.Utilities;
using Xunit;
namespace NucuCar.UnitTests.NucuCar.Domain.Tests
{
public class GuardTest
{
/// <summary>
/// Ensure that an exception is thrown when the argument is null or whitespace,
/// and no exception is raised when the argument is non-null.
/// </summary>
[Fact]
private void Test_GuardArgumentNotNullOrWhitespace()
{
Assert.Throws<ArgumentNullException>(() =>
{
Guard.ArgumentNotNullOrWhiteSpace("null", null);
});
Assert.Throws<ArgumentNullException>(() =>
{
Guard.ArgumentNotNullOrWhiteSpace("whitespace", "");
});
Guard.ArgumentNotNullOrWhiteSpace("string", "string");
}
/// <summary>
/// Ensure that an exception is thrown when argument is null. Otherwise no exception should be thrown.
/// </summary>
[Fact]
private void Test_GuardArgumentNotNull()
{
Assert.Throws<ArgumentNullException>(() =>
{
Guard.ArgumentNotNull("null", null);
});
Guard.ArgumentNotNull("object", new string("asd"));
}
}
}

View file

@ -23,6 +23,6 @@
&lt;/SessionState&gt;</s:String>
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=e8af539e_002D0b50_002D476d_002Daa84_002D80fbff5a748b/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" Name="Test_PublishAsync_OK" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;&#xD;
&lt;TestAncestor&gt;&#xD;
&lt;TestId&gt;xUnit::C6F07921-1052-4945-911E-F328A622F229::.NETCoreApp,Version=v3.1::NucuCar.UnitTests.NucuCar.Telemetry.Tests.TelemetryPublisherFirestoreTest.Test_PublishAsync_OK&lt;/TestId&gt;&#xD;
&lt;TestId&gt;xUnit::C6F07921-1052-4945-911E-F328A622F229::.NETCoreApp,Version=v3.1::NucuCar.UnitTests.NucuCar.Domain.Tests.GuardTest&lt;/TestId&gt;&#xD;
&lt;/TestAncestor&gt;&#xD;
&lt;/SessionState&gt;</s:String></wpf:ResourceDictionary>