Skip to content

Commit

Permalink
Adding a unit test project and some initial tests
Browse files Browse the repository at this point in the history
  • Loading branch information
haacked committed Mar 15, 2012
1 parent ae8b865 commit 04123ec
Show file tree
Hide file tree
Showing 26 changed files with 18,817 additions and 11 deletions.
29 changes: 29 additions & 0 deletions SeeGit.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,45 @@ Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SeeGitApp", "SeeGitApp\SeeGitApp.csproj", "{455C90CF-CB4E-41FB-8DB8-04AD1B104F64}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "UnitTests\UnitTests.csproj", "{AC22554C-AC27-42A3-91FA-16D49BBC0A4D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8B481ABB-96B1-4480-B8CA-EF43A860156E}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
LICENSE.txt = LICENSE.txt
README.md = README.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{455C90CF-CB4E-41FB-8DB8-04AD1B104F64}.Debug|Any CPU.ActiveCfg = Debug|x86
{455C90CF-CB4E-41FB-8DB8-04AD1B104F64}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{455C90CF-CB4E-41FB-8DB8-04AD1B104F64}.Debug|Mixed Platforms.Build.0 = Debug|x86
{455C90CF-CB4E-41FB-8DB8-04AD1B104F64}.Debug|x86.ActiveCfg = Debug|x86
{455C90CF-CB4E-41FB-8DB8-04AD1B104F64}.Debug|x86.Build.0 = Debug|x86
{455C90CF-CB4E-41FB-8DB8-04AD1B104F64}.Release|Any CPU.ActiveCfg = Release|x86
{455C90CF-CB4E-41FB-8DB8-04AD1B104F64}.Release|Mixed Platforms.ActiveCfg = Release|x86
{455C90CF-CB4E-41FB-8DB8-04AD1B104F64}.Release|Mixed Platforms.Build.0 = Release|x86
{455C90CF-CB4E-41FB-8DB8-04AD1B104F64}.Release|x86.ActiveCfg = Release|x86
{455C90CF-CB4E-41FB-8DB8-04AD1B104F64}.Release|x86.Build.0 = Release|x86
{AC22554C-AC27-42A3-91FA-16D49BBC0A4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AC22554C-AC27-42A3-91FA-16D49BBC0A4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AC22554C-AC27-42A3-91FA-16D49BBC0A4D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{AC22554C-AC27-42A3-91FA-16D49BBC0A4D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{AC22554C-AC27-42A3-91FA-16D49BBC0A4D}.Debug|x86.ActiveCfg = Debug|Any CPU
{AC22554C-AC27-42A3-91FA-16D49BBC0A4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AC22554C-AC27-42A3-91FA-16D49BBC0A4D}.Release|Any CPU.Build.0 = Release|Any CPU
{AC22554C-AC27-42A3-91FA-16D49BBC0A4D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{AC22554C-AC27-42A3-91FA-16D49BBC0A4D}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{AC22554C-AC27-42A3-91FA-16D49BBC0A4D}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
9 changes: 6 additions & 3 deletions SeeGitApp/Models/BranchCollection.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
using System.Collections.ObjectModel;
using System.Linq;

namespace SeeGit.Models
{
public class BranchCollection : ObservableCollection<BranchReference>
{
public void Merge(BranchReference branch)
{
if (Contains(branch))
var existing = Items.FirstOrDefault(b => b.Name == branch.Name);
if (existing != null)
{
branch.IsCurrent = branch.IsCurrent;
branch.IsRemote = branch.IsRemote;
existing.IsCurrent = branch.IsCurrent;
existing.IsHead = branch.IsHead;
existing.IsRemote = branch.IsRemote;
return;
}
Add(branch);
Expand Down
1 change: 0 additions & 1 deletion SeeGitApp/Models/GitObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace SeeGit
{
public abstract class GitObject<T> : INotifyPropertyChanged

{
public abstract override int GetHashCode();

Expand Down
7 changes: 0 additions & 7 deletions SeeGitApp/Properties/Settings.settings

This file was deleted.

34 changes: 34 additions & 0 deletions UnitTests/Models/BranchCollectionTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System.Linq;
using SeeGit.Models;
using Xunit;

namespace UnitTests
{
public class BranchCollectionTests
{
public class TheMergeMethod
{
[Fact]
public void AddsBranchToCollection()
{
var branches = new BranchCollection();

branches.Merge(new SeeGit.BranchReference {Name = "foo"});

Assert.Equal(1, branches.Count);
}

[Fact]
public void MergesBranchWithSameNameAsExistingGivingPrecedenceToNewerOne()
{
var branches = new BranchCollection();
branches.Merge(new SeeGit.BranchReference {Name = "foo", IsCurrent = false, IsHead = true, IsRemote = true});

branches.Merge(new SeeGit.BranchReference {Name = "foo", IsCurrent = true, IsRemote = true, IsHead = true});

Assert.Equal(1, branches.Count);
Assert.True(branches.First().IsCurrent);
}
}
}
}
36 changes: 36 additions & 0 deletions UnitTests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("UnitTests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UnitTests")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("b54694bc-56f3-4cc3-b0cb-8402b20a2bbf")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
69 changes: 69 additions & 0 deletions UnitTests/UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{AC22554C-AC27-42A3-91FA-16D49BBC0A4D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>UnitTests</RootNamespace>
<AssemblyName>UnitTests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Moq">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="xunit">
<HintPath>..\packages\xunit.1.9.0.1566\lib\xunit.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Models\BranchCollectionTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SeeGitApp\SeeGitApp.csproj">
<Project>{455C90CF-CB4E-41FB-8DB8-04AD1B104F64}</Project>
<Name>SeeGitApp</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
5 changes: 5 additions & 0 deletions UnitTests/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Moq" version="4.0.10827" />
<package id="xunit" version="1.9.0.1566" />
</packages>
39 changes: 39 additions & 0 deletions packages/Moq.4.0.10827/License.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Copyright (c) 2007. Clarius Consulting, Manas Technology Solutions, InSTEDD
http://code.google.com/p/moq/
All rights reserved.

Redistribution and use in source and binary forms,
with or without modification, are permitted provided
that the following conditions are met:

* Redistributions of source code must retain the
above copyright notice, this list of conditions and
the following disclaimer.

* Redistributions in binary form must reproduce
the above copyright notice, this list of conditions
and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of Clarius Consulting, Manas Technology Solutions or InSTEDD nor the
names of its contributors may be used to endorse
or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.

[This is the BSD license, see
http://www.opensource.org/licenses/bsd-license.php]
Binary file added packages/Moq.4.0.10827/Moq.4.0.10827.nupkg
Binary file not shown.
Binary file added packages/Moq.4.0.10827/Moq.chm
Binary file not shown.
Binary file added packages/Moq.4.0.10827/lib/NET35/Moq.dll
Binary file not shown.
Loading

0 comments on commit 04123ec

Please sign in to comment.