ex-int-04-shipping-cost/ShippingCosts.Test/SelfPickupTests.cs
github-classroom[bot] 5db225db88
Initial commit
2025-04-29 15:01:53 +00:00

39 lines
1.2 KiB
C#

using ShippingCosts.Contracts;
using ShippingCosts.Implementations;
namespace ShippingCosts.Test;
public sealed class SelfPickupTests
{
[Fact]
public void InterfaceAndClassHierarchy()
{
var calculator = new SelfPickup();
calculator.Should()
.NotBeAssignableTo<ShippingCostCalculatorBase>("independent class")
.And.BeAssignableTo<IShippingCostCalculator>("but implements interface");
}
[Fact]
public void CarrierName()
{
new SelfPickup().CarrierName.Should().Be("Self Pickup");
}
[Theory]
[InlineData("Italy", 5, 10, 15, 20)]
[InlineData("Israel", 10, 20, 30, 40)]
[InlineData("Malaysia", 1, 2, 3, 4)]
public void CalculateShippingCosts_AlwaysZero(string targetCountry, int width, int height, int depth, double weight)
{
var box = Substitute.For<IMeasuredBox>();
box.Width.Returns(width);
box.Height.Returns(height);
box.Depth.Returns(depth);
box.Weight.Returns(weight);
new SelfPickup().CalculateShippingCosts(targetCountry, box).Should()
.Be(0M, "shipping cost is always zero if picking the item up yourself");
}
}