2020-08-01 17:04:28 +00:00
|
|
|
|
using System;
|
2021-08-02 18:57:52 +00:00
|
|
|
|
using NucuCar.Core.Utilities;
|
2020-08-01 17:04:28 +00:00
|
|
|
|
using Xunit;
|
|
|
|
|
|
2021-08-02 18:57:52 +00:00
|
|
|
|
namespace NucuCar.UnitTests.NucuCar.Core
|
2020-08-01 17:04:28 +00:00
|
|
|
|
{
|
|
|
|
|
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"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|