public void CheckDifferentMethodProducts() { PhysicalProduct physicalProduct = new PhysicalProduct("Product", 100, 100, "New Product"); DigitalProduct digitalProduct = new DigitalProduct("Product", 100, 100, "New Product"); Assert.IsFalse(physicalProduct.TransportMethod().Equals(digitalProduct.TransportMethod())); }
public IProduct OrderCreation(string product) { IProduct InitiateProduct = null; switch (product) { case "Book": InitiateProduct = new Book(); break; case "PhysicalProduct": InitiateProduct = new PhysicalProduct(); break; case "NewMembership": InitiateProduct = new NewMembership(); break; case "Upgrade": InitiateProduct = new UpgradeMembership(); break; case "Video": InitiateProduct = new Video(); break; } return(InitiateProduct); }
public void Test_PhysicalProduct_ProcessPayment() { Product product = new PhysicalProduct(); product.TryProcessPayment(out bool isSuccess); Assert.True(isSuccess); }
// Process all ProductType payments public void ProcessPayment(PaymentDTO paymentDto) { switch (paymentDto.ProductType) { case ProductType.Book: BookProduct book = new BookProduct(paymentDto, _shippingService, _agentService); book.ProcessPayments(); break; case ProductType.Membership: MembershipProduct membership = new MembershipProduct(paymentDto, _membershipService, _notificationService); membership.ProcessPayments(); break; case ProductType.Video: VideoProduct video = new VideoProduct(paymentDto); video.ProcessPayments(); break; case ProductType.PhysicalProduct: PhysicalProduct physicalProduct = new PhysicalProduct(paymentDto, _shippingService, _agentService); physicalProduct.ProcessPayments(); break; } }
public void RuleNotMatch() { var phyproduct = new PhysicalProduct(); var result = phyproduct.Handle("Failure"); // Assert Assert.AreNotEqual("Create a packing slip for shipping", result); }
public void ValidateRules() { var phyproduct = new PhysicalProduct(); var result = phyproduct.Handle("physical"); // Assert Assert.AreEqual("Create a packing slip for shipping", result); }
public void When_Payment_Is_For_PhysicalProduct_Expect_Generate_Packing_Slip_And_Generate_Comission_Payment() { PhysicalProduct physicalProduct = new PhysicalProduct(); OrderProcessing orderProcessing = new OrderProcessing(physicalProduct, _user); Assert.That(orderProcessing.ProcessOrder(), Is.True); }
public void TestPackagingSlip() { PhysicalProduct product = new PhysicalProduct(); PackingSlipRule packingSlipRule = new PackingSlipRule(product); var result = packingSlipRule.ExecuteRule(); Assert.AreEqual("packing slip executed for Physical Product", result); }
public void physicalProductTest() { PhysicalProduct physicalProduct = new PhysicalProduct(); string physicalProductString = physicalProduct.GetBusinessRuleLogic(); Assert.AreEqual(physicalProductString, "packing slip for shipping"); Assert.AreNotEqual(physicalProductString, "packing slip for shipping1"); }
public void physicalProductNoException() { //Arrange IOrder order = new PhysicalProduct(); int result; //Assert Assert.DoesNotThrow(() => order.ActionTaken(out result)); }
public void Test_MembershipUpgradePayment() { IPayment payment = new PhysicalProductPayment(); IProduct product = new PhysicalProduct(payment); IOrderProcessor processor = new OrderProcessor(); processor.ProcessOrder(product); Assert.Equal("Generate a packing slip for shipping", product.Status); }
public void TestCommisionPayment() { var rule = new CompositeRule( new PaymentCommissionRule()); var physicalProduct = new PhysicalProduct("pp01", "computer"); Assert.AreEqual(false, physicalProduct.isCommissionGenerated); IReadOnlyCollection <ICommand> commands = rule.Handle(physicalProduct); Assert.AreEqual(true, physicalProduct.isCommissionGenerated); }
private static GrpcProduct PresentPhysicalProduct(PhysicalProduct product) { return(new GrpcProduct() { Id = product.Id.ToString(), Name = product.Name, Brand = product.Brand, Category = product.Category, Description = product.Description, Measurements = MeasurementsPresenter.PresentPhysicalMeasurements(product.Measurements) }); }
public static async Task ValidateNewPhysicalProduct(PhysicalProduct product) { try { await ProductEntity.ValidateNewProduct(product); await ValidateDataFields(product); } catch (Exception e) { throw e; } }
public void physicalProductFailureTest() { //Arrange IOrder order = new PhysicalProduct(); int result; //Act order.ActionTaken(out result); //Assert Assert.AreEqual(1, result); }
private static async Task ValidateDataFields(PhysicalProduct product) { try { Weight.Valdiate(product.Weight); Measurements.Validate(product.Measurements); } catch (Exception e) { throw e; } }
public void AddCartItem_ShippingForPhysical_ChangesBool() { // Arrange Sale testSale = new Sale(); Product fysiek = new PhysicalProduct("fiets", 9.99f, "dit is een fietsje", new Tuple <float, float, float>(1, 2, 3), 7); // Act testSale.AddItem(fysiek, "69"); var heeftFysiek = testSale.ContainsPhysical(); // Assert Assert.AreEqual(true, heeftFysiek); }
public void TestForPhysicalProduct() { //arrange string expectedresult = "Generate a packing slip for shipping!"; IProduct product = new PhysicalProduct(); // act var rtntext = product.ProcessPayment(); // assert Assert.Equal(expectedresult, rtntext); }
//[DataRow("-1")] public void AddItem_QuantityMoreThenZero_AddsNewCartItem(string quantity) { // Arrange Sale testSale = new Sale(); Product fysiek = new PhysicalProduct("fiets", 9.99f, "dit is een fietsje", new Tuple <float, float, float>(1, 2, 3), 7); Product digitaal = new DigitalProduct("download", 15f, "hier mee kan je iets downloaden", "www.blah.nl"); // Act //testSale.AddItem(fysiek, quantity); testSale.AddItem(digitaal, quantity); // Assert Assert.AreEqual(false, testSale.IsFilled()); }
public void ShippingForPhysical() { string[] allLines = File.ReadAllLines("Database.txt", Encoding.UTF8); int[] allProducts = new int[allLines.Length]; ShoppingCart shoppingCart = new ShoppingCart(allProducts); shoppingCart.AddToCart(1, 8); shoppingCart.AddToCart(4, 10); Parser parser = new Parser(); PhysicalProduct one = (PhysicalProduct)parser.GetProductFromIndex(1); DigitalProduct two = (DigitalProduct)parser.GetProductFromIndex(4); int noShippingPrice = 8 * one.productPrice + 10 * two.productPrice; Assert.IsTrue(noShippingPrice < shoppingCart.PriceOfCart(OrderType.Inland)); }
// method name syntax: 'subject'_'condition'_'event' public void IsFilled_after_addtion() { // Arrange Sale testSale = new Sale(); Product fysiek = new PhysicalProduct("fiets", 9.99f, "dit is een fietsje", new Tuple <float, float, float>(1, 2, 3), 7); Product digitaal = new DigitalProduct("download", 15f, "hier mee kan je iets downloaden", "www.blah.nl"); // Act testSale.AddItem(fysiek, "3"); testSale.AddItem(digitaal, "5"); var value = testSale.IsFilled(); // Assert Assert.AreEqual(true, value); }
public void MakeOrder_PaymentIsCompleted_PaymentStateCompleted() { // Arrange Sale testSale = new Sale(); Product fysiek = new PhysicalProduct("fiets", 9.99f, "dit is een fietsje", new Tuple <float, float, float>(1, 2, 3), 7); Product digitaal = new DigitalProduct("download", 15f, "hier mee kan je iets downloaden", "www.blah.nl"); // Act testSale.AddItem(fysiek, "1"); testSale.AddItem(digitaal, "69"); testSale.SetCustomerInfo("Floris", "*****@*****.**", CustomerInfo.PaymentMethod.CreditCard, "Utrecht", "Androsdreef 88", "3562XC"); var value = Payment.state; // Assert Assert.AreEqual(PaymentState.Completed, value); }
public double GetTotalWeight(Dictionary <Product, int> products) { double totalWeight = 0; foreach (var item in products) { if (item.Key is PhysicalProduct) { PhysicalProduct physicalItem = item.Key as PhysicalProduct; totalWeight += physicalItem.Size.Weight * item.Value; return(totalWeight); } } return(0); }
public void AddNewItem_WhenAllreadyPresent_AdditionOfQuantity() { // Arrange Sale testSale = new Sale(); Product fysiek = new PhysicalProduct("fiets", 9.99f, "dit is een fietsje", new Tuple <float, float, float>(1, 2, 3), 7); // Act testSale.AddItem(fysiek, "1"); var een = testSale.GetQuantity(); testSale.AddItem(fysiek, "3"); var twee = testSale.GetQuantity(); // Assert Assert.AreEqual(een + 3, twee); }
public string OnNavigatedTo(NavigationData data) { _navData = data; StringBuilder menu = new StringBuilder(); menu.AppendLine($"{_product.Name} - {_product.Price:C}"); menu.AppendLine("-------------------"); if (_product is PhysicalProduct) { PhysicalProduct physicalProduct = _product as PhysicalProduct; menu.AppendLine($"dimentions: {physicalProduct.Size.Depth}x{physicalProduct.Size.Height}x{physicalProduct.Size.Width}"); menu.AppendLine($"weight: { physicalProduct.Size.Weight}"); menu.AppendLine($"color: {physicalProduct.Color}"); if (physicalProduct is Book) { Book book = physicalProduct as Book; menu.AppendLine($"number of pages: {book.NumberOfPages}"); menu.AppendLine($"Author: {book.Author}"); } else if (physicalProduct is BackPack) { BackPack backPack = physicalProduct as BackPack; menu.AppendLine($"volume: {backPack.Volume}"); menu.AppendLine($"material: {backPack.Material}"); } } else { Song song = _product as Song; menu.AppendLine($"Artist: {song.Artist}\nDuration: {song.Duration} sec"); } menu.AppendLine(""); //if (_navData.Cart.Products ) if (_navData.Cart.Products.ContainsKey(_product)) { menu.AppendLine("1. Remove from the cart."); } else if (_navData.StocksReader.GetProductStock(_product.Id) != 0) { menu.AppendLine("1. Add to the cart"); } menu.AppendLine("2. Go to the cart page.\n3. Go to the main page.\n----------"); return(menu.ToString()); }
public void GetPrice_AfterDeletingCart_Zero() { // Arrange Sale testSale = new Sale(); Product fysiek = new PhysicalProduct("fiets", 9.99f, "dit is een fietsje", new Tuple <float, float, float>(1, 2, 3), 7); Product digitaal = new DigitalProduct("download", 15f, "hier mee kan je iets downloaden", "www.blah.nl"); // Act testSale.AddItem(fysiek, "3"); testSale.AddItem(digitaal, "5"); testSale.Cancel(); var value = testSale.GetPrice(); // Assert Assert.AreEqual(0, value); }
public override Product Create(string description) { Target client = new ShippingAgent("Shipping"); client.Link = "URL to Shipping Service"; Target paymentClient = new PaymentServiceAgent("Payment"); paymentClient.Link = "URL to Payment Services"; Product physicalProduct = new PhysicalProduct(description); physicalProduct.Outputs = new List <Output>(); physicalProduct.Outputs.Add(new PackingSlip("Original Packing Slip", physicalProduct, client)); physicalProduct.Outputs.Add(new PackingSlip("Commission Payment", physicalProduct, paymentClient)); return(physicalProduct); }
/// <summary> /// Pass the request to handler according to Payment Type /// </summary> private static void RuleHandler() { AbstractHandler abstractHandler = null; var email = new SendEmail(); var compayment = new CommissionPayment(); var ctx = new Context() { PaymentType = ReadInputRequest() }; var handler = ctx.PaymentType; switch (handler) { case "PhysicalProduct": abstractHandler = new PhysicalProduct(); abstractHandler.SetNext(compayment); break; case "ProductBook": abstractHandler = new ProdcutBook(); abstractHandler.SetNext(compayment); break; case "Membership": abstractHandler = new Membership(); abstractHandler.SetNext(email); break; case "UpgradeMembership": abstractHandler = new UpgradeMembership(); abstractHandler.SetNext(email); break; case "Video": abstractHandler = new Video(); break; default: break; } RuleEngOrchestrator.ClientCode(abstractHandler); Console.WriteLine(); }
public PaymentClient(IProudctFactory factory, Product product) { switch (product.category) { case "physical": physicalProduct = factory.ProcessPhysicalProduct(product); break; case "membership": membership = factory.ProcessMembership(product); break; default: throw new Exception(); } }
public static IProduct GetProduct(string type) { IProduct product = null; switch (type) { case "physical": product = new PhysicalProduct("Pyhsical"); product.SetStrategy(new PhysicalStrategy()); break; case "booking": product = new PhysicalProduct("booking"); product.SetStrategy(new BookingStrategy(new PhysicalStrategy())); break; case "activatemembership": product = new PhysicalProduct("membership"); product.SetStrategy(new NotifyMemebershipChange(new ActivateMembershipStrategy())); break; case "upgrademembership": product = new PhysicalProduct("membership"); product.SetStrategy(new NotifyMemebershipChange(new UpgradeMembershipStrategy())); break; case "video": product = new PhysicalProduct("video"); product.SetStrategy(new VideoStrategy()); break; default: product = null; break; } return(product); }