public void FindCustomerReturnNullIfCustomerIdIsEmpty() { //Arrange var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); 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 FindCountriesInPageMaterializeResults() { //Arrange var customerRepository = new SICustomerRepository(); var countryRepository = new SICountryRepository(); countryRepository.GetPagedInt32Int32ExpressionOfFuncOfCountryKPropertyBoolean <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 FindCustomersInPageMaterializeResults() { //Arrange var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); 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 FindCustomersByFilterMaterializeResults() { //Arrange var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); 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 FindCountriesByFilterMaterializeResults() { //Arrange var customerRepository = new SICustomerRepository(); var countryRepository = new SICountryRepository(); 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 FindCustomerMaterializaResultIfExist() { //Arrange var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); 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 AddNewCustomerReturnAdaptedDTO() { //Arrange var adapter = PrepareTypeAdapter(); var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); customerRepository.AddCustomer = (customer) => { }; customerRepository.UnitOfWorkGet = () => { var uow = new SIUnitOfWork(); uow.Commit = () => { }; return uow; }; var customerManagementService = new CustomerAppService(adapter, 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 ConstructorThrowExceptionWhenCountryRepositoryDependencyIsNull() { //Arrange var customerRepository = new SICustomerRepository(); SICountryRepository countryRepository = null; //act var customerManagementService = new CustomerAppService(countryRepository, customerRepository); }
public void FindCustomersWithInvalidPageArgumentsThrowArgumentException() { //Arrange var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //Act customerManagementService.FindCustomers(-1, 0); }
public void FindCountriesWithInvalidPageArgumentsReturnNull() { //Arrange var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //Act customerManagementService.FindCountries(-1, 0); }
public void UpdateCustomerMergePersistentAndCurrent() { //Arrange var country = new Country("spain", "es-ES"); country.GenerateNewIdentity(); Guid customerId = Guid.NewGuid(); var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); customerRepository.UnitOfWorkGet = () => { var uow = new SIUnitOfWork(); 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 AddNewCustomerThrowExceptionIfCustomerDtoIsNull() { //Arrange var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //act var result = customerManagementService.AddNewCustomer(null); //Assert Assert.IsNull(result); }
public void AddNewCustomerThrowExceptionIfCustomerDtoIsNull() { //Arrange var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //act var result = customerManagementService.AddNewCustomer(null); //Assert Assert.IsNull(result); }
public void AddNewCustomerThrowArgumentExceptionIfCustomerCountryInformationIsEmpty() { //Arrange var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); var customerManagementService = new CustomerAppService(countryRepository, customerRepository); var customerDTO = new CustomerDTO() { CountryId = Guid.Empty }; //act var result = customerManagementService.AddNewCustomer(customerDTO); }
public void AddNewCustomerThrowArgumentExceptionIfCustomerCountryInformationIsEmpty() { //Arrange var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); 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 SICustomerRepository(); var countryRepository = new SICountryRepository(); 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 FindCustomersInPageReturnNullIfNotData() { //Arrange var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); 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 FindCountriesInPageReturnNullIfNotData() { //Arrange var customerRepository = new SICustomerRepository(); var countryRepository = new SICountryRepository(); countryRepository.GetPagedInt32Int32ExpressionOfFuncOfCountryKPropertyBoolean <string>((index, count, order, ascending) => { return(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 SICountryRepository(); countryRepository.GetGuid = (guid) => { var country = new Country("Spain", "es-ES");; country.ChangeCurrentIdentity(guid); return(country); }; var customerRepository = new SICustomerRepository(); customerRepository.AddCustomer = (customer) => { }; customerRepository.UnitOfWorkGet = () => { var uow = new SIUnitOfWork(); 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 AddNewCustomerReturnAdaptedDTO() { //Arrange var countryRepository = new SICountryRepository(); countryRepository.GetGuid = (guid) => { var country = new Country("Spain", "es-ES"); ; country.ChangeCurrentIdentity(guid); return country; }; var customerRepository = new SICustomerRepository(); customerRepository.AddCustomer = (customer) => { }; customerRepository.UnitOfWorkGet = () => { var uow = new SIUnitOfWork(); 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(); Guid customerId = Guid.NewGuid(); var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); customerRepository.UnitOfWorkGet = () => { var uow = new SIUnitOfWork(); 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 AddNewCustomerThrowApplicationErrorsWhenEntityIsNotValid() { //Arrange var countryId = Guid.NewGuid(); var countryRepository = new SICountryRepository(); countryRepository.GetGuid = (guid) => { var country = new Country("spain", "es-ES"); country.GenerateNewIdentity(); return(country); }; var customerRepository = new SICustomerRepository(); customerRepository.AddCustomer = (customer) => { }; customerRepository.UnitOfWorkGet = () => { var uow = new SIUnitOfWork(); 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 FindCustomerReturnNullIfCustomerIdIsEmpty() { //Arrange var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); 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 FindCustomersByFilterMaterializeResults() { //Arrange var adapter = PrepareTypeAdapter(); var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); customerRepository.AllMatchingISpecificationOfCustomer = (spec) => { var customers = new List<Customer>(); customers.Add(CustomerFactory.CreateCustomer("Jhon", "El rojo", Guid.NewGuid(), new Address("city", "zipCode", "address line", "address line2"))); return customers; }; var customerManagementService = new CustomerAppService(adapter, countryRepository, customerRepository); //Act var result = customerManagementService.FindCustomers("Jhon"); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.Count == 1); }
public void FindCustomersByFilterMaterializeResults() { //Arrange var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); 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 FindCountriesByFilterReturnNullIfNotData() { //Arrange var customerRepository = new SICustomerRepository(); var countryRepository = new SICountryRepository(); 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 AddNewCustomerThrowApplicationErrorsWhenEntityIsNotValid() { //Arrange var adapter = PrepareTypeAdapter(); var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); customerRepository.AddCustomer = (customer) => { }; customerRepository.UnitOfWorkGet = () => { var uow = new SIUnitOfWork(); uow.Commit = () => { }; return uow; }; var customerManagementService = new CustomerAppService(adapter, countryRepository, customerRepository); var customerDTO = new CustomerDTO() //missing lastname { CountryId = Guid.NewGuid(), FirstName = "Jhon" }; //act var result = customerManagementService.AddNewCustomer(customerDTO); }
public void FindCountriesWithInvalidPageArgumentsReturnNull() { //Arrange var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //Act customerManagementService.FindCountries(-1, 0); }
public void FindCountriesInPageMaterializeResults() { //Arrange var customerRepository = new SICustomerRepository(); var countryRepository = new SICountryRepository(); countryRepository.GetPagedInt32Int32ExpressionOfFuncOfCountryKPropertyBoolean<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 AddNewCustomerReturnNullIfCustomerCountryInformationIsEmpty() { //Arrange var adapter = PrepareTypeAdapter(); var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); var customerManagementService = new CustomerAppService(adapter, countryRepository, customerRepository); var customerDTO = new CustomerDTO() { CountryId = Guid.Empty }; //act var result = customerManagementService.AddNewCustomer(customerDTO); //Assert Assert.IsNull(result); }
public void AddNewCustomerThrowApplicationErrorsWhenEntityIsNotValid() { //Arrange var countryId = Guid.NewGuid(); var countryRepository = new SICountryRepository(); countryRepository.GetGuid = (guid)=> { var country = new Country("spain", "es-ES"); country.GenerateNewIdentity(); return country; }; var customerRepository = new SICustomerRepository(); customerRepository.AddCustomer = (customer) => { }; customerRepository.UnitOfWorkGet = () => { var uow = new SIUnitOfWork(); 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 Guid countryGuid = Guid.NewGuid(); Guid customerId = Guid.NewGuid(); var adapter = PrepareTypeAdapter(); var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); customerRepository.UnitOfWorkGet = () => { var uow = new SIUnitOfWork(); uow.Commit = () => { }; return uow; }; var customer = CustomerFactory.CreateCustomer("Jhon","El rojo",countryGuid,new Address("city", "zipCode", "address line", "address line")); customer.Id = customerId; customerRepository.GetGuid = (guid) => { return customer; }; //Act var customerManagementService = new CustomerAppService(adapter, countryRepository, customerRepository); customerManagementService.RemoveCustomer(customerId); //Assert Assert.IsFalse(customer.IsEnabled); }
public void FindCountriesInPageMaterializeResults() { //Arrange var adapter = PrepareTypeAdapter(); var customerRepository = new SICustomerRepository(); var countryRepository = new SICountryRepository(); countryRepository.GetPagedInt32Int32ExpressionOfFuncOfCountryKPropertyBoolean<string>((index, count, order, ascending) => { return new List<Country>() { new Country(){Id = Guid.NewGuid(),CountryName ="country name",CountryISOCode="country iso"} }; }); var customerManagementService = new CustomerAppService(adapter, countryRepository, customerRepository); //Act var result = customerManagementService.FindCountries(0, 1); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.Count == 1); }
public void FindCustomersWithInvalidPageArgumentsReturnNull() { //Arrange var adapter = PrepareTypeAdapter(); var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); var customerManagementService = new CustomerAppService(adapter, countryRepository, customerRepository); //Act var resultInvalidPageIndex = customerManagementService.FindCustomers(-1, 0); var resultInvalidPageCount = customerManagementService.FindCustomers(1, 0); //Assert Assert.IsNull(resultInvalidPageIndex); Assert.IsNull(resultInvalidPageCount); }
public void FindCustomersInPageMaterializeResults() { //Arrange var adapter = PrepareTypeAdapter(); var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); customerRepository.GetEnabledInt32Int32 = (index, count) => { var customers = new List<Customer>(); customers.Add(CustomerFactory.CreateCustomer("Jhon", "El rojo", Guid.NewGuid(), new Address("city","zipCode","address line","address line2"))); return customers; }; var customerManagementService = new CustomerAppService(adapter, countryRepository, customerRepository); //Act var result = customerManagementService.FindCustomers(0, 1); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.Count == 1); }
public void FindCustomerMaterializaResultIfExist() { //Arrange var adapter = PrepareTypeAdapter(); var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); customerRepository.GetGuid = (guid) => { return CustomerFactory.CreateCustomer("Jhon", "El rojo", Guid.NewGuid(), new Address("city", "zipCode", "address line1", "address line2")); }; var customerManagementService = new CustomerAppService(adapter, countryRepository, customerRepository); //Act var result = customerManagementService.FindCustomer(Guid.NewGuid()); //Assert Assert.IsNotNull(result); }
public void FindCustomerMaterializaResultIfExist() { //Arrange var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); 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 RemoveCustomerSetCustomerAsDisabled() { //Arrange var country = new Country("spain", "es-ES"); country.GenerateNewIdentity(); Guid customerId = Guid.NewGuid(); var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); customerRepository.UnitOfWorkGet = () => { var uow = new SIUnitOfWork(); 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 FindCountriesByFilterMaterializeResults() { //Arrange var adapter = PrepareTypeAdapter(); var customerRepository = new SICustomerRepository(); var countryRepository = new SICountryRepository(); countryRepository.AllMatchingISpecificationOfCountry = (spec)=> { return new List<Country>() { new Country(){Id = Guid.NewGuid(),CountryName ="country name",CountryISOCode="country iso"} }; }; var customerManagementService = new CustomerAppService(adapter, countryRepository, customerRepository); //Act var result = customerManagementService.FindCountries("filter"); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.Count == 1); }
public void UpdateCustomerMergePersistentAndCurrent() { //Arrange var country = new Country("spain", "es-ES"); country.GenerateNewIdentity(); Guid customerId = Guid.NewGuid(); var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); customerRepository.UnitOfWorkGet = () => { var uow = new SIUnitOfWork(); 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 FindCountriesInPageReturnNullIfNotData() { //Arrange var customerRepository = new SICustomerRepository(); var countryRepository = new SICountryRepository(); countryRepository.GetPagedInt32Int32ExpressionOfFuncOfCountryKPropertyBoolean<string>((index, count, order, ascending) => { return new List<Country>(); }); var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //Act var result = customerManagementService.FindCountries(0, 1); //Assert Assert.IsNull(result); }
public void FindCustomersWithInvalidPageArgumentsThrowArgumentException() { //Arrange var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); var customerManagementService = new CustomerAppService(countryRepository, customerRepository); //Act customerManagementService.FindCustomers(-1, 0); }
public void FindCountriesByFilterMaterializeResults() { //Arrange var customerRepository = new SICustomerRepository(); var countryRepository = new SICountryRepository(); 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 FindCustomersInPageReturnNullIfNotData() { //Arrange var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); 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 ConstructorThrowExceptionWhenCustomerRepositoryDependencyIsNull() { //Arrange SICustomerRepository customerRepository = null; var countryRepository = new SICountryRepository(); //act var customerManagementService = new CustomerAppService(countryRepository, customerRepository); }
public void FindCustomersInPageMaterializeResults() { //Arrange var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); 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 FindCustomersByFilterReturnNullIfNotData() { //Arrange var adapter = PrepareTypeAdapter(); var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); customerRepository.AllMatchingISpecificationOfCustomer = (spec) => { return new List<Customer>(); }; var customerManagementService = new CustomerAppService(adapter, countryRepository, customerRepository); //Act var result = customerManagementService.FindCustomers("text"); //Assert Assert.IsNull(result); }
public void FindCustomerReturnNullIfCustomerIdIsEmpty() { //Arrange var adapter = PrepareTypeAdapter(); var countryRepository = new SICountryRepository(); var customerRepository = new SICustomerRepository(); var customerManagementService = new CustomerAppService(adapter, countryRepository, customerRepository); //Act var result = customerManagementService.FindCustomer(Guid.Empty); //Assert Assert.IsNull(result); }