Skip to content

Commit

Permalink
Added better domain tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmackay committed Nov 21, 2023
1 parent 41aa616 commit 90a8cb2
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 2 deletions.
32 changes: 32 additions & 0 deletions Tests/Domain.UnitTests/Common/CountryTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Northwind.Domain.Common;

namespace Northwind.Domain.UnitTests.Common;

public class CountryTests
{
[Fact]
public void IsAustralia_GivenAustralianCountry_ReturnsTrue()
{
// Arrange
var country = new Country("Australia");

// Act
var result = country.IsAustralia;

// Assert
result.Should().BeTrue();
}

[Fact]
public void IsAustralia_GivenNonAustralianCountry_ReturnsFalse()
{
// Arrange
var country = new Country("New Zealand");

// Act
var result = country.IsAustralia;

// Assert
result.Should().BeFalse();
}
}
32 changes: 32 additions & 0 deletions Tests/Domain.UnitTests/Common/PhoneTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Northwind.Domain.Customers;

namespace Northwind.Domain.UnitTests.Common;

public class PhoneTests
{
[Fact]
public void IsQueenslandLandline_GivenQLDNumber_ReturnsTrue()
{
// Arrange
var phone = new Phone("0733333333");

// Act
var result = phone.IsQueenslandLandLine;

// Assert
result.Should().BeTrue();
}

[Fact]
public void IsQueenslandLandline_GivenNonQLDNumber_ReturnsFalse()
{
// Arrange
var phone = new Phone("0833333333");

// Act
var result = phone.IsQueenslandLandLine;

// Assert
result.Should().BeFalse();
}
}
32 changes: 32 additions & 0 deletions Tests/Domain.UnitTests/Common/PostCodeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Northwind.Domain.Common;

namespace Northwind.Domain.UnitTests.Common;

public class PostCodeTests
{
[Fact]
public void IsQueenslandPostCode_GivenQLDPostCode_ReturnsTrue()
{
// Arrange
var postCode = new PostCode("4000");

// Act
var result = postCode.IsQueenslandPostCode;

// Assert
result.Should().BeTrue();
}

[Fact]
public void IsQueenslandPostCode_GivenNonQLDPostCode_ReturnsFalse()
{
// Arrange
var postCode = new PostCode("2000");

// Act
var result = postCode.IsQueenslandPostCode;

// Assert
result.Should().BeFalse();
}
}
2 changes: 0 additions & 2 deletions Tests/Domain.UnitTests/Customers/CustomerTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using Common.Factories;
using FluentAssertions;
using Northwind.Domain.Customers;
using Xunit;

namespace Northwind.Domain.UnitTests.Customers;

Expand Down
4 changes: 4 additions & 0 deletions Tests/Domain.UnitTests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Global using directives

global using FluentAssertions;
global using Xunit;

0 comments on commit 90a8cb2

Please # to comment.