Created unit tests for the --autocrlf option to init and clone.

Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
This commit is contained in:
Pat Thoyts
2012-11-08 10:38:47 +00:00
parent 7cab876287
commit bb1bfd4dc0
2 changed files with 59 additions and 1 deletions
+57
View File
@@ -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<InitOptions> mocks;
public InitOptionsTest()
{
mocks = new RhinoAutoMocker<InitOptions>();
}
[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<OptionException>(() => mocks.ClassUnderTest.OptionSet.Parse(args));
Assert.Equal("false", mocks.ClassUnderTest.GitInitAutoCrlf);
}
}
}
+2 -1
View File
@@ -85,6 +85,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Commands\InitOptionsTest.cs" />
<Compile Include="FactExceptOnUnix.cs" />
<Compile Include="Commands\HelpTest.cs" />
<Compile Include="Commands\ShelveTest.cs" />
@@ -152,4 +153,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>