public void CheckIfAddressNumbersAreUnique() { ShipmentPackageGenerator shipmentPackageGenerator = new ShipmentPackageGenerator(_baseFixture.MockConfiguration); List <ShipmentPackageDTO> packages = shipmentPackageGenerator.GenerateRandomShipmentPackages(); Assert.True(packages.Select(p => p.DeliveryAddressNumber).Distinct().Count() == packages.Count()); }
public void CheckIfPackageNumbersAreNumeric() { ShipmentPackageGenerator shipmentPackageGenerator = new ShipmentPackageGenerator(_baseFixture.MockConfiguration); List <ShipmentPackageDTO> packages = shipmentPackageGenerator.GenerateRandomShipmentPackages(); Assert.True(packages.Select(p => p.PackageNumber).ConvertToInt().Count() == packages.Count()); }
public void CheckIfPackageWeightsAreBetweenTenAndTwentyFive() { ShipmentPackageGenerator shipmentPackageGenerator = new ShipmentPackageGenerator(_baseFixture.MockConfiguration); List <ShipmentPackageDTO> packages = shipmentPackageGenerator.GenerateRandomShipmentPackages(); Assert.True(packages.All(p => p.PackageWeightInKilos >= 10 && p.PackageWeightInKilos <= 25)); }
public void CheckIfPackageCountIsBetweenFiftyAndEighty() { ShipmentPackageGenerator shipmentPackageGenerator = new ShipmentPackageGenerator(_baseFixture.MockConfiguration); List <ShipmentPackageDTO> packages = shipmentPackageGenerator.GenerateRandomShipmentPackages(); Assert.True(packages.Count >= 50 && packages.Count <= 80); }
public ShipmentApiControllerBaseTestFixture() { var mockConfSection = new Mock <IConfigurationSection>(); // Difference between _minQuantity and _maxQuantity MUST NOT BE bigger than 89. Because Address Numbers must be unique and 2 digits mockConfSection.SetupGet(m => m[It.Is <string>(s => s == "MinQuantity")]).Returns("50"); mockConfSection.SetupGet(m => m[It.Is <string>(s => s == "MaxQuantity")]).Returns("80"); mockConfSection.SetupGet(m => m[It.Is <string>(s => s == "MinWeight")]).Returns("10"); mockConfSection.SetupGet(m => m[It.Is <string>(s => s == "MaxWeight")]).Returns("25"); mockConfSection.SetupGet(m => m[It.Is <string>(s => s == "MaxDeliverableWeight")]).Returns("500"); mockConfSection.SetupGet(m => m[It.Is <string>(s => s == "DeliveryVehicleCharge")]).Returns("80"); mockConfSection.SetupGet(m => m[It.Is <string>(s => s == "DeliveryTimeBetweenStopsInMinutes")]).Returns("1"); mockConfSection.SetupGet(m => m[It.Is <string>(s => s == "WorkingHourStartHour")]).Returns("9"); mockConfSection.SetupGet(m => m[It.Is <string>(s => s == "WorkingStartMinute")]).Returns("0"); mockConfSection.SetupGet(m => m[It.Is <string>(s => s == "WorkingHourEndHour")]).Returns("18"); mockConfSection.SetupGet(m => m[It.Is <string>(s => s == "WorkingHourEndMinute")]).Returns("30"); var mockConfiguration = new Mock <IConfiguration>(); mockConfiguration.Setup(a => a.GetSection(It.Is <string>(s => s == "AppSettings"))).Returns(mockConfSection.Object); IShipmentPackageGenerator mockedShipmentPackageGenerator = new ShipmentPackageGenerator(mockConfiguration.Object); IMemoryCache mockedCache = Create.MockedMemoryCache(); MockedShipmentBusiness = new ShipmentBusiness(mockedShipmentPackageGenerator, mockedCache); }
public void CheckIfPackageNumbersAreMinimumEightDigits() { ShipmentPackageGenerator shipmentPackageGenerator = new ShipmentPackageGenerator(_baseFixture.MockConfiguration); List <ShipmentPackageDTO> packages = shipmentPackageGenerator.GenerateRandomShipmentPackages(); IEnumerable <string> packageNumbers = packages.Select(p => p.PackageNumber); Assert.True(packageNumbers.All(p => p.Length >= 8)); }
public void CheckIfPackageNumbersAreNullOrEmpty() { ShipmentPackageGenerator shipmentPackageGenerator = new ShipmentPackageGenerator(_baseFixture.MockConfiguration); List <ShipmentPackageDTO> packages = shipmentPackageGenerator.GenerateRandomShipmentPackages(); IEnumerable <string> packageNumbers = packages.Select(p => p.PackageNumber); Assert.DoesNotContain(packageNumbers, p => string.IsNullOrEmpty(p)); }
public void CheckIfAddressNumbersAreTwoDigits() { ShipmentPackageGenerator shipmentPackageGenerator = new ShipmentPackageGenerator(_baseFixture.MockConfiguration); List <ShipmentPackageDTO> packages = shipmentPackageGenerator.GenerateRandomShipmentPackages(); IEnumerable <string> packageAddressNumbers = packages.Select(p => p.DeliveryAddressNumber); Assert.True(packageAddressNumbers.All(p => p.Length == 2)); }
public void CheckIfLastDeliverablePackagesDeliveryTimeIsBeforeWorkingHoursEnd() { ShipmentPackageGenerator shipmentPackageGenerator = new ShipmentPackageGenerator(_baseFixture.MockConfiguration); List <ShipmentPackageDTO> packages = shipmentPackageGenerator.GenerateRandomShipmentPackages(); ShipmentPackageDTO lastDeliverablePackage = packages.Last(p => p.ApproximateDeliveryTime.HasValue); int workingHourEndHour, workingHourEndMinute; int.TryParse(_baseFixture.MockConfiguration.GetSection("AppSettings")["WorkingHourEndHour"], out workingHourEndHour); int.TryParse(_baseFixture.MockConfiguration.GetSection("AppSettings")["WorkingHourEndMinute"], out workingHourEndMinute); var endWorkingTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, workingHourEndHour, workingHourEndMinute, 0); Assert.True(lastDeliverablePackage.ApproximateDeliveryTime < endWorkingTime); }