public void OrderRepositoryRemoveItemDeleteIt() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var customerRepository = new CustomerRepository(unitOfWork); var orderRepository = new OrderRepository(unitOfWork); var customer = customerRepository.Get(new Guid("0CD6618A-9C8E-4D79-9C6B-4AA69CF18AE6")); var order = OrderFactory.CreateOrder( customer, "shipping name", "shipping city", "shipping address", "shipping zip code"); order.GenerateNewIdentity(); orderRepository.Add(order); orderRepository.UnitOfWork.Commit(); //Act orderRepository.Remove(order); unitOfWork.Commit(); }
public void CustomerRepositoryRemoveItemDeleteIt() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var customerRepository = new CustomerRepository(unitOfWork); var country = new Country("Spain", "es-ES"); country.ChangeCurrentIdentity(new Guid("32BB805F-40A4-4C37-AA96-B7945C8C385C")); var address = new Address("city", "zipCode", "addressline1", "addressline2"); var customer = CustomerFactory.CreateCustomer("Frank", "Frank", "+3444", "company", country, address); customer.SetTheCountryReference(country.Id); customerRepository.Add(customer); unitOfWork.Commit(); //Act customerRepository.Remove(customer); unitOfWork.Commit(); var result = customerRepository.Get(customer.Id); //Assert Assert.IsNull(result); }
public void BankAccountRepositoryGetMethodReturnNullWhenIdIsEmpty() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var bankAccountRepository = new BankAccountRepository(unitOfWork); //Act var bankAccount = bankAccountRepository.Get(Guid.Empty); //Assert Assert.IsNull(bankAccount); }
public void CountryRepositoryGetMethodReturnNullWhenIdIsEmpty() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var countryRepository = new CountryRepository(unitOfWork); //Act var country = countryRepository.Get(Guid.Empty); //Assert Assert.IsNull(country); }
public void OrderRepositoryGetMethodReturnNullWhenIdIsEmpty() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var orderRepository = new OrderRepository(unitOfWork); //Act var order = orderRepository.Get(Guid.Empty); //Assert Assert.IsNull(order); }
public void CustomerRepositoryGetAllReturnMaterializedAllItems() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var customerRepository = new CustomerRepository(unitOfWork); //Act var allItems = customerRepository.GetAll(); //Assert Assert.IsNotNull(allItems); Assert.IsTrue(allItems.Any()); }
public void CustomerRepositoryFilterMethodReturnEntitisWithSatisfiedFilter() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var customerRepository = new CustomerRepository(unitOfWork); //Act var result = customerRepository.GetFiltered(c => c.CreditLimit > 0); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.All(c => c.CreditLimit > 0)); }
public void OrderRepositoryFilterMethodReturnEntitisWithSatisfiedFilter() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var orderRepository = new OrderRepository(unitOfWork); //Act var result = orderRepository.GetFiltered(o => o.IsDelivered == false); //Assert Assert.IsNotNull(result); Assert.IsFalse(result.All(o => o.IsDelivered)); }
public void CountryRepositoryGetAllReturnMaterializedAllItems() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var countryRepository = new CountryRepository(unitOfWork); //Act var allItems = countryRepository.GetAll(); //Assert Assert.IsNotNull(allItems); Assert.IsTrue(allItems.Any()); }
public void CountryRepositoryFilterMethodReturnEntitisWithSatisfiedFilter() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var countryRepository = new CountryRepository(unitOfWork); //Act var result = countryRepository.GetFiltered(c => c.CountryName.Contains("EU")); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.All(c => c.CountryName.Contains("EU"))); }
public void ProductRepositoryFilterMethodReturnEntitisWithSatisfiedFilter() { //Arrange var unitOfWork = new MainBcUnitOfWork(); IProductRepository productRepository = new ProductRepository(unitOfWork); //Act var result = productRepository.GetFiltered(p => p.AmountInStock > 1); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.All(p => p.AmountInStock > 1)); }
public void ProductRepositoryGetAllReturnMaterializedAllItems() { //Arrange var unitOfWork = new MainBcUnitOfWork(); IProductRepository productRepository = new ProductRepository(unitOfWork); //Act var allItems = productRepository.GetAll(); //Assert Assert.IsNotNull(allItems); Assert.IsTrue(allItems.Any()); }
public void CountryRepositoryAddNewItemSaveItem() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var countryRepository = new CountryRepository(unitOfWork); var country = new Country("France", "fr-FR"); country.GenerateNewIdentity(); //Act countryRepository.Add(country); unitOfWork.Commit(); }
public void ProductRepositoryGetMethodReturnNullWhenIdIsEmpty() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var productRepository = new ProductRepository(unitOfWork); Product product = null; //Act product = productRepository.Get(Guid.Empty); //Assert Assert.IsNull(product); }
public void CustomerRepositoryGetEnalbedReturnOnlyEnabledCustomers() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var customerRepository = new CustomerRepository(unitOfWork); //Act var result = customerRepository.GetEnabled(0, 10); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.Any()); Assert.IsTrue(result.All(c => c.IsEnabled)); }
public void CountryRepositoryGetMethodReturnMaterializedEntityById() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var countryRepository = new CountryRepository(unitOfWork); var countryId = new Guid("32BB805F-40A4-4C37-AA96-B7945C8C385C"); //Act var country = countryRepository.Get(countryId); //Assert Assert.IsNotNull(country); Assert.IsTrue(country.Id == countryId); }
public void BankAccountRepositoryGetAllReturnMaterializedBankAccountsAndCustomers() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var bankAccountRepository = new BankAccountRepository(unitOfWork); //Act var allItems = bankAccountRepository.GetAll(); //Assert Assert.IsNotNull(allItems); Assert.IsTrue(allItems.Any()); Assert.IsTrue(allItems.All(ba => ba.Customer != null)); }
public void CustomerRepositoryAllMatchingMethodReturnEntitiesWithSatisfiedCriteria() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var customerRepository = new CustomerRepository(unitOfWork); var spec = CustomerSpecifications.EnabledCustomers(); //Act var result = customerRepository.AllMatching(spec); //Assert Assert.IsNotNull(result.All(c => c.IsEnabled)); }
public void ProductRepositoryAllMatchingMethodReturnEntitiesWithSatisfiedCriteria() { //Arrange var unitOfWork = new MainBcUnitOfWork(); IProductRepository productRepository = new ProductRepository(unitOfWork); var spec = ProductSpecifications.ProductFullText("book"); //Act var result = productRepository.AllMatching(spec); //Assert Assert.IsNotNull(result.All(p => p.Title.Contains("book") || p.Description.Contains("book"))); }
public void BankAccountRepositoryFilterMethodReturnEntitisWithSatisfiedFilter() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var bankAccountRepository = new BankAccountRepository(unitOfWork); var iban = string.Format("ES{0} {1} {2} {0}{3}", "02", "4444", "5555", "3333333333"); //Act var allItems = bankAccountRepository.GetFiltered(ba => ba.Iban == iban); //Assert Assert.IsNotNull(allItems); Assert.IsTrue(allItems.All(b => b.Iban == iban)); }
public void BankAccountRepositoryGetMethodReturnMaterializedEntityById() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var bankAccountRepository = new BankAccountRepository(unitOfWork); var selectedBankAccount = new Guid("0343C0B0-7C40-444A-B044-B463F36A1A1F"); //Act var bankAccount = bankAccountRepository.Get(selectedBankAccount); //Assert Assert.IsNotNull(bankAccount); Assert.IsTrue(bankAccount.Id == selectedBankAccount); }
public void OrderRepositoryGetMethodReturnMaterializedEntityById() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var orderRepository = new OrderRepository(unitOfWork); var orderId = new Guid("3135513C-63FD-43E6-9697-6C6E5D8CE55B"); //Act var order = orderRepository.Get(orderId); //Assert Assert.IsNotNull(order); Assert.IsTrue(order.Id == orderId); }
public void CountryRepositoryAllMatchingMethodReturnEntitiesWithSatisfiedCriteria() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var countryRepository = new CountryRepository(unitOfWork); var textToFind = "ain"; var spec = CountrySpecifications.CountryFullText(textToFind); //Act var result = countryRepository.AllMatching(spec); //Assert Assert.IsNotNull(result.All(c => c.CountryIsoCode.Contains(textToFind) || c.CountryName.Contains(textToFind))); }
public void OrderRepositoryAllMatchingMethodReturnEntitiesWithSatisfiedCriteria() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var orderRepository = new OrderRepository(unitOfWork); var spec = OrdersSpecifications.OrderFromDateRange(DateTime.Now.AddDays(-2), DateTime.Now.AddDays(-1)); //Act var result = orderRepository.AllMatching(spec); //Assert Assert.IsNotNull( result.All(o => o.OrderDate > DateTime.Now.AddDays(-2) && o.OrderDate < DateTime.Now.AddDays(-1))); }
public void ProductRepositoryAddNewItemSaveItem() { //Arrange var unitOfWork = new MainBcUnitOfWork(); IProductRepository productRepository = new ProductRepository(unitOfWork); var book = new Book("The book title", "Any book description", "Krasis Press", "ABC"); book.ChangeUnitPrice(40); book.IncrementStock(1); book.GenerateNewIdentity(); //Act productRepository.Add(book); unitOfWork.Commit(); }
public void CustomerRepositoryGetMethodReturnCustomerWithPicture() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var customerRepository = new CustomerRepository(unitOfWork); var customerId = new Guid("43A38AC8-EAA9-4DF0-981F-2685882C7C45"); //Act var customer = customerRepository.Get(customerId); //Assert Assert.IsNotNull(customer); Assert.IsNotNull(customer.Picture); Assert.IsTrue(customer.Id == customerId); }
public void ProductRepositoryGetMethodReturnMaterializedEntityById() { //Arrange var unitOfWork = new MainBcUnitOfWork(); IProductRepository productRepository = new ProductRepository(unitOfWork); var productId = new Guid("44668EBF-7B54-4431-8D61-C1298DB50857"); Product product = null; //Act product = productRepository.Get(productId); //Assert Assert.IsNotNull(product); Assert.IsTrue(product.Id == productId); }
public void BankAccountRepositoryAllMatchingMethodReturnEntitiesWithSatisfiedCriteria() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var bankAccountRepository = new BankAccountRepository(unitOfWork); var iban = string.Format("ES{0} {1} {2} {0}{3}", "02", "4444", "5555", "3333333333"); var spec = BankAccountSpecifications.BankAccountIbanNumber(iban); //Act var result = bankAccountRepository.AllMatching(spec); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.All(b => b.Iban == iban)); }
public void CountryRepositoryRemoveItemDeleteIt() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var countryRepository = new CountryRepository(unitOfWork); var country = new Country("England", "en-EN"); country.GenerateNewIdentity(); countryRepository.Add(country); countryRepository.UnitOfWork.Commit(); //Act countryRepository.Remove(country); unitOfWork.Commit(); }
public void ProductRepositoryPagedMethodReturnEntitiesInPageFashion() { //Arrange var unitOfWork = new MainBcUnitOfWork(); IProductRepository productRepository = new ProductRepository(unitOfWork); //Act var pageI = productRepository.GetPaged(0, 1, b => b.Id, false); var pageIi = productRepository.GetPaged(1, 1, b => b.Id, false); //Assert Assert.IsNotNull(pageI); Assert.IsTrue(pageI.Count() == 1); Assert.IsNotNull(pageIi); Assert.IsTrue(pageIi.Count() == 1); Assert.IsFalse(pageI.Intersect(pageIi).Any()); }
public void BankAccountRepositoryRemoveItemDeleteIt() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var customerRepository = new CustomerRepository(unitOfWork); var bankAccountRepository = new BankAccountRepository(unitOfWork); var customer = customerRepository.Get(new Guid("43A38AC8-EAA9-4DF0-981F-2685882C7C45")); var bankAccountNumber = new BankAccountNumber("4444", "5555", "3333333333", "02"); var newBankAccount = BankAccountFactory.CreateBankAccount(customer, bankAccountNumber); bankAccountRepository.Add(newBankAccount); unitOfWork.Commit(); //Act bankAccountRepository.Remove(newBankAccount); unitOfWork.Commit(); }
public void BankAccountRepositoryAddNewItemSaveItem() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var customerRepository = new CustomerRepository(unitOfWork); var bankAccountRepository = new BankAccountRepository(unitOfWork); var customer = customerRepository.Get(new Guid("43A38AC8-EAA9-4DF0-981F-2685882C7C45")); var bankAccountNumber = new BankAccountNumber("1111", "2222", "3333333333", "01"); var newBankAccount = BankAccountFactory.CreateBankAccount(customer, bankAccountNumber); //Act bankAccountRepository.Add(newBankAccount); try { unitOfWork.Commit(); } catch (DbUpdateException ex) { var entry = ex.Entries.First(); } }
public void OrderRepositoryAddNewItemSaveItem() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var customerRepository = new CustomerRepository(unitOfWork); var orderRepository = new OrderRepository(unitOfWork); var customer = customerRepository.Get(new Guid("0CD6618A-9C8E-4D79-9C6B-4AA69CF18AE6")); var order = OrderFactory.CreateOrder( customer, "shipping name", "shipping city", "shipping address", "shipping zip code"); order.GenerateNewIdentity(); //Act orderRepository.Add(order); unitOfWork.Commit(); }
public void CustomerRepositoryAddNewItemSaveItem() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var customerRepository = new CustomerRepository(unitOfWork); var country = new Country("spain", "es-ES"); country.ChangeCurrentIdentity(new Guid("32BB805F-40A4-4C37-AA96-B7945C8C385C")); var customer = CustomerFactory.CreateCustomer( "Felix", "Trend", "+3434", "company", country, new Address("city", "zipCode", "addressLine1", "addressLine2")); customer.SetTheCountryReference(country.Id); //Act customerRepository.Add(customer); unitOfWork.Commit(); }
public void BankAccountRepositoryPagedMethodReturnEntitiesInPageFashion() { //Arrange var unitOfWork = new MainBcUnitOfWork(); var bankAccountRepository = new BankAccountRepository(unitOfWork); //Act var pageI = bankAccountRepository.GetPaged(0, 1, b => b.Id, false); var pageIi = bankAccountRepository.GetPaged(1, 1, b => b.Id, false); //Assert Assert.IsNotNull(pageI); Assert.IsTrue(pageI.Count() == 1); Assert.IsNotNull(pageIi); Assert.IsTrue(pageIi.Count() == 1); Assert.IsFalse(pageI.Intersect(pageIi).Any()); }