Exemplo n.º 1
0
        public void NewCustomerIsCreated()
        {
            const string customerLastName = CustomersLastNameToBeDeleted;

            //Arrange
            var systemUnderTest     = new CarRentalBusinessLayer();
            var customerToBeCreated = _autoFixture.Build <CustomerModel>().Without(property => property.CustomerId).With(property => property.CustomerType, CustomerModel.Consumer).With(property => property.LastName, customerLastName)
                                      .Create();
            var expectedResult = customerToBeCreated;

            //Act
            systemUnderTest.CreateNewCustomer(
                customerToBeCreated.FirstName,
                customerToBeCreated.LastName,
                customerToBeCreated.DateOfBirth,
                customerToBeCreated.Street,
                customerToBeCreated.City,
                customerToBeCreated.Postcode,
                customerToBeCreated.CustomerType);

            //Assert
            Customer actualResult;

            using (var carRentalDbContext = new CarRentalDbContext()) { actualResult = carRentalDbContext.Customers.SingleOrDefault(c => c.LastName == customerLastName); }
            Assert.True(actualResult != null && expectedResult.LastName == actualResult.LastName);
        }