diff --git a/GraalGmapGenerator.sln b/GraalGmapGenerator.sln index 75a4a75..37f3dcd 100644 --- a/GraalGmapGenerator.sln +++ b/GraalGmapGenerator.sln @@ -1,9 +1,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27428.2043 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29403.142 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GraalGmapGenerator", "GraalGmapGenerator\GraalGmapGenerator.csproj", "{C7C953DE-6E2D-4876-8252-B85431CB85DC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GraalGmapGenerator", "GraalGmapGenerator\GraalGmapGenerator.csproj", "{C7C953DE-6E2D-4876-8252-B85431CB85DC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GraalGmapGeneratorTests", "GrralGmapGeneratorTests\GraalGmapGeneratorTests.csproj", "{2D85D1C0-AE56-4F27-9ABF-3070414D1B0D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,6 +17,10 @@ Global {C7C953DE-6E2D-4876-8252-B85431CB85DC}.Debug|Any CPU.Build.0 = Debug|Any CPU {C7C953DE-6E2D-4876-8252-B85431CB85DC}.Release|Any CPU.ActiveCfg = Release|Any CPU {C7C953DE-6E2D-4876-8252-B85431CB85DC}.Release|Any CPU.Build.0 = Release|Any CPU + {2D85D1C0-AE56-4F27-9ABF-3070414D1B0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2D85D1C0-AE56-4F27-9ABF-3070414D1B0D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2D85D1C0-AE56-4F27-9ABF-3070414D1B0D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2D85D1C0-AE56-4F27-9ABF-3070414D1B0D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/GraalGmapGenerator/GmapBuilder.cs b/GraalGmapGenerator/GmapBuilder.cs index e65b0cb..3eee5ed 100644 --- a/GraalGmapGenerator/GmapBuilder.cs +++ b/GraalGmapGenerator/GmapBuilder.cs @@ -22,15 +22,15 @@ return this; } - public GmapBuilder NoAutomapping() + public GmapBuilder NoAutomapping(bool value) { - _noAutomapping = true; + _noAutomapping = value; return this; } - public GmapBuilder LoadFullMap() + public GmapBuilder LoadFullMap(bool value) { - _loadFullMap = true; + _loadFullMap = value; return this; } diff --git a/GraalGmapGenerator/Program.cs b/GraalGmapGenerator/Program.cs index f7bc0eb..133c012 100644 --- a/GraalGmapGenerator/Program.cs +++ b/GraalGmapGenerator/Program.cs @@ -43,13 +43,13 @@ namespace GraalGmapGenerator Console.WriteLine("Load full map? (y/n)..."); if (Console.ReadLine() == "y") { - mapBuilder.LoadFullMap(); + mapBuilder.LoadFullMap(true); } Console.WriteLine("No automapping? (y/n)..."); if (Console.ReadLine() == "y") { - mapBuilder.NoAutomapping(); + mapBuilder.NoAutomapping(true); } Console.WriteLine("Generating gmap..."); diff --git a/GrralGmapGeneratorTests/GmapBuilderTests.cs b/GrralGmapGeneratorTests/GmapBuilderTests.cs new file mode 100644 index 0000000..e15d786 --- /dev/null +++ b/GrralGmapGeneratorTests/GmapBuilderTests.cs @@ -0,0 +1,62 @@ +using GraalGmapGenerator; +using NUnit.Framework; + +namespace GraalGmapGeneratorTests +{ + public class GmapBuilderTests + { + GmapBuilder gmapBuilder; + + [SetUp] + public void Setup() + { + gmapBuilder = new GmapBuilder(); + } + + [Test] + public void SetName_SetsTheName() + { + var expectedName = "My gmap test name"; + + gmapBuilder.SetName(expectedName); + + var gmap = gmapBuilder.Build(); + Assert.AreEqual(expectedName, gmap.Name); + } + + [Test] + public void SetDimensions_SetsTheDimensions() + { + var expectedWidth = 10; + var expectedHeight = 20; + + gmapBuilder.SetDimensions(expectedWidth, expectedHeight); + + var gmap = gmapBuilder.Build(); + Assert.AreEqual(expectedWidth, gmap.Width); + Assert.AreEqual(expectedHeight, gmap.Height); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void NoAutomapping_SetsNoAutomapping(bool expectedNoAutomappingValue) + { + gmapBuilder.NoAutomapping(expectedNoAutomappingValue); + + var gmap = gmapBuilder.Build(); + Assert.AreEqual(expectedNoAutomappingValue, gmap.NoAutomapping); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void loadFullMap_SetsLoadFullMap(bool expectedLoadFullMapValue) + { + gmapBuilder.LoadFullMap(expectedLoadFullMapValue); + + var gmap = gmapBuilder.Build(); + Assert.AreEqual(expectedLoadFullMapValue, gmap.LoadFullMap); + } + } +} diff --git a/GrralGmapGeneratorTests/GraalGmapGeneratorTests.csproj b/GrralGmapGeneratorTests/GraalGmapGeneratorTests.csproj new file mode 100644 index 0000000..ebd429b --- /dev/null +++ b/GrralGmapGeneratorTests/GraalGmapGeneratorTests.csproj @@ -0,0 +1,20 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <TargetFramework>netcoreapp3.0</TargetFramework> + + <IsPackable>false</IsPackable> + </PropertyGroup> + + <ItemGroup> + <PackageReference Include="Moq" Version="4.13.1" /> + <PackageReference Include="nunit" Version="3.12.0" /> + <PackageReference Include="NUnit3TestAdapter" Version="3.13.0" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" /> + </ItemGroup> + + <ItemGroup> + <ProjectReference Include="..\GraalGmapGenerator\GraalGmapGenerator.csproj" /> + </ItemGroup> + +</Project>