public void CreateCustomerRepositoryTest() { //Arrange Customer b = ObjectMother.GetCustomer(); ICustomerRepository repository = new CustomerRepository(); //Action Customer newCustomer = repository.Save(b); //Assert Assert.IsTrue(newCustomer.Id > 0); Assert.IsTrue(newCustomer.Accommodations[0].Id > 0); }
public void Setup() { //Inicializa o banco, apagando e recriando-o Database.SetInitializer(new DropCreateDatabaseAlways <CustomerContext>()); //Seta um registro padrão pra ser usado nos testes _contextForTest = new CustomerContext(); var customer = ObjectMother.GetCustomer(); _contextForTest.Customers.Add(customer); _contextForTest.SaveChanges(); }
public void RetrieveCustomerServiceTest() { //Arrange Customer customer = ObjectMother.GetCustomer(); //Fake do repositório var repositoryFake = new Mock <ICustomerRepository>(); repositoryFake.Setup(r => r.Get(1)).Returns(customer); ICustomerService service = new CustomerService(repositoryFake.Object); //Action var customerFake = service.Retrieve(1); //Assert repositoryFake.Verify(r => r.Get(1)); Assert.IsNotNull(customerFake); }
public void UpdateCustomerServiceValidationAndPersistenceTest() { //Arrange Customer customer = ObjectMother.GetCustomer(); //Fake do repositório var repositoryFake = new Mock <ICustomerRepository>(); repositoryFake.Setup(r => r.Update(customer)).Returns(customer); //Fake do dominio var customerFake = new Mock <Customer>(); customerFake.As <IObjectValidation>().Setup(b => b.Validate()); ICustomerService service = new CustomerService(repositoryFake.Object); //Action service.Update(customerFake.Object); //Assert customerFake.As <IObjectValidation>().Verify(b => b.Validate()); repositoryFake.Verify(r => r.Update(customerFake.Object)); }
public void CreateAValidCustomerTest() { Customer customer = ObjectMother.GetCustomer(); Validator.Validate(customer); }
public void CreateACustomerTest() { Customer customer = ObjectMother.GetCustomer(); Assert.IsNotNull(customer); }