diff --git a/Behavioral/DesignPatterns.Visitor.UnitTests/DesignPatterns.Visitor.UnitTests.csproj b/Behavioral/DesignPatterns.Visitor.UnitTests/DesignPatterns.Visitor.UnitTests.csproj new file mode 100644 index 0000000..8144415 --- /dev/null +++ b/Behavioral/DesignPatterns.Visitor.UnitTests/DesignPatterns.Visitor.UnitTests.csproj @@ -0,0 +1,36 @@ + + + + net8.0 + enable + enable + DesignPatterns.Visitor.UnitTests + false + true + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + \ No newline at end of file diff --git a/Behavioral/DesignPatterns.Visitor.UnitTests/StringVisitor.cs b/Behavioral/DesignPatterns.Visitor.UnitTests/StringVisitor.cs new file mode 100644 index 0000000..97b08fa --- /dev/null +++ b/Behavioral/DesignPatterns.Visitor.UnitTests/StringVisitor.cs @@ -0,0 +1,27 @@ +using DesignPatterns.Visitor.Models; +using Shouldly; +using Xunit; + +namespace DesignPatterns.Visitor.UnitTests; + +public class StringVisitorTests +{ + [Theory] + [InlineData("256KB", 256, typeof(SizeInKiloBytes))] + [InlineData("512 KB", 512, typeof(SizeInKiloBytes))] + [InlineData("256MB", 256, typeof(SizeInMegaBytes))] + [InlineData("512 MB", 512, typeof(SizeInMegaBytes))] + [InlineData("256GB", 256, typeof(SizeInGigaBytes))] + [InlineData("512 GB", 512, typeof(SizeInGigaBytes))] + [InlineData("256TB", 256, typeof(SizeInTeraBytes))] + [InlineData("512 TB", 512, typeof(SizeInTeraBytes))] + [InlineData("256PB", 256, typeof(SizeInPetaBytes))] + [InlineData("512 PB", 512, typeof(SizeInPetaBytes))] + public void GivenStringValue_WhenCallVisit_ThenResultAsExpected(string inputValue, long expectedValue, Type expectedType) + { + var stringVisitor = new StringVisitor(); + var result = stringVisitor.Visit(inputValue); + result.ShouldBeOfType(expectedType); + result.Value.ShouldBe(expectedValue); + } +} diff --git a/Behavioral/DesignPatterns.Visitor/DesignPatterns.Visitor.csproj b/Behavioral/DesignPatterns.Visitor/DesignPatterns.Visitor.csproj index c34b924..6e6c6e3 100644 --- a/Behavioral/DesignPatterns.Visitor/DesignPatterns.Visitor.csproj +++ b/Behavioral/DesignPatterns.Visitor/DesignPatterns.Visitor.csproj @@ -9,8 +9,4 @@ DesignPatterns.Visitor - - - - - + \ No newline at end of file diff --git a/DesignPatterns.sln b/DesignPatterns.sln index 2f0933d..980ac49 100644 --- a/DesignPatterns.sln +++ b/DesignPatterns.sln @@ -4,6 +4,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DesignPatterns.Visitor", "B EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Behavioral", "Behavioral", "{7FF0E83F-EBEB-4103-BCD1-2F100E82FCD1}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DesignPatterns.Visitor.UnitTests", "Behavioral\DesignPatterns.Visitor.UnitTests\DesignPatterns.Visitor.UnitTests.csproj", "{02AA0F74-2EFE-4804-8938-A92542860F74}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -14,8 +16,13 @@ Global {DCE06EB6-BAB5-4573-AF67-128DBCCDB90C}.Debug|Any CPU.Build.0 = Debug|Any CPU {DCE06EB6-BAB5-4573-AF67-128DBCCDB90C}.Release|Any CPU.ActiveCfg = Release|Any CPU {DCE06EB6-BAB5-4573-AF67-128DBCCDB90C}.Release|Any CPU.Build.0 = Release|Any CPU + {02AA0F74-2EFE-4804-8938-A92542860F74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {02AA0F74-2EFE-4804-8938-A92542860F74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {02AA0F74-2EFE-4804-8938-A92542860F74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {02AA0F74-2EFE-4804-8938-A92542860F74}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {DCE06EB6-BAB5-4573-AF67-128DBCCDB90C} = {7FF0E83F-EBEB-4103-BCD1-2F100E82FCD1} + {02AA0F74-2EFE-4804-8938-A92542860F74} = {7FF0E83F-EBEB-4103-BCD1-2F100E82FCD1} EndGlobalSection EndGlobal