diff --git a/GitTfsTest/Commands/InitOptionsTest.cs b/GitTfsTest/Commands/InitOptionsTest.cs new file mode 100644 index 00000000..49319fda --- /dev/null +++ b/GitTfsTest/Commands/InitOptionsTest.cs @@ -0,0 +1,57 @@ +using System.IO; +using Sep.Git.Tfs.Commands; +using StructureMap.AutoMocking; +using NDesk.Options; +using Xunit; + +namespace Sep.Git.Tfs.Test.Commands +{ + public class InitOptionsTest + { + private RhinoAutoMocker mocks; + + public InitOptionsTest() + { + mocks = new RhinoAutoMocker(); + } + + [Fact] + public void AutoCrlfDefault() + { + Assert.Equal("false", mocks.ClassUnderTest.GitInitAutoCrlf); + } + + [Fact] + public void AutoCrlfProvideTrue() + { + string[] args = {"init", "--autocrlf=true", "http://example.com/tfs", "$/Junk"}; + mocks.ClassUnderTest.OptionSet.Parse(args); + Assert.Equal("true", mocks.ClassUnderTest.GitInitAutoCrlf); + } + + [Fact] + public void AutoCrlfProvideFalse() + { + string[] args = { "init", "--autocrlf=false", "http://example.com/tfs", "$/Junk" }; + mocks.ClassUnderTest.OptionSet.Parse(args); + Assert.Equal("false", mocks.ClassUnderTest.GitInitAutoCrlf); + } + + [Fact] + public void AutoCrlfProvideAuto() + { + string[] args = { "init", "--autocrlf=auto", "http://example.com/tfs", "$/Junk" }; + mocks.ClassUnderTest.OptionSet.Parse(args); + Assert.Equal("auto", mocks.ClassUnderTest.GitInitAutoCrlf); + } + + [Fact] + public void AutoCrlfProvideInvalidOption() + { + string[] args = { "init", "--autocrlf=windows", "http://example.com/tfs", "$/Junk" }; + Assert.Throws(() => mocks.ClassUnderTest.OptionSet.Parse(args)); + Assert.Equal("false", mocks.ClassUnderTest.GitInitAutoCrlf); + } + + } +} diff --git a/GitTfsTest/GitTfsTest.csproj b/GitTfsTest/GitTfsTest.csproj index 4737bac1..789457b2 100644 --- a/GitTfsTest/GitTfsTest.csproj +++ b/GitTfsTest/GitTfsTest.csproj @@ -85,6 +85,7 @@ + @@ -152,4 +153,4 @@ --> - + \ No newline at end of file