• Stars
    star
    102
  • Rank 334,073 (Top 7 %)
  • Language
    C#
  • License
    MIT License
  • Created over 13 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Testing library for creating Expected Objects.

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.