public async Task The_Customer_Is_Added_To_The_Datastore() { string id = Guid.NewGuid().ToString(); const string firstName = nameof(firstName); const string lastName = nameof(lastName); DateTime dateOfBirth = DateTime.UtcNow; var customer = new Api.Customer { FirstName = firstName, LastName = lastName, DateOfBirth = dateOfBirth }; var expectedCustomers = new Entities.Customer[] { new Entities.Customer { DateOfBirth = dateOfBirth, FirstName = firstName, Id = id, LastName = lastName } }; FakeIdentityGenerator identityGenerator = new FakeIdentityGenerator() .WithGeneratedIdentities(id); AddCustomerFixture sut = new AddCustomerFixture() .WithIdentityGenerator(identityGenerator); await sut.AddCustomer(customer); sut.PostTestCustomers.Should().BeEquivalentTo(expectedCustomers); }
public Api.Customer Map(Entities.Customer customer) { return(new Api.Customer { DateOfBirth = customer.DateOfBirth, FirstName = customer.FirstName, Id = customer.Id, LastName = customer.LastName }); }
public async Task A_Success_Response_Is_Returned() { string id1 = Guid.NewGuid().ToString(); string id2 = Guid.NewGuid().ToString(); const string firstName1 = nameof(firstName1); const string firstName1a = nameof(firstName1a); const string firstName2 = nameof(firstName2); const string lastName1 = nameof(lastName1); const string lastName1a = nameof(lastName1a); const string lastName2 = nameof(lastName2); DateTime dateOfBirth1 = DateTime.UtcNow; DateTime dateOfBirth1a = dateOfBirth1.AddDays(-1); DateTime dateOfBirth2 = dateOfBirth1.AddDays(-2); var existingCustomers = new Entities.Customer[] { new Entities.Customer { DateOfBirth = dateOfBirth1, FirstName = firstName1, Id = id1, LastName = lastName1 }, new Entities.Customer { DateOfBirth = dateOfBirth2, FirstName = firstName2, Id = id2, LastName = lastName2 }, }; var updateCustomer = new Api.Customer { DateOfBirth = dateOfBirth1a, FirstName = firstName1a, Id = id1, LastName = lastName1a }; UpdateCustomerFixture sut = new UpdateCustomerFixture() .WithCustomerRepositoryData(existingCustomers); IActionResult response = await sut.UpdateCustomer(updateCustomer); response.Should().BeOfType <OkResult>(); }
public async Task Customer_Is_Updated_In_The_Datastore() { string id1 = Guid.NewGuid().ToString(); string id2 = Guid.NewGuid().ToString(); const string firstName1 = nameof(firstName1); const string firstName1a = nameof(firstName1a); const string firstName2 = nameof(firstName2); const string lastName1 = nameof(lastName1); const string lastName1a = nameof(lastName1a); const string lastName2 = nameof(lastName2); DateTime dateOfBirth1 = DateTime.UtcNow; DateTime dateOfBirth1a = dateOfBirth1.AddDays(-1); DateTime dateOfBirth2 = dateOfBirth1.AddDays(-2); var existingCustomers = new Entities.Customer[] { new Entities.Customer { DateOfBirth = dateOfBirth1, FirstName = firstName1, Id = id1, LastName = lastName1 }, new Entities.Customer { DateOfBirth = dateOfBirth2, FirstName = firstName2, Id = id2, LastName = lastName2 }, }; var expectedCustomers = new Entities.Customer[] { new Entities.Customer { DateOfBirth = dateOfBirth1a, FirstName = firstName1a, Id = id1, LastName = lastName1a }, new Entities.Customer { DateOfBirth = dateOfBirth2, FirstName = firstName2, Id = id2, LastName = lastName2 }, }; var updateCustomer = new Api.Customer { DateOfBirth = dateOfBirth1a, FirstName = firstName1a, Id = id1, LastName = lastName1a }; UpdateCustomerFixture sut = new UpdateCustomerFixture() .WithCustomerRepositoryData(existingCustomers); await sut.UpdateCustomer(updateCustomer); sut.PostTestCustomers.Should().BeEquivalentTo(expectedCustomers); }