Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move TfsApiBridge to the core project.

This will let me drop one of the test projects without dropping any tests.
  • Loading branch information...
commit f38e84db766cb78d2b684c97c632ff00f7bd94bb 1 parent ff364f8
@spraints spraints authored
View
3  GitTfs.Vs11/GitTfs.Vs11.csproj
@@ -62,9 +62,6 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
- <Compile Include="..\GitTfs.VsCommon\TfsApiBridge.cs">
- <Link>TfsApiBridge.cs</Link>
- </Compile>
<Compile Include="..\GitTfs.VsCommon\TfsHelper.Common.cs">
<Link>TfsHelper.Common.cs</Link>
</Compile>
View
3  GitTfs.Vs2008/GitTfs.Vs2008.csproj
@@ -110,9 +110,6 @@
<Compile Include="..\CommonAssemblyInfo.cs">
<Link>Properties\CommonAssemblyInfo.cs</Link>
</Compile>
- <Compile Include="..\GitTfs.VsCommon\TfsApiBridge.cs">
- <Link>TfsApiBridge.cs</Link>
- </Compile>
<Compile Include="..\GitTfs.VsCommon\TfsHelper.Common.cs">
<Link>TfsHelper.Common.cs</Link>
</Compile>
View
3  GitTfs.Vs2010/GitTfs.Vs2010.csproj
@@ -97,9 +97,6 @@
<Compile Include="..\CommonAssemblyInfo.cs">
<Link>Properties\CommonAssemblyInfo.cs</Link>
</Compile>
- <Compile Include="..\GitTfs.VsCommon\TfsApiBridge.cs">
- <Link>TfsApiBridge.cs</Link>
- </Compile>
<Compile Include="..\GitTfs.VsCommon\TfsHelper.Common.cs">
<Link>TfsHelper.Common.cs</Link>
</Compile>
View
0  GitTfs.VsCommon/TfsApiBridge.cs → GitTfs/Core/TfsInterop/TfsApiBridge.cs
File renamed without changes
View
1  GitTfs/GitTfs.csproj
@@ -146,6 +146,7 @@
<Compile Include="Core\TfsInterop\ICheckinNote.cs" />
<Compile Include="Core\TfsInterop\IVersionControlServer.cs" />
<Compile Include="Core\TfsInterop\IWorkItemCheckedInfo.cs" />
+ <Compile Include="Core\TfsInterop\TfsApiBridge.cs" />
<Compile Include="Core\TfsInterop\TfsChangeType.cs" />
<Compile Include="Core\TfsInterop\TfsCheckinEvaluationOptions.cs" />
<Compile Include="Core\TfsInterop\TfsExt.cs" />
View
128 GitTfsTest/Core/TfsApiBridgeTest.cs
@@ -0,0 +1,128 @@
+using Sep.Git.Tfs.Core.TfsInterop;
+using Sep.Git.Tfs.VsCommon;
+using StructureMap.AutoMocking;
+using Xunit;
+
+namespace GitTfsTest.Core
+{
+ public class TfsApiBridgeTest
+ {
+ private RhinoAutoMocker<TfsApiBridge> _mocks;
+
+ public TfsApiBridgeTest()
+ {
+ _mocks = new RhinoAutoMocker<TfsApiBridge>();
+ _mocks.MockObjectFactory();
+ }
+
+ [Fact]
+ public void ConvertsEnum()
+ {
+ Assert.Equal(OriginalEnum.Value2, _mocks.ClassUnderTest.Convert<OriginalEnum>(WrappedEnum.Value2));
+ }
+
+ [Fact]
+ public void WrapsAndUnwrapsObject()
+ {
+ var originalObject = new OriginalType();
+ var wrappedObject = _mocks.ClassUnderTest.Wrap<WrapperForOriginalType, OriginalType>(originalObject);
+ Assert.Equal(originalObject, _mocks.ClassUnderTest.Unwrap<OriginalType>(wrappedObject));
+ }
+
+ [Fact]
+ public void WrapsObjectWithBridge()
+ {
+ var originalObject = new OriginalType();
+ var wrappedObject = _mocks.ClassUnderTest.Wrap<WrapperForOriginalTypeWithBridge, OriginalType>(originalObject);
+ Assert.NotNull(wrappedObject.Bridge);
+ }
+
+ [Fact]
+ public void WrapsAndUnwrapsArray()
+ {
+ var originalObjects = new [] { new OriginalType() };
+ var wrappedObjects = _mocks.ClassUnderTest.Wrap<WrapperForOriginalType, OriginalType>(originalObjects);
+ Assert.Equal(1, wrappedObjects.Length);
+ Assert.Equal(originalObjects[0], _mocks.ClassUnderTest.Unwrap<OriginalType>(wrappedObjects)[0]);
+ }
+
+ [Fact]
+ public void WrapsNullAsNull()
+ {
+ OriginalType obj = null;
+ Assert.Null(_mocks.ClassUnderTest.Wrap<WrapperForOriginalType, OriginalType>(obj));
+ }
+
+ [Fact]
+ public void WrapsNullArrayAsNull()
+ {
+ OriginalType [] obj = null;
+ Assert.Null(_mocks.ClassUnderTest.Wrap<WrapperForOriginalType, OriginalType>(obj));
+ }
+
+ [Fact]
+ public void UnwrapsNullAsNull()
+ {
+ WrapperForOriginalType obj = null;
+ Assert.Null(_mocks.ClassUnderTest.Unwrap<OriginalType>(obj));
+ }
+
+ [Fact]
+ public void UnwrapsNullArrayAsNull()
+ {
+ WrapperForOriginalType[] obj = null;
+ Assert.Null(_mocks.ClassUnderTest.Unwrap<OriginalType>(obj));
+ }
+
+ public class OriginalType
+ {
+ public static int counter;
+ public static object lockObject = new object();
+ private readonly int _id;
+ public OriginalType()
+ {
+ lock (lockObject)
+ {
+ _id = ++counter;
+ }
+ }
+ public override bool Equals(object obj)
+ {
+ return obj is OriginalType && ((OriginalType) obj)._id == _id;
+ }
+ public override int GetHashCode()
+ {
+ return _id;
+ }
+ public override string ToString()
+ {
+ return "OriginalObject:" + _id;
+ }
+ }
+ interface IOriginalType {}
+ public class WrapperForOriginalType : WrapperFor<OriginalType>, IOriginalType
+ {
+ public WrapperForOriginalType(OriginalType o) : base(o) {}
+ }
+ public class WrapperForOriginalTypeWithBridge : WrapperFor<OriginalType>, IOriginalType
+ {
+ public WrapperForOriginalTypeWithBridge(OriginalType o, TfsApiBridge b) : base(o)
+ {
+ Bridge = b;
+ }
+ public TfsApiBridge Bridge { get; private set; }
+ }
+
+ public enum OriginalEnum
+ {
+ Value1,
+ Value2,
+ };
+
+ public enum WrappedEnum
+ {
+ Value1,
+ Value2,
+ };
+ }
+}
View
1  GitTfsTest/GitTfsTest.csproj
@@ -92,6 +92,7 @@
<Compile Include="Core\ExtTests.cs" />
<Compile Include="Core\GitChangeInfoTests.cs" />
<Compile Include="Core\ModeTests.cs" />
+ <Compile Include="Core\TfsApiBridgeTest.cs" />
<Compile Include="GitTfsRegexTests.cs" />
<Compile Include="Integration\CloneTests.cs" />
<Compile Include="Integration\IntegrationHelper.cs" />
Please sign in to comment.
Something went wrong with that request. Please try again.