public MutatingOrderBuilder By(Client client, bool storeInRepository = true) { _client = client; if (storeInRepository) { ClientsRepository.Clients.Add(client); } return this; }
public IOrderWithClientPart ByDummyClient(bool storeInRepository = true) { var address = new Address { AddressLine = "RandomStreet 1", City = "RandomCity", PostalCode = "RandomPostalCode", IsDefault = true }; var email = new Email { EmailString = "*****@*****.**", IsDefault = true }; var client = new Client { Addresses = new List<Address> { address }, Balance = 100, Emails = new List<Email> { email }, FirstName = "RandomFirstName", Id = new Random().Next(), LastName = "RandomLastName", MiddleName = "RandomMiddleName" }; return By(client, storeInRepository); }
public IOrderWithClientPart By(Client client, bool storeInRepository = true) { _client = client; if (storeInRepository) { ClientsRepository.Clients.Add(client); } return this; }
public void Store(Client client) { var storedClient = Clients.First(p => p.Id == client.Id); Clients.Remove(storedClient); Clients.Add(storedClient); }
public void OrdersService_PayOrder_WithInitiatedOrderUsingStandardMethod_StatusChangedToPaid() { //ARRANGE var clientsRepository = new ClientsRepositoryInMemory(); var ordersRepository = new OrderRepositoryInMemory(); var storageItemsRepository = new StorageItemsRepositoryInMemory(); var mailService = new MailService(); var address = new Address { AddressLine = "RandomStreet 1", City = "RandomCity", PostalCode = "RandomPostalCode", IsDefault = true }; var email = new Email { EmailString = "*****@*****.**", IsDefault = true }; var client = new Client { Addresses = new List<Address>{ address }, Balance = 100, Emails = new List<Email>{ email }, FirstName = "RandomFirstName", Id = 1, LastName = "RandomLastName", MiddleName = "RandomMiddleName" }; var shopAddress = new Address { AddressLine = "RandomStreet 1", City = "RandomCity", PostalCode = "RandomPostalCode", IsDefault = true }; var shop = new Shop { CompanyNumber = "00001", Address = shopAddress, Title = "RandomTitle" }; var product = new Product { Id = 1, Price = 10, Title = "RandomTitle1", }; var storageItem = new StorageItem { Id = 1, Product = product, Quantity = 2 }; var orderLine = new OrderLine { Product = product, Quantity = 2 }; var order = new Order { Status = OrderStatus.Initiated, CreationDate = DateTime.Now, FinishDate = null, Id = 1, Initiator = client, Notes = string.Empty, Shop = shop, OrderLines = new List<OrderLine> {orderLine} }; ordersRepository.Orders = new List<Order> {order}; clientsRepository.Clients = new List<Client> {client}; storageItemsRepository.StorageItems = new List<StorageItem> {storageItem}; //ACT var ordersService = new OrdersService(ordersRepository, storageItemsRepository, clientsRepository, mailService); ordersService.PayOrder(order.Id, client.Id); //ASSERT order = ordersRepository.Orders.First(p => p.Id == order.Id); client = clientsRepository.Clients.First(p => p.Id == client.Id); Assert.That(order.Status, Is.EqualTo(OrderStatus.Paid)); Assert.That(client.Balance, Is.EqualTo(80m)); }