public void CreateOffer_ValidateCreationWithOfferPrice_Successful() { var product1 = new Product("Product1", 2, 5); var product2 = new Product("Product2", 3, 10); var product3 = new Product("Product3", 4, 23); var product4 = new Product("Product4", 5, 23); var offer = manager.CreateOffer(new List <IProduct>() { product1, product2, product3, product4 }, new DateTime(DateTime.Now.Year - 1, 1, DateTime.Now.Day), DateTime.Now, new List <ITransport>()); var expectedPrice = (product1.Price + product2.Price + product3.Price + product4.Price) * (1 - 0.17); Assert.AreEqual(expectedPrice, offer.OfferPrice); }
public void CreateOffer_InvalidTest(IClient client, List <IProduct> products, List <ITransport> transports) { SalesManager salesManager = new SalesManager(); int numberOfProducts = ShoppingOffers.Offers.Count; Assert.Throws <ArgumentNullException>(() => salesManager.CreateOffer(client, products, transports)); }
public void GetOffersByTransportID_InvalidGuidTest() { SalesManager salesManager = new SalesManager(); ITransport transport = new Transport("gojowgijweoirg", 3); List <ITransport> transportList = new List <ITransport>(); transportList.Add(transport); salesManager.CreateOffer(new FizickoLice(), new List <IProduct>(), transportList); salesManager.CreateOffer(new FizickoLice(), new List <IProduct>(), transportList); salesManager.CreateOffer(new FizickoLice(), new List <IProduct>(), transportList); var result = salesManager.GetOffersByTransportID(Guid.NewGuid()); Assert.IsNotNull(result); Assert.AreEqual(result.Count, 0); }
public void GetOffersByProductID_InvalidGuidTest() { SalesManager salesManager = new SalesManager(); IProduct product = new Product("dgfsafg", "fgwerf", 4234, 1); List <IProduct> productList = new List <IProduct>(); productList.Add(product); salesManager.CreateOffer(new FizickoLice(), productList, new List <ITransport>()); salesManager.CreateOffer(new FizickoLice(), productList, new List <ITransport>()); salesManager.CreateOffer(new FizickoLice(), productList, new List <ITransport>()); var result = salesManager.GetOffersByProductID(Guid.NewGuid()); Assert.IsNotNull(result); Assert.AreEqual(result.Count, 0); }
public void CreateOffer_ValidTest() { SalesManager salesManager = new SalesManager(); int numberOfOffers = ShoppingOffers.Offers.Count; salesManager.CreateOffer(new FizickoLice(), new List <IProduct>(), new List <ITransport>()); Assert.AreEqual(numberOfOffers + 1, ShoppingOffers.Offers.Count); }
public void GetLowestOffer_InvalidTest() { SalesManager salesManager = new SalesManager(); IProduct product1 = new Product("dgfsafg", "fgwerf", 4234, 1); IProduct product2 = new Product("dgfsafg", "fgwerf", 7568756, 1); IProduct product3 = new Product("dgfsafg", "fgwerf", 345345, 1); List <IProduct> productList1 = new List <IProduct>(); List <IProduct> productList2 = new List <IProduct>(); productList1.Add(product1); productList2.Add(product2); productList2.Add(product3); salesManager.CreateOffer(new FizickoLice(), productList2, new List <ITransport>()); salesManager.CreateOffer(new FizickoLice(), productList2, new List <ITransport>()); salesManager.CreateOffer(new FizickoLice(), productList1, new List <ITransport>()); Assert.Throws <ArgumentNullException>(() => salesManager.GetLowestOffer(null)); }
public void GetLowestOffer_ValidTest() { SalesManager salesManager = new SalesManager(); IProduct product1 = new Product("dgfsafg", "fgwerf", 4234, 1); IProduct product2 = new Product("dgfsafg", "fgwerf", 7568756, 1); IProduct product3 = new Product("dgfsafg", "fgwerf", 345345, 1); List <IProduct> productList1 = new List <IProduct>(); List <IProduct> productList2 = new List <IProduct>(); productList1.Add(product1); productList2.Add(product2); productList2.Add(product3); ShoppingOffers.Offers.Clear(); salesManager.CreateOffer(new FizickoLice(), productList2, new List <ITransport>()); salesManager.CreateOffer(new FizickoLice(), productList2, new List <ITransport>()); salesManager.CreateOffer(new FizickoLice(), productList1, new List <ITransport>()); IOffer result = salesManager.GetLowestOffer(ShoppingOffers.Offers.Values.ToList()); Assert.IsNotNull(result); Assert.AreEqual(result.Price, 4234); }
public void CreateTransaction_ValidTest(int year, int month, int day, int rating, string transcationTypeKey) { IEmailSender emailSender = Substitute.For <IEmailSender>(); IFinanceManager financeManager = new FinanceManager(); IClientManager clientManager = new ClientManager(); ISalesManager salesManager = new SalesManager(); ShoppingClient.Clients.Clear(); ShoppingOffers.Offers.Clear(); clientManager.RegisterUser("Pera", "Peric", "*****@*****.**", "peraPeric123", "Novi Sad", new DateTime(1992, 5, 6), new List <IAccount>()); clientManager.RegisterOrg("Prodavnica", "q234ffsad", "Novi Sad", "*****@*****.**", new DateTime(2010, 1, 1), new List <IAccount>()); IClient client = ShoppingClient.Clients.FirstOrDefault(x => x is FizickoLice); IClient company = ShoppingClient.Clients.FirstOrDefault(x => x is PravnoLice); IProduct product = new Product("Product", "Description", 3000, 1); salesManager.CreateOffer(company, new List <IProduct>() { product }, new List <ITransport>()); financeManager.CreateAccount("41234123453425", new Bank(), 100000, 0, false); financeManager.CreateAccount("456345634567456", new Bank(), 100000, 0, false); IAccount customerAccount = FinantialDB.Accounts.Values.ToList()[0]; IAccount companyAccount = FinantialDB.Accounts.Values.ToList()[1]; client.ListOfAccounts.Add(customerAccount); customerAccount.Balance = 1000000; company.ListOfAccounts.Add(companyAccount); companyAccount.Balance = 2000000; IOffer offer = ShoppingOffers.Offers.Values.ToList()[0]; offer.SubmitionDate = new DateTime(year, month, day); ITransactionManager transactionManager = new TransactionManager(clientManager, salesManager, financeManager, emailSender); ITransactionType transactionType = ShoppingTransaction.TransactionTypes[transcationTypeKey]; transactionManager.CreateTransaction(client.ID, company.ID, offer.ID, transactionType.ID, rating); Assert.IsTrue(client.ListOfBuyingTransaction.Count == 1); Assert.IsTrue(company.ListOfSellingTransaction.Count == 1); }