/expectedObjects

Testing library for creating Expected Objects.

Primary LanguageC#MIT LicenseMIT

ExpectedObjects

Conventional Commits

ExpectedObjects is a testing library implementing the Expected Object pattern. Use of the Expected Object pattern eliminates the need to encumber system objects with test-specific equality behavior, helps to reduce test code duplication, and aids in expressing the logical intent of automated tests.

Quickstart

Installation

$> nuget install ExpectedObjects

Example Usage

using Xunit;

namespace MyProject.Specs
{
  public class CustomerServiceSpecs
  {        
    [Fact]
    public void RetrievingACustomer_ShouldReturnTheExpectedCustomer()
    {
      // Arrange
      var expectedCustomer = new Customer
      {
        FirstName = "Silence",
        LastName = "Dogood",
        Address = new Address
        {
          AddressLineOne = "The New-England Courant",
          AddressLineTwo = "3 Queen Street",
          City = "Boston",
          State = "MA",
          PostalCode = "02114"
        }                                            
      }.ToExpectedObject();


      // Act
      var actualCustomer = new CustomerService().GetCustomerByName("Silence", "Dogood");


      // Assert
      expectedCustomer.ShouldEqual(actualCustomer);
    }
  }
}

For more examples, see the documentation or browse the specifications.