Skip to content
This repository was archived by the owner on Jun 27, 2019. It is now read-only.

Commit 75cecba

Browse files
Added first classes for dynamic repositories / contexts / unit tests
1 parent 846b3cb commit 75cecba

25 files changed

+905
-2
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright file="ArgumentParserFacts.cs" company="GitTools">
3+
// Copyright (c) 2014 - 2015 GitTools. All rights reserved.
4+
// </copyright>
5+
// --------------------------------------------------------------------------------------------------------------------
6+
7+
8+
namespace GitTools.Tests
9+
{
10+
using Catel.Test;
11+
using NUnit.Framework;
12+
13+
[TestFixture]
14+
public class ArgumentParserFacts
15+
{
16+
//[TestCase]
17+
//public void ThrowsExceptionForEmptyParameters()
18+
//{
19+
// ExceptionTester.CallMethodAndExpectException<GitLinkException>(() => ArgumentParser.ParseArguments(string.Empty));
20+
//}
21+
22+
//[TestCase]
23+
//public void CorrectlyParsesSolutionDirectory()
24+
//{
25+
// var context = ArgumentParser.ParseArguments("solutionDirectory -u http://github.com/CatenaLogic/GitLink");
26+
27+
// Assert.AreEqual("solutionDirectory", context.SolutionDirectory);
28+
//}
29+
30+
//[TestCase]
31+
//public void CorrectlyParsesLogFilePath()
32+
//{
33+
// var context = ArgumentParser.ParseArguments("solutionDirectory -l logFilePath");
34+
35+
// Assert.AreEqual("solutionDirectory", context.SolutionDirectory);
36+
// Assert.AreEqual("logFilePath", context.LogFile);
37+
//}
38+
39+
//[TestCase]
40+
//public void CorrectlyParsesHelp()
41+
//{
42+
// var context = ArgumentParser.ParseArguments("-h");
43+
44+
// Assert.IsTrue(context.IsHelp);
45+
//}
46+
47+
//[TestCase]
48+
//public void CorrectlyParsesSolutionFile()
49+
//{
50+
// var context = ArgumentParser.ParseArguments("solutionDirectory -u http://github.com/CatenaLogic/GitLink -f someSolution");
51+
52+
// Assert.AreEqual("someSolution", context.SolutionFile);
53+
//}
54+
55+
//[TestCase]
56+
//public void CorrectlyParsesUrlAndBranchName()
57+
//{
58+
// var context = ArgumentParser.ParseArguments("solutionDirectory -u http://github.com/CatenaLogic/GitLink -b somebranch");
59+
60+
// Assert.AreEqual("solutionDirectory", context.SolutionDirectory);
61+
// Assert.AreEqual("http://github.com/CatenaLogic/GitLink", context.TargetUrl);
62+
// Assert.AreEqual("somebranch", context.TargetBranch);
63+
//}
64+
65+
//[TestCase]
66+
//public void CorrectlyParsesUrlAndConfiguration()
67+
//{
68+
// var context = ArgumentParser.ParseArguments("solutionDirectory -u http://github.com/CatenaLogic/GitLink -c someConfiguration");
69+
70+
// Assert.AreEqual("solutionDirectory", context.SolutionDirectory);
71+
// Assert.AreEqual("http://github.com/CatenaLogic/GitLink", context.TargetUrl);
72+
// Assert.AreEqual("someConfiguration", context.ConfigurationName);
73+
//}
74+
75+
//[TestCase]
76+
//public void CorrectlyParsesUrlAndConfigurationAndPlatform()
77+
//{
78+
// var context = ArgumentParser.ParseArguments("solutionDirectory -u http://github.com/CatenaLogic/GitLink -c someConfiguration -p \"Any CPU\"");
79+
80+
// Assert.AreEqual("solutionDirectory", context.SolutionDirectory);
81+
// Assert.AreEqual("http://github.com/CatenaLogic/GitLink", context.TargetUrl);
82+
// Assert.AreEqual("someConfiguration", context.ConfigurationName);
83+
// Assert.AreEqual("Any CPU", context.PlatformName);
84+
//}
85+
86+
//[TestCase]
87+
//public void CorrectlyParsesUrlAndConfigurationWithDebug()
88+
//{
89+
// var context = ArgumentParser.ParseArguments("solutionDirectory -u http://github.com/CatenaLogic/GitLink -debug -c someConfiguration");
90+
91+
// Assert.AreEqual("solutionDirectory", context.SolutionDirectory);
92+
// Assert.AreEqual("http://github.com/CatenaLogic/GitLink", context.TargetUrl);
93+
// Assert.AreEqual("someConfiguration", context.ConfigurationName);
94+
// Assert.IsTrue(context.IsDebug);
95+
//}
96+
97+
//[TestCase]
98+
//public void CorrectlyParsesIgnoredProjects()
99+
//{
100+
// var context = ArgumentParser.ParseArguments("solutionDirectory -u http://github.com/CatenaLogic/GitLink -debug -c someConfiguration -ignore test1,test2");
101+
102+
// Assert.AreEqual("solutionDirectory", context.SolutionDirectory);
103+
// Assert.AreEqual("http://github.com/CatenaLogic/GitLink", context.TargetUrl);
104+
// Assert.AreEqual("someConfiguration", context.ConfigurationName);
105+
// Assert.IsTrue(context.IsDebug);
106+
107+
// Assert.AreEqual(2, context.IgnoredProjects.Count);
108+
// Assert.AreEqual("test1", context.IgnoredProjects[0]);
109+
// Assert.AreEqual("test2", context.IgnoredProjects[1]);
110+
//}
111+
112+
//[TestCase]
113+
//public void ThrowsExceptionForUnknownArgument()
114+
//{
115+
// ExceptionTester.CallMethodAndExpectException<GitLinkException>(() => ArgumentParser.ParseArguments("solutionDirectory -x logFilePath"));
116+
//}
117+
}
118+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright file="Context.cs" company="GitTools">
3+
// Copyright (c) 2014 - 2015 GitTools. All rights reserved.
4+
// </copyright>
5+
// --------------------------------------------------------------------------------------------------------------------
6+
7+
8+
namespace GitTools.Tests
9+
{
10+
public class Context : ContextBase
11+
{
12+
}
13+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright file="ContextFacts.cs" company="GitTools">
3+
// Copyright (c) 2014 - 2015 GitTools. All rights reserved.
4+
// </copyright>
5+
// --------------------------------------------------------------------------------------------------------------------
6+
7+
8+
namespace GitTools.Tests
9+
{
10+
using System;
11+
using Catel.Test;
12+
using NUnit.Framework;
13+
14+
public class ContextFacts
15+
{
16+
[TestFixture]
17+
public class TheDefaultValues
18+
{
19+
[TestCase]
20+
public void SetsRightDefaultValues()
21+
{
22+
var context = new Context();
23+
24+
//Assert.AreEqual("Release", context.ConfigurationName);
25+
Assert.IsFalse(context.IsHelp);
26+
}
27+
}
28+
29+
//[TestFixture]
30+
//public class TheValidateContextMethod
31+
//{
32+
// [TestCase]
33+
// public void ThrowsExceptionForMissingSolutionDirectory()
34+
// {
35+
// var context = new Context();
36+
37+
// ExceptionTester.CallMethodAndExpectException<GitLinkException>(() => context.ValidateContext());
38+
// }
39+
40+
// [TestCase]
41+
// public void ThrowsExceptionForMissingConfigurationName()
42+
// {
43+
// var context = new Context(new ProviderManager())
44+
// {
45+
// SolutionDirectory = @"c:\source\GitLink",
46+
// ConfigurationName = string.Empty
47+
// };
48+
49+
// ExceptionTester.CallMethodAndExpectException<GitLinkException>(() => context.ValidateContext());
50+
// }
51+
52+
// [TestCase]
53+
// public void ThrowsExceptionForMissingTargetUrl()
54+
// {
55+
// var context = new Context(new ProviderManager())
56+
// {
57+
// SolutionDirectory = @"c:\source\GitLink",
58+
// };
59+
60+
// ExceptionTester.CallMethodAndExpectException<GitLinkException>(() => context.ValidateContext());
61+
// }
62+
63+
// [TestCase]
64+
// public void SucceedsForValidContext()
65+
// {
66+
// var context = new Context(new ProviderManager())
67+
// {
68+
// SolutionDirectory = @"c:\source\GitLink",
69+
// TargetUrl = "https://github.com/CatenaLogic/GitLink",
70+
// };
71+
72+
// // should not throw
73+
// context.ValidateContext();
74+
// }
75+
76+
// [TestCase(@".", @"c:\")]
77+
// [TestCase(@"C:\MyDirectory\", @"C:\MyDirectory\")]
78+
// [TestCase(@"C:\MyDirectory\..", @"C:\")]
79+
// [TestCase(@"C:\MyDirectory\..\TestDirectory\", @"C:\TestDirectory\")]
80+
// public void ExpandsDirectoryIfRequired(string solutionDirectory, string expectedValue)
81+
// {
82+
// Environment.CurrentDirectory = @"c:\";
83+
84+
// var context = new Context(new ProviderManager());
85+
// context.TargetUrl = "https://github.com/CatenaLogic/GitLink.git";
86+
// context.SolutionDirectory = solutionDirectory;
87+
88+
// context.ValidateContext();
89+
90+
// Assert.AreEqual(expectedValue, context.SolutionDirectory);
91+
// }
92+
//}
93+
}
94+
}

src/GitTools.Core.Tests/GitTools.Core.Tests.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
<HintPath>..\..\lib\Catel.Fody.2.5.0\lib\portable-net4+sl4+wp7+win8+wpa81+MonoAndroid14+MonoTouch40\Catel.Fody.Attributes.dll</HintPath>
4444
<Private>True</Private>
4545
</Reference>
46+
<Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
47+
<HintPath>..\..\lib\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
48+
<Private>True</Private>
49+
</Reference>
4650
<Reference Include="System" />
4751
<Reference Include="System.Core" />
4852
<Reference Include="System.Xml.Linq" />
@@ -55,6 +59,10 @@
5559
<Compile Include="..\SolutionAssemblyInfo.cs">
5660
<Link>Properties\SolutionAssemblyInfo.cs</Link>
5761
</Compile>
62+
<Compile Include="ArgumentParserFacts.cs" />
63+
<Compile Include="ContextFacts.cs" />
64+
<Compile Include="Context\Context.cs" />
65+
<Compile Include="GlobalInitialization.cs" />
5866
<Compile Include="ModuleInitializer.cs" />
5967
<Compile Include="Properties\AssemblyInfo.cs" />
6068
</ItemGroup>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright file="GlobalInitialization.cs" company="GitTools">
3+
// Copyright (c) 2014 - 2015 GitTools. All rights reserved.
4+
// </copyright>
5+
// --------------------------------------------------------------------------------------------------------------------
6+
7+
8+
using Catel.Logging;
9+
using NUnit.Framework;
10+
11+
[SetUpFixture]
12+
public class GlobalInitialization
13+
{
14+
[SetUp]
15+
public static void SetUp()
16+
{
17+
#if DEBUG
18+
LogManager.AddDebugListener(true);
19+
#endif
20+
}
21+
}

src/GitTools.Core.Tests/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
<package id="Catel.Fody" version="2.5.0" targetFramework="net45" developmentDependency="true" />
55
<package id="Fody" version="1.28.3" targetFramework="net45" developmentDependency="true" />
66
<package id="ModuleInit.Fody" version="1.5.6.0" targetFramework="net45" developmentDependency="true" />
7+
<package id="NUnit" version="2.6.4" targetFramework="net45" />
78
</packages>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright file="ContextBase.cs" company="GitTools">
3+
// Copyright (c) 2014 - 2015 GitTools. All rights reserved.
4+
// </copyright>
5+
// --------------------------------------------------------------------------------------------------------------------
6+
7+
8+
namespace GitTools
9+
{
10+
public abstract class ContextBase : IContext
11+
{
12+
public ContextBase()
13+
{
14+
Repository = new RepositoryContext();
15+
}
16+
17+
public bool IsHelp { get; set; }
18+
19+
public IRepositoryContext Repository { get; set; }
20+
}
21+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright file="IAuthenticationContext.cs" company="GitTools">
3+
// Copyright (c) 2014 - 2015 GitTools. All rights reserved.
4+
// </copyright>
5+
// --------------------------------------------------------------------------------------------------------------------
6+
7+
8+
namespace GitTools
9+
{
10+
public interface IAuthenticationContext
11+
{
12+
string Username { get; set; }
13+
14+
string Password { get; set; }
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright file="IContext.cs" company="GitTools">
3+
// Copyright (c) 2014 - 2015 GitTools. All rights reserved.
4+
// </copyright>
5+
// --------------------------------------------------------------------------------------------------------------------
6+
7+
8+
namespace GitTools
9+
{
10+
public interface IContext
11+
{
12+
bool IsHelp { get; set; }
13+
14+
IRepositoryContext Repository { get; set; }
15+
}
16+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright file="IContext.cs" company="GitTools">
3+
// Copyright (c) 2014 - 2015 GitTools. All rights reserved.
4+
// </copyright>
5+
// --------------------------------------------------------------------------------------------------------------------
6+
7+
8+
namespace GitTools
9+
{
10+
public interface IRepositoryContext : IAuthenticationContext
11+
{
12+
string Directory { get; set; }
13+
14+
string Branch { get; set; }
15+
16+
string Url { get; set; }
17+
}
18+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright file="RepositoryContext.cs" company="GitTools">
3+
// Copyright (c) 2014 - 2015 GitTools. All rights reserved.
4+
// </copyright>
5+
// --------------------------------------------------------------------------------------------------------------------
6+
7+
8+
namespace GitTools
9+
{
10+
public class RepositoryContext : IRepositoryContext
11+
{
12+
public string Directory { get; set; }
13+
14+
public string Branch { get; set; }
15+
16+
public string Url { get; set; }
17+
18+
public string Username { get; set; }
19+
20+
public string Password { get; set; }
21+
}
22+
}

0 commit comments

Comments
 (0)