public void Scenario1() { var uow = new Mock<IPropertyUpgradeUoW>(); var calculator = new BuildingUpgradeDurationCalculator(uow.Object); var request = new BuildingUpgradeDurationCalculatorRequest { BuildingUpgrade = new BuildingUpgrade { Products = new List<Product> { new Product { ProductTypeId = 4, Quantity = 1 } } }, CityStorage = CityStorage(), ProductTypes = ProductTypes() }; var ret = calculator.CalculateUpgradeTime(request); Assert.IsNotNull(ret); request.BuildingUpgrade.TotalUpgradeTime.ShouldEqual(10); request.BuildingUpgrade.RemainingUpgradeTime.ShouldEqual(10); request.BuildingUpgrade.Products.First().TotalDuration.ShouldEqual(10); request.BuildingUpgrade.Products.First().RemainingDuration.ShouldEqual(10); }
public void Scenario5() { var uow = new Mock<IPropertyUpgradeUoW>(); var calculator = new BuildingUpgradeDurationCalculator(uow.Object); var cityStorage = CityStorage(); var prod = cityStorage.CurrentInventory.First(x => x.ProductTypeId == 4); prod.Quantity = 1; var request = new BuildingUpgradeDurationCalculatorRequest { BuildingUpgrade = new BuildingUpgrade { Products = new List<Product> { new Product { ProductTypeId = 3, Quantity = 1 } } }, CityStorage = cityStorage, ProductTypes = ProductTypes() }; var ret = calculator.CalculateUpgradeTime(request); Assert.IsNotNull(ret); ret.TotalUpgradeTime.ShouldEqual(20); ret.RemainingUpgradeTime.ShouldEqual(10); }
public void Scenario3() { var uow = new Mock<IPropertyUpgradeUoW>(); var calculator = new BuildingUpgradeDurationCalculator(uow.Object); var request = new BuildingUpgradeDurationCalculatorRequest { BuildingUpgrade = new BuildingUpgrade { Products = new List<Product> { new Product { ProductTypeId = 2, Quantity = 1 } } }, CityStorage = CityStorage(), ProductTypes = ProductTypes() }; var ret = calculator.CalculateUpgradeTime(request); Assert.IsNotNull(ret); ret.TotalUpgradeTime.ShouldEqual(50); ret.RemainingUpgradeTime.ShouldEqual(50); request.BuildingUpgrade.Products.First().TotalDuration.ShouldEqual(50); request.BuildingUpgrade.Products.First().RemainingDuration.ShouldEqual(50); request.BuildingUpgrade.Products.First().RequiredProducts.FirstOrDefault().ShouldNotBeNull(); request.BuildingUpgrade.Products.First().RequiredProducts.Count().ShouldEqual(2); request.BuildingUpgrade.Products.First().RequiredProducts.ToArray()[0].TotalDuration.ShouldEqual(20); request.BuildingUpgrade.Products.First().RequiredProducts.ToArray()[0].RemainingDuration.ShouldEqual(20); request.BuildingUpgrade.Products.First().RequiredProducts.ToArray()[1].TotalDuration.ShouldEqual(20); request.BuildingUpgrade.Products.First().RequiredProducts.ToArray()[1].RemainingDuration.ShouldEqual(20); }