public void FindCustomerMaterializaResultIfExist() { //Arrange var countryRepository = new StubICountryRepository(); var customerRepository = new StubICustomerRepository(); var country = new Country("spain", "es-ES"); country.GenerateNewIdentity(); customerRepository.GetGuid = (guid) => { return(CustomerFactory.CreateCustomer( "Jhon", "El rojo", "+3434344", "company", country, new Address("city", "zipCode", "address line1", "address line2"))); }; var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //Act var result = customerManagementService.FindCustomer(Guid.NewGuid()); //Assert Assert.IsNotNull(result); }
public void FindCountriesByFilterMaterializeResults() { //Arrange var customerRepository = new StubICustomerRepository(); var countryRepository = new StubICountryRepository(); countryRepository.AllMatchingISpecificationOfCountry = (spec) => { var country = new Country("country name", "country iso"); country.GenerateNewIdentity(); return(new List <Country>() { country }); }; var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //Act var result = customerManagementService.FindCountries("filter"); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.Count == 1); }
public void FindCustomersByFilterMaterializeResults() { //Arrange var countryRepository = new StubICountryRepository(); var customerRepository = new StubICustomerRepository(); var country = new Country("Spain", "es-ES"); country.GenerateNewIdentity(); customerRepository.AllMatchingISpecificationOfCustomer = (spec) => { var customers = new List <Customer>(); customers.Add( CustomerFactory.CreateCustomer( "Jhon", "El rojo", "+34343", "company", country, new Address("city", "zipCode", "address line", "address line2"))); return(customers); }; var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //Act var result = customerManagementService.FindCustomers("Jhon"); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.Count == 1); }
public void FindCustomerReturnNullIfCustomerIdIsEmpty() { //Arrange var countryRepository = new StubICountryRepository(); var customerRepository = new StubICustomerRepository(); customerRepository.GetGuid = (guid) => { if (guid == Guid.Empty) { return(null); } else { return(new Customer()); } }; var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //Act var result = customerManagementService.FindCustomer(Guid.Empty); //Assert Assert.IsNull(result); }
public void FindCustomersInPageMaterializeResults() { //Arrange var countryRepository = new StubICountryRepository(); var customerRepository = new StubICustomerRepository(); var country = new Country("spain", "es-ES"); country.GenerateNewIdentity(); customerRepository.GetEnabledInt32Int32 = (index, count) => { var customers = new List <Customer>(); customers.Add( CustomerFactory.CreateCustomer( "Jhon", "El rojo", "+343", "company", country, new Address("city", "zipCode", "address line", "address line2"))); return(customers); }; var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //Act var result = customerManagementService.FindCustomers(0, 1); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.Count == 1); }
public void ConstructorThrowExceptionWhenCountryRepositoryDependencyIsNull() { //Arrange var customerRepository = new StubICustomerRepository(); StubICountryRepository countryRepository = null; //act var customerManagementService = new CustomerAppService(countryRepository, customerRepository); }
public void FindCustomersWithInvalidPageArgumentsThrowArgumentException() { //Arrange var countryRepository = new StubICountryRepository(); var customerRepository = new StubICustomerRepository(); var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //Act customerManagementService.FindCustomers(-1, 0); }
public void UpdateCustomerMergePersistentAndCurrent() { //Arrange var country = new Country("spain", "es-ES"); country.GenerateNewIdentity(); var customerId = Guid.NewGuid(); var countryRepository = new StubICountryRepository(); var customerRepository = new StubICustomerRepository(); customerRepository.UnitOfWorkGet = () => { var uow = new StubIUnitOfWork(); uow.Commit = () => { }; return(uow); }; customerRepository.GetGuid = (guid) => { var customer = CustomerFactory.CreateCustomer( "Jhon", "El rojo", "+3434", "company", country, new Address("city", "zipCode", "address line", "address line")); customer.ChangeCurrentIdentity(customerId); return(customer); }; customerRepository.MergeCustomerCustomer = (persistent, current) => { Assert.AreEqual(persistent, current); Assert.IsTrue(persistent != null); Assert.IsTrue(current != null); }; var customerManagementService = new CustomerAppService(countryRepository, customerRepository); var customerDto = new CustomerDto() //missing lastname { Id = customerId, CountryId = country.Id, FirstName = "Jhon", LastName = "El rojo", }; //act customerManagementService.UpdateCustomer(customerDto); }
public void FindCountriesWithInvalidPageArgumentsReturnNull() { //Arrange var countryRepository = new StubICountryRepository(); var customerRepository = new StubICustomerRepository(); var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //Act customerManagementService.FindCountries(-1, 0); }
public void AddNewCustomerThrowExceptionIfCustomerDtoIsNull() { //Arrange var countryRepository = new StubICountryRepository(); var customerRepository = new StubICustomerRepository(); var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //act var result = customerManagementService.AddNewCustomer(null); //Assert Assert.IsNull(result); }
public void FindCustomersInPageReturnNullIfNotData() { //Arrange var countryRepository = new StubICountryRepository(); var customerRepository = new StubICustomerRepository(); customerRepository.GetEnabledInt32Int32 = (index, count) => { return(new List <Customer>()); }; var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //Act var result = customerManagementService.FindCustomers(0, 1); //Assert Assert.IsNull(result); }
public void AddNewCustomerThrowArgumentExceptionIfCustomerCountryInformationIsEmpty() { //Arrange var countryRepository = new StubICountryRepository(); var customerRepository = new StubICustomerRepository(); var customerManagementService = new CustomerAppService(countryRepository, customerRepository); var customerDto = new CustomerDto() { CountryId = Guid.Empty }; //act var result = customerManagementService.AddNewCustomer(customerDto); }
public void FindCountriesByFilterReturnNullIfNotData() { //Arrange var customerRepository = new StubICustomerRepository(); var countryRepository = new StubICountryRepository(); countryRepository.AllMatchingISpecificationOfCountry = (spec) => { return(new List <Country>()); }; var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //Act var result = customerManagementService.FindCountries("filter"); //Assert Assert.IsNull(result); }
public void AddNewCustomerReturnAdaptedDto() { //Arrange var countryRepository = new StubICountryRepository(); countryRepository.GetGuid = (guid) => { var country = new Country("Spain", "es-ES"); ; country.ChangeCurrentIdentity(guid); return(country); }; var customerRepository = new StubICustomerRepository(); customerRepository.AddCustomer = (customer) => { }; customerRepository.UnitOfWorkGet = () => { var uow = new StubIUnitOfWork(); uow.Commit = () => { }; return(uow); }; var customerManagementService = new CustomerAppService(countryRepository, customerRepository); var customerDto = new CustomerDto() { CountryId = Guid.NewGuid(), FirstName = "Jhon", LastName = "El rojo" }; //act var result = customerManagementService.AddNewCustomer(customerDto); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.Id != Guid.Empty); Assert.AreEqual(result.FirstName, customerDto.FirstName); Assert.AreEqual(result.LastName, customerDto.LastName); }
public void FindCountriesInPageReturnNullIfNotData() { //Arrange var customerRepository = new StubICustomerRepository(); var countryRepository = new StubICountryRepository(); //countryRepository.GetPagedInt32Int32ExpressionOfFuncOfCountryKPropertyBoolean<string>( // (index, count, order, ascending) => { return new List<Country>(); }); countryRepository.GetPagedOf1Int32Int32ExpressionOfFuncOfCountryM0Boolean <string>( (index, count, order, ascending) => new List <Country>()); var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //Act var result = customerManagementService.FindCountries(0, 1); //Assert Assert.IsNull(result); }
public void AddNewCustomerReturnAdaptedDto() { //Arrange var countryRepository = new StubICountryRepository(); countryRepository.GetGuid = (guid) => { var country = new Country("Spain", "es-ES"); ; country.ChangeCurrentIdentity(guid); return country; }; var customerRepository = new StubICustomerRepository(); customerRepository.AddCustomer = (customer) => { }; customerRepository.UnitOfWorkGet = () => { var uow = new StubIUnitOfWork(); uow.Commit = () => { }; return uow; }; var customerManagementService = new CustomerAppService(countryRepository, customerRepository); var customerDto = new CustomerDto() { CountryId = Guid.NewGuid(), FirstName = "Jhon", LastName = "El rojo" }; //act var result = customerManagementService.AddNewCustomer(customerDto); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.Id != Guid.Empty); Assert.AreEqual(result.FirstName, customerDto.FirstName); Assert.AreEqual(result.LastName, customerDto.LastName); }
public void RemoveCustomerSetCustomerAsDisabled() { //Arrange var country = new Country("spain", "es-ES"); country.GenerateNewIdentity(); var customerId = Guid.NewGuid(); var countryRepository = new StubICountryRepository(); var customerRepository = new StubICustomerRepository(); customerRepository.UnitOfWorkGet = () => { var uow = new StubIUnitOfWork(); uow.Commit = () => { }; return(uow); }; var customer = CustomerFactory.CreateCustomer( "Jhon", "El rojo", "+3434", "company", country, new Address("city", "zipCode", "address line", "address line")); customer.ChangeCurrentIdentity(customerId); customerRepository.GetGuid = (guid) => { return(customer); }; //Act var customerManagementService = new CustomerAppService(countryRepository, customerRepository); customerManagementService.RemoveCustomer(customerId); //Assert Assert.IsFalse(customer.IsEnabled); }
public void FindCountriesInPageMaterializeResults() { //Arrange var customerRepository = new StubICustomerRepository(); var countryRepository = new StubICountryRepository(); /* countryRepository.GetPagedInt32Int32ExpressionOfFuncOfCountryKPropertyBoolean<string>( * (index, count, order, ascending) => * { * var country = new Country("country name", "country iso"); * country.GenerateNewIdentity(); * * return new List<Country>() * { * country * }; * });*/ countryRepository.GetPagedOf1Int32Int32ExpressionOfFuncOfCountryM0Boolean <string>( (index, count, order, ascending) => { var country = new Country("country name", " country iso"); country.GenerateNewIdentity(); return(new List <Country>() { country }); }); var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //Act var result = customerManagementService.FindCountries(0, 1); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.Count == 1); }
public void AddNewCustomerThrowApplicationErrorsWhenEntityIsNotValid() { //Arrange var countryId = Guid.NewGuid(); var countryRepository = new StubICountryRepository(); countryRepository.GetGuid = (guid) => { var country = new Country("spain", "es-ES"); country.GenerateNewIdentity(); return(country); }; var customerRepository = new StubICustomerRepository(); customerRepository.AddCustomer = (customer) => { }; customerRepository.UnitOfWorkGet = () => { var uow = new StubIUnitOfWork(); uow.Commit = () => { }; return(uow); }; var customerManagementService = new CustomerAppService(countryRepository, customerRepository); var customerDto = new CustomerDto() //missing lastname { CountryId = Guid.NewGuid(), FirstName = "Jhon" }; //act var result = customerManagementService.AddNewCustomer(customerDto); }
public void ConstructorThrowExceptionWhenCustomerRepositoryDependencyIsNull() { //Arrange StubICustomerRepository customerRepository = null; var countryRepository = new StubICountryRepository(); //act var customerManagementService = new CustomerAppService(countryRepository, customerRepository); }
public void AddNewCustomerThrowApplicationErrorsWhenEntityIsNotValid() { //Arrange var countryId = Guid.NewGuid(); var countryRepository = new StubICountryRepository(); countryRepository.GetGuid = (guid) => { var country = new Country("spain", "es-ES"); country.GenerateNewIdentity(); return country; }; var customerRepository = new StubICustomerRepository(); customerRepository.AddCustomer = (customer) => { }; customerRepository.UnitOfWorkGet = () => { var uow = new StubIUnitOfWork(); uow.Commit = () => { }; return uow; }; var customerManagementService = new CustomerAppService(countryRepository, customerRepository); var customerDto = new CustomerDto() //missing lastname { CountryId = Guid.NewGuid(), FirstName = "Jhon" }; //act var result = customerManagementService.AddNewCustomer(customerDto); }
public void RemoveCustomerSetCustomerAsDisabled() { //Arrange var country = new Country("spain", "es-ES"); country.GenerateNewIdentity(); var customerId = Guid.NewGuid(); var countryRepository = new StubICountryRepository(); var customerRepository = new StubICustomerRepository(); customerRepository.UnitOfWorkGet = () => { var uow = new StubIUnitOfWork(); uow.Commit = () => { }; return uow; }; var customer = CustomerFactory.CreateCustomer( "Jhon", "El rojo", "+3434", "company", country, new Address("city", "zipCode", "address line", "address line")); customer.ChangeCurrentIdentity(customerId); customerRepository.GetGuid = (guid) => { return customer; }; //Act var customerManagementService = new CustomerAppService(countryRepository, customerRepository); customerManagementService.RemoveCustomer(customerId); //Assert Assert.IsFalse(customer.IsEnabled); }
public void FindCountriesByFilterReturnNullIfNotData() { //Arrange var customerRepository = new StubICustomerRepository(); var countryRepository = new StubICountryRepository(); countryRepository.AllMatchingISpecificationOfCountry = (spec) => { return new List<Country>(); }; var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //Act var result = customerManagementService.FindCountries("filter"); //Assert Assert.IsNull(result); }
public void FindCountriesInPageMaterializeResults() { //Arrange var customerRepository = new StubICustomerRepository(); var countryRepository = new StubICountryRepository(); /* countryRepository.GetPagedInt32Int32ExpressionOfFuncOfCountryKPropertyBoolean<string>( (index, count, order, ascending) => { var country = new Country("country name", "country iso"); country.GenerateNewIdentity(); return new List<Country>() { country }; });*/ countryRepository.GetPagedOf1Int32Int32ExpressionOfFuncOfCountryM0Boolean<string>( (index, count, order, ascending) => { var country = new Country("country name", " country iso"); country.GenerateNewIdentity(); return new List<Country>() { country }; }); var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //Act var result = customerManagementService.FindCountries(0, 1); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.Count == 1); }
public void FindCountriesByFilterMaterializeResults() { //Arrange var customerRepository = new StubICustomerRepository(); var countryRepository = new StubICountryRepository(); countryRepository.AllMatchingISpecificationOfCountry = (spec) => { var country = new Country("country name", "country iso"); country.GenerateNewIdentity(); return new List<Country>() { country }; }; var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //Act var result = customerManagementService.FindCountries("filter"); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.Count == 1); }
public void FindCountriesInPageReturnNullIfNotData() { //Arrange var customerRepository = new StubICustomerRepository(); var countryRepository = new StubICountryRepository(); //countryRepository.GetPagedInt32Int32ExpressionOfFuncOfCountryKPropertyBoolean<string>( // (index, count, order, ascending) => { return new List<Country>(); }); countryRepository.GetPagedOf1Int32Int32ExpressionOfFuncOfCountryM0Boolean<string>( (index, count, order, ascending) => new List<Country>()); var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //Act var result = customerManagementService.FindCountries(0, 1); //Assert Assert.IsNull(result); }
public void FindCustomerReturnNullIfCustomerIdIsEmpty() { //Arrange var countryRepository = new StubICountryRepository(); var customerRepository = new StubICustomerRepository(); customerRepository.GetGuid = (guid) => { if (guid == Guid.Empty) { return null; } else { return new Customer(); } }; var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //Act var result = customerManagementService.FindCustomer(Guid.Empty); //Assert Assert.IsNull(result); }
public void FindCustomerMaterializaResultIfExist() { //Arrange var countryRepository = new StubICountryRepository(); var customerRepository = new StubICustomerRepository(); var country = new Country("spain", "es-ES"); country.GenerateNewIdentity(); customerRepository.GetGuid = (guid) => { return CustomerFactory.CreateCustomer( "Jhon", "El rojo", "+3434344", "company", country, new Address("city", "zipCode", "address line1", "address line2")); }; var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //Act var result = customerManagementService.FindCustomer(Guid.NewGuid()); //Assert Assert.IsNotNull(result); }
public void UpdateCustomerMergePersistentAndCurrent() { //Arrange var country = new Country("spain", "es-ES"); country.GenerateNewIdentity(); var customerId = Guid.NewGuid(); var countryRepository = new StubICountryRepository(); var customerRepository = new StubICustomerRepository(); customerRepository.UnitOfWorkGet = () => { var uow = new StubIUnitOfWork(); uow.Commit = () => { }; return uow; }; customerRepository.GetGuid = (guid) => { var customer = CustomerFactory.CreateCustomer( "Jhon", "El rojo", "+3434", "company", country, new Address("city", "zipCode", "address line", "address line")); customer.ChangeCurrentIdentity(customerId); return customer; }; customerRepository.MergeCustomerCustomer = (persistent, current) => { Assert.AreEqual(persistent, current); Assert.IsTrue(persistent != null); Assert.IsTrue(current != null); }; var customerManagementService = new CustomerAppService(countryRepository, customerRepository); var customerDto = new CustomerDto() //missing lastname { Id = customerId, CountryId = country.Id, FirstName = "Jhon", LastName = "El rojo", }; //act customerManagementService.UpdateCustomer(customerDto); }
public void FindCustomersByFilterMaterializeResults() { //Arrange var countryRepository = new StubICountryRepository(); var customerRepository = new StubICustomerRepository(); var country = new Country("Spain", "es-ES"); country.GenerateNewIdentity(); customerRepository.AllMatchingISpecificationOfCustomer = (spec) => { var customers = new List<Customer>(); customers.Add( CustomerFactory.CreateCustomer( "Jhon", "El rojo", "+34343", "company", country, new Address("city", "zipCode", "address line", "address line2"))); return customers; }; var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //Act var result = customerManagementService.FindCustomers("Jhon"); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.Count == 1); }
public void FindCustomersInPageMaterializeResults() { //Arrange var countryRepository = new StubICountryRepository(); var customerRepository = new StubICustomerRepository(); var country = new Country("spain", "es-ES"); country.GenerateNewIdentity(); customerRepository.GetEnabledInt32Int32 = (index, count) => { var customers = new List<Customer>(); customers.Add( CustomerFactory.CreateCustomer( "Jhon", "El rojo", "+343", "company", country, new Address("city", "zipCode", "address line", "address line2"))); return customers; }; var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //Act var result = customerManagementService.FindCustomers(0, 1); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.Count == 1); }
public void FindCustomersInPageReturnNullIfNotData() { //Arrange var countryRepository = new StubICountryRepository(); var customerRepository = new StubICustomerRepository(); customerRepository.GetEnabledInt32Int32 = (index, count) => { return new List<Customer>(); }; var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //Act var result = customerManagementService.FindCustomers(0, 1); //Assert Assert.IsNull(result); }