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 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 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 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 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 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 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 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 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 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); }
protected void Seed(MainBCUnitOfWork unitOfWork) { /* * Countries agg */ var spainCountry = new Country("Spain", "es-ES"); spainCountry.ChangeCurrentIdentity(new Guid("32BB805F-40A4-4C37-AA96-B7945C8C385C")); var usaCountry = new Country("EEUU", "en-US"); usaCountry.ChangeCurrentIdentity(new Guid("C3C82D06-6A07-41FB-B7EA-903EC456BFC5")); unitOfWork.Countries.Add(spainCountry); unitOfWork.Countries.Add(usaCountry); /* * Customers agg */ var customerJhon = CustomerFactory.CreateCustomer("Jhon", "Jhon", "+34617", "company", spainCountry, new Address("Madrid", "280181", "Paseo de La finca", "")); customerJhon.ChangeCurrentIdentity(new Guid("43A38AC8-EAA9-4DF0-981F-2685882C7C45")); var customerMay = CustomerFactory.CreateCustomer("May", "Garcia", "+34617", "company", usaCountry, new Address("Seatle", "3332", "Alaskan Way", "")); customerMay.ChangeCurrentIdentity(new Guid("0CD6618A-9C8E-4D79-9C6B-4AA69CF18AE6")); unitOfWork.Customers.Add(customerJhon); unitOfWork.Customers.Add(customerMay); /* * Product agg */ var book = new Book("The book title", "Any book description", "Krassis Press", "ABC"); book.ChangeUnitPrice(40M); book.IncrementStock(2); book.ChangeCurrentIdentity(new Guid("44668EBF-7B54-4431-8D61-C1298DB50857")); var software = new Software("the new SO", "the software description", "XXXX0000--111"); software.ChangeUnitPrice(100M); software.IncrementStock(3); software.ChangeCurrentIdentity(new Guid("D7E5C537-6A0C-4E19-B41E-3653F4998085")); unitOfWork.Products.Add(book); unitOfWork.Products.Add(software); /* * Orders agg */ var orderA = OrderFactory.CreateOrder(customerJhon, "shipping name", "shipping city", "shipping address", "shipping zip code"); orderA.ChangeCurrentIdentity(new Guid("3135513C-63FD-43E6-9697-6C6E5D8CE55B")); orderA.OrderDate = DateTime.Now; orderA.AddNewOrderLine(book.Id, 1, 40, 0); var orderB = OrderFactory.CreateOrder(customerMay, "shipping name", "shipping city", "shipping address", "shipping zip code"); orderB.GenerateNewIdentity(); orderB.OrderDate = DateTime.Now; orderB.AddNewOrderLine(software.Id, 3, 12, 0); unitOfWork.Orders.Add(orderA); unitOfWork.Orders.Add(orderB); /* * Bank Account agg */ var bankAccountNumberJhon = new BankAccountNumber("1111", "2222", "3333333333", "01"); BankAccount bankAccountJhon = BankAccountFactory.CreateBankAccount(customerJhon, bankAccountNumberJhon); bankAccountJhon.ChangeCurrentIdentity(new Guid("0343C0B0-7C40-444A-B044-B463F36A1A1F")); bankAccountJhon.DepositMoney(1000, "Open BankAccount"); var bankAccountNumberMay = new BankAccountNumber("4444", "5555", "3333333333", "02"); BankAccount bankAccountMay = BankAccountFactory.CreateBankAccount(customerMay, bankAccountNumberMay); bankAccountMay.GenerateNewIdentity(); bankAccountJhon.DepositMoney(2000, "Open BankAccount"); unitOfWork.BankAccounts.Add(bankAccountJhon); unitOfWork.BankAccounts.Add(bankAccountMay); unitOfWork.Commit(); }