using ShippingCosts.Contracts; using ShippingCosts.Implementations; namespace ShippingCosts.Test; public sealed class CountryDistanceProviderTests { private readonly ICountryDistanceProvider _provider = new CountryDistanceProvider(); [Theory] [InlineData("India", true)] [InlineData("Chile", false)] public void IsPossibleCountry(string country, bool isAvailable) { _provider.IsPossibleCountry(country) .Should().Be(isAvailable); } [Theory] [InlineData("Brazil", 9820, false, false)] [InlineData("France", 1036, false, true)] [InlineData("Italy", 763, true, true)] [InlineData("Japan", 9278, false, false)] [InlineData("Switzerland", 692, true, false)] public void GetDistanceTo_ExistingCountry(string countryName, int expectedDistance, bool expectedIsDirectNeighbor, bool expectedIsEuMember) { _provider.GetDistanceTo(countryName) .Should().NotBeNull("country exists and is in database") .And.BeOfType() .And.Match(x => x.ApproxDistance == expectedDistance && x.IsDirectNeighbor == expectedIsDirectNeighbor && x.IsEuMember == expectedIsEuMember); } [Theory] [InlineData("NonExistingCountry")] [InlineData("Atlantis")] public void GetDistanceTo_NonExistingCountry(string countryName) { _provider.GetDistanceTo(countryName).Should().BeNull("country does not exist"); } [Fact] public void GetDistanceTo_EmptyCountryName() { _provider.GetDistanceTo(string.Empty).Should().BeNull("country name is empty"); } [Fact] public void GetDistanceTo_NotDefinedCountry() { _provider.GetDistanceTo("Sweden") .Should().BeNull("country exists, but is not in internal database"); } }