From bb1bfd4dc0d0ae8a0fc9030a30ca346c6f7c3579 Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Thu, 8 Nov 2012 10:38:47 +0000 Subject: [PATCH] Created unit tests for the --autocrlf option to init and clone. Signed-off-by: Pat Thoyts --- GitTfsTest/Commands/InitOptionsTest.cs | 57 ++++++++++++++++++++++++++ GitTfsTest/GitTfsTest.csproj | 3 +- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 GitTfsTest/Commands/InitOptionsTest.cs 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