public void ExpirationDays_less_than_1() { //Arrange var stock = new ItemStock { Price = 100, ExpirationDate = DateTime.Now }; //Act var newPrice = strategy.CalculatePrice(stock); //Assert Assert.AreEqual(0, newPrice, 0.02d); }
public void ComputeYears_between_2_4() { //Arrange var stock = new ItemStock { Price = 100, ManufacturingDate = DateTime.Now.AddYears(-4), Entrydate = DateTime.Now.AddYears(-1) }; //Act var newPrice = strategy.CalculatePrice(stock); //Assert Assert.AreEqual(105d, newPrice, 0.02d); }
public async Task CalculatePriceAsync_WhenRideIsASharedRide_ReturnsTheCorrectPrice() { decimal distance = 10; decimal calculatedPrice = 75; _googleMapsApiService.GetDistanceInKmAsync(Arg.Any <string>(), Arg.Any <string>()) .ReturnsForAnyArgs(distance); _sharedRidePriceStrategy.CalculatePrice(distance).Returns(calculatedPrice); _priceStrategyFactory.GetPriceStrategy(Arg.Any <RideType>()).Returns(_sharedRidePriceStrategy); decimal price = await _rideService.CalculatePriceAsync(_anAddress, _anAddress, RideType.SharedRide); Assert.That(price, Is.EqualTo(calculatedPrice)); }
public void Same_price() { //Arrange var stock = new ItemStock { Price = 100 }; //Act var newPrice = strategy.CalculatePrice(stock); //Assert Assert.AreEqual(100, newPrice, 0.02d); }
public void Notify(IMenu menu) { Console.WriteLine($"{menu.Pizza}kr"); if (menu.Drink != null) { Console.WriteLine($"Served with {menu.Drink} at the cost of {menu.MenuPrice-menu.Pizza.Price}kr"); } double price = 0; switch (DayTime) { case TimeOfDay.Evening: price = EveningPriceStrategy.CalculatePrice(menu); break; case TimeOfDay.Lunch: price = LunchPriceStrategy.CalculatePrice(menu); break; case TimeOfDay.Night: price = NightPriceStrategy.CalculatePrice(menu); break; } Console.WriteLine($"Since it's {DayTime} the price is increased by 10% and the total cost is {price}kr"); }