diff --git a/ShippingRates.Tests/Helpers/DHLServicesValidatorTests.cs b/ShippingRates.Tests/Helpers/DHLServicesValidatorTests.cs index 6b4b5fd..5f8ecef 100644 --- a/ShippingRates.Tests/Helpers/DHLServicesValidatorTests.cs +++ b/ShippingRates.Tests/Helpers/DHLServicesValidatorTests.cs @@ -1,9 +1,5 @@ using NUnit.Framework; -using ShippingRates.Helpers; -using System; -using System.Collections.Generic; using System.Linq; -using System.Text; namespace ShippingRates.Helpers.Tests { @@ -13,9 +9,12 @@ public class DHLServicesValidatorTests [Test()] public void IsServiceValidTest() { - Assert.IsTrue(DHLServicesValidator.IsServiceValid('M')); - Assert.IsTrue(DHLServicesValidator.IsServiceValid('n')); - Assert.IsFalse(DHLServicesValidator.IsServiceValid('9')); + Assert.Multiple(() => + { + Assert.That(DHLServicesValidator.IsServiceValid('M'), Is.True); + Assert.That(DHLServicesValidator.IsServiceValid('n'), Is.True); + Assert.That(DHLServicesValidator.IsServiceValid('9'), Is.False); + }); } [Test()] @@ -24,11 +23,14 @@ public void GetValidServicesTest() var services = new char[] { 'M', 'n', '9' }; var validServices = DHLServicesValidator.GetValidServices(services); - Assert.IsTrue(validServices.Count() == 2); - Assert.IsTrue(validServices.Count(s => s == 'M') == 1); - Assert.IsTrue(validServices.Count(s => s == 'n') == 0); - Assert.IsTrue(validServices.Count(s => s == 'N') == 1); - Assert.IsTrue(validServices.Count(s => s == '9') == 0); + Assert.Multiple(() => + { + Assert.That(validServices, Has.Length.EqualTo(2)); + Assert.That(validServices.Count(s => s == 'M'), Is.EqualTo(1)); + Assert.That(validServices.Where(s => s == 'n'), Is.Empty); + Assert.That(validServices.Count(s => s == 'N'), Is.EqualTo(1)); + Assert.That(validServices.Where(s => s == '9'), Is.Empty); + }); } } } diff --git a/ShippingRates.Tests/ShippingProviders/FedExSmartPostShipRates.cs b/ShippingRates.Tests/ShippingProviders/FedExSmartPostShipRates.cs index da3804e..bc5155e 100644 --- a/ShippingRates.Tests/ShippingProviders/FedExSmartPostShipRates.cs +++ b/ShippingRates.Tests/ShippingProviders/FedExSmartPostShipRates.cs @@ -58,8 +58,8 @@ public void CanGetFedExServiceCodes() { var serviceCodes = _provider.GetServiceCodes(); - Assert.NotNull(serviceCodes); - Assert.IsNotEmpty(serviceCodes); + Assert.That(serviceCodes, Is.Not.Null); + Assert.That(serviceCodes, Is.Not.Empty); } } } diff --git a/ShippingRates.Tests/Units/PackageDimensionTests.cs b/ShippingRates.Tests/Units/PackageDimensionTests.cs index a487e33..a2b35c4 100644 --- a/ShippingRates.Tests/Units/PackageDimensionTests.cs +++ b/ShippingRates.Tests/Units/PackageDimensionTests.cs @@ -10,36 +10,48 @@ public class PackageWeightTests public void LbsToKgs() { var weight1 = new PackageWeight(UnitsSystem.USCustomary, 5); - Assert.AreEqual(5, weight1.Get()); - Assert.AreEqual(5, weight1.Get(UnitsSystem.USCustomary)); - Assert.AreEqual(2.26796185m, weight1.Get(UnitsSystem.Metric)); - Assert.AreEqual(5, weight1.GetRounded(UnitsSystem.USCustomary)); - Assert.AreEqual(3, weight1.GetRounded(UnitsSystem.Metric)); + Assert.Multiple(() => + { + Assert.That(weight1.Get(), Is.EqualTo(5)); + Assert.That(weight1.Get(UnitsSystem.USCustomary), Is.EqualTo(5)); + Assert.That(weight1.Get(UnitsSystem.Metric), Is.EqualTo(2.26796185m)); + Assert.That(weight1.GetRounded(UnitsSystem.USCustomary), Is.EqualTo(5)); + Assert.That(weight1.GetRounded(UnitsSystem.Metric), Is.EqualTo(3)); + }); var weight2 = new PackageWeight(UnitsSystem.USCustomary, 0.3m); - Assert.AreEqual(0.3m, weight2.Get()); - Assert.AreEqual(0.3m, weight2.Get(UnitsSystem.USCustomary)); - Assert.AreEqual(0.136077711m, weight2.Get(UnitsSystem.Metric)); - Assert.AreEqual(1, weight2.GetRounded(UnitsSystem.USCustomary)); - Assert.AreEqual(1, weight2.GetRounded(UnitsSystem.Metric)); + Assert.Multiple(() => + { + Assert.That(weight2.Get(), Is.EqualTo(0.3m)); + Assert.That(weight2.Get(UnitsSystem.USCustomary), Is.EqualTo(0.3m)); + Assert.That(weight2.Get(UnitsSystem.Metric), Is.EqualTo(0.136077711m)); + Assert.That(weight2.GetRounded(UnitsSystem.USCustomary), Is.EqualTo(1)); + Assert.That(weight2.GetRounded(UnitsSystem.Metric), Is.EqualTo(1)); + }); } [Test()] public void KgsToLbs() { var weight1 = new PackageWeight(UnitsSystem.Metric, 5); - Assert.AreEqual(5, weight1.Get()); - Assert.AreEqual(11.0231m, weight1.Get(UnitsSystem.USCustomary)); - Assert.AreEqual(5, weight1.Get(UnitsSystem.Metric)); - Assert.AreEqual(12, weight1.GetRounded(UnitsSystem.USCustomary)); - Assert.AreEqual(5, weight1.GetRounded(UnitsSystem.Metric)); + Assert.Multiple(() => + { + Assert.That(weight1.Get(), Is.EqualTo(5)); + Assert.That(weight1.Get(UnitsSystem.USCustomary), Is.EqualTo(11.0231m)); + Assert.That(weight1.Get(UnitsSystem.Metric), Is.EqualTo(5)); + Assert.That(weight1.GetRounded(UnitsSystem.USCustomary), Is.EqualTo(12)); + Assert.That(weight1.GetRounded(UnitsSystem.Metric), Is.EqualTo(5)); + }); var weight2 = new PackageWeight(UnitsSystem.Metric, 0.5m); - Assert.AreEqual(0.5m, weight2.Get()); - Assert.AreEqual(1.10231m, weight2.Get(UnitsSystem.USCustomary)); - Assert.AreEqual(0.5m, weight2.Get(UnitsSystem.Metric)); - Assert.AreEqual(2, weight2.GetRounded(UnitsSystem.USCustomary)); - Assert.AreEqual(1, weight2.GetRounded(UnitsSystem.Metric)); + Assert.Multiple(() => + { + Assert.That(weight2.Get(), Is.EqualTo(0.5m)); + Assert.That(weight2.Get(UnitsSystem.USCustomary), Is.EqualTo(1.10231m)); + Assert.That(weight2.Get(UnitsSystem.Metric), Is.EqualTo(0.5m)); + Assert.That(weight2.GetRounded(UnitsSystem.USCustomary), Is.EqualTo(2)); + Assert.That(weight2.GetRounded(UnitsSystem.Metric), Is.EqualTo(1)); + }); } } } diff --git a/ShippingRates.Tests/Units/PackageKgCmTests.cs b/ShippingRates.Tests/Units/PackageKgCmTests.cs index 3d5a798..95093a8 100644 --- a/ShippingRates.Tests/Units/PackageKgCmTests.cs +++ b/ShippingRates.Tests/Units/PackageKgCmTests.cs @@ -1,5 +1,4 @@ using NUnit.Framework; -using ShippingRates.Models; namespace ShippingRates.Tests.Units { @@ -12,15 +11,18 @@ public void TestDimensions() var packageLbsInches = new Package(10, 20, 30, 40, 50); var packageKgCm = new PackageKgCm(10, 20, 30, 40, 50); - Assert.AreNotEqual(packageKgCm.GetHeight(UnitsSystem.Metric), packageLbsInches.GetHeight(UnitsSystem.Metric)); - Assert.AreNotEqual(packageKgCm.GetLength(UnitsSystem.Metric), packageLbsInches.GetLength(UnitsSystem.Metric)); - Assert.AreNotEqual(packageKgCm.GetWidth(UnitsSystem.USCustomary), packageLbsInches.GetWidth(UnitsSystem.USCustomary)); - Assert.AreNotEqual(packageKgCm.GetHeight(UnitsSystem.USCustomary), packageLbsInches.GetHeight(UnitsSystem.USCustomary)); + Assert.Multiple(() => + { + Assert.That(packageLbsInches.GetHeight(UnitsSystem.Metric), Is.Not.EqualTo(packageKgCm.GetHeight(UnitsSystem.Metric))); + Assert.That(packageLbsInches.GetLength(UnitsSystem.Metric), Is.Not.EqualTo(packageKgCm.GetLength(UnitsSystem.Metric))); + Assert.That(packageLbsInches.GetWidth(UnitsSystem.USCustomary), Is.Not.EqualTo(packageKgCm.GetWidth(UnitsSystem.USCustomary))); + Assert.That(packageLbsInches.GetHeight(UnitsSystem.USCustomary), Is.Not.EqualTo(packageKgCm.GetHeight(UnitsSystem.USCustomary))); - Assert.AreEqual(40, packageLbsInches.GetWeight(UnitsSystem.USCustomary)); - Assert.AreEqual(18.1436948m, packageLbsInches.GetWeight(UnitsSystem.Metric)); - Assert.AreEqual(88.1848m, packageKgCm.GetWeight(UnitsSystem.USCustomary)); - Assert.AreEqual(40, packageKgCm.GetWeight(UnitsSystem.Metric)); + Assert.That(packageLbsInches.GetWeight(UnitsSystem.USCustomary), Is.EqualTo(40)); + Assert.That(packageLbsInches.GetWeight(UnitsSystem.Metric), Is.EqualTo(18.1436948m)); + Assert.That(packageKgCm.GetWeight(UnitsSystem.USCustomary), Is.EqualTo(88.1848m)); + Assert.That(packageKgCm.GetWeight(UnitsSystem.Metric), Is.EqualTo(40)); + }); } } } diff --git a/ShippingRates.Tests/Units/PackageTests.cs b/ShippingRates.Tests/Units/PackageTests.cs index fdebb51..f2a5b96 100644 --- a/ShippingRates.Tests/Units/PackageTests.cs +++ b/ShippingRates.Tests/Units/PackageTests.cs @@ -14,8 +14,11 @@ public class PackageTests public void PoundsAndOuncesCalculatedCorrectly(decimal weight, int pounds, decimal ounces) { var package = new Package(1, 2, 3, weight, 100); - Assert.That(package.PoundsAndOunces.Pounds, Is.EqualTo(pounds)); - Assert.That(package.PoundsAndOunces.Ounces, Is.EqualTo(ounces)); + Assert.Multiple(() => + { + Assert.That(package.PoundsAndOunces.Pounds, Is.EqualTo(pounds)); + Assert.That(package.PoundsAndOunces.Ounces, Is.EqualTo(ounces)); + }); } } } diff --git a/ShippingRates.Tests/Units/PackageWeightTests.cs b/ShippingRates.Tests/Units/PackageWeightTests.cs index aeee801..9fc3ca7 100644 --- a/ShippingRates.Tests/Units/PackageWeightTests.cs +++ b/ShippingRates.Tests/Units/PackageWeightTests.cs @@ -10,36 +10,48 @@ public class PackageDimensionTests public void InchesToCm() { var dimension1 = new PackageDimension(UnitsSystem.USCustomary, 5); - Assert.AreEqual(5, dimension1.Get()); - Assert.AreEqual(5, dimension1.Get(UnitsSystem.USCustomary)); - Assert.AreEqual(12.7m, dimension1.Get(UnitsSystem.Metric)); - Assert.AreEqual(5, dimension1.GetRounded(UnitsSystem.USCustomary)); - Assert.AreEqual(13, dimension1.GetRounded(UnitsSystem.Metric)); + Assert.Multiple(() => + { + Assert.That(dimension1.Get(), Is.EqualTo(5)); + Assert.That(dimension1.Get(UnitsSystem.USCustomary), Is.EqualTo(5)); + Assert.That(dimension1.Get(UnitsSystem.Metric), Is.EqualTo(12.7m)); + Assert.That(dimension1.GetRounded(UnitsSystem.USCustomary), Is.EqualTo(5)); + Assert.That(dimension1.GetRounded(UnitsSystem.Metric), Is.EqualTo(13)); + }); var dimension2 = new PackageDimension(UnitsSystem.USCustomary, 0.4m); - Assert.AreEqual(0.4m, dimension2.Get()); - Assert.AreEqual(0.4m, dimension2.Get(UnitsSystem.USCustomary)); - Assert.AreEqual(1.016m, dimension2.Get(UnitsSystem.Metric)); - Assert.AreEqual(1, dimension2.GetRounded(UnitsSystem.USCustomary)); - Assert.AreEqual(2, dimension2.GetRounded(UnitsSystem.Metric)); + Assert.Multiple(() => + { + Assert.That(dimension2.Get(), Is.EqualTo(0.4m)); + Assert.That(dimension2.Get(UnitsSystem.USCustomary), Is.EqualTo(0.4m)); + Assert.That(dimension2.Get(UnitsSystem.Metric), Is.EqualTo(1.016m)); + Assert.That(dimension2.GetRounded(UnitsSystem.USCustomary), Is.EqualTo(1)); + Assert.That(dimension2.GetRounded(UnitsSystem.Metric), Is.EqualTo(2)); + }); } [Test()] public void CmToInches() { var dimension1 = new PackageDimension(UnitsSystem.Metric, 6); - Assert.AreEqual(6, dimension1.Get()); - Assert.AreEqual(2.362206m, dimension1.Get(UnitsSystem.USCustomary)); - Assert.AreEqual(6, dimension1.Get(UnitsSystem.Metric)); - Assert.AreEqual(3, dimension1.GetRounded(UnitsSystem.USCustomary)); - Assert.AreEqual(6, dimension1.GetRounded(UnitsSystem.Metric)); + Assert.Multiple(() => + { + Assert.That(dimension1.Get(), Is.EqualTo(6)); + Assert.That(dimension1.Get(UnitsSystem.USCustomary), Is.EqualTo(2.362206m)); + Assert.That(dimension1.Get(UnitsSystem.Metric), Is.EqualTo(6)); + Assert.That(dimension1.GetRounded(UnitsSystem.USCustomary), Is.EqualTo(3)); + Assert.That(dimension1.GetRounded(UnitsSystem.Metric), Is.EqualTo(6)); + }); var dimension2 = new PackageDimension(UnitsSystem.Metric, 2.6m); - Assert.AreEqual(2.6m, dimension2.Get()); - Assert.AreEqual(1.0236226m, dimension2.Get(UnitsSystem.USCustomary)); - Assert.AreEqual(2.6m, dimension2.Get(UnitsSystem.Metric)); - Assert.AreEqual(2, dimension2.GetRounded(UnitsSystem.USCustomary)); - Assert.AreEqual(3, dimension2.GetRounded(UnitsSystem.Metric)); + Assert.Multiple(() => + { + Assert.That(dimension2.Get(), Is.EqualTo(2.6m)); + Assert.That(dimension2.Get(UnitsSystem.USCustomary), Is.EqualTo(1.0236226m)); + Assert.That(dimension2.Get(UnitsSystem.Metric), Is.EqualTo(2.6m)); + Assert.That(dimension2.GetRounded(UnitsSystem.USCustomary), Is.EqualTo(2)); + Assert.That(dimension2.GetRounded(UnitsSystem.Metric), Is.EqualTo(3)); + }); } } }