-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from johnmwright/typeTests
adding support for shims with void returns. Adding unit tests for a …
- Loading branch information
Showing
13 changed files
with
1,349 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
Fakes.Contrib/Fakes.Contrib.Tests.Classes/ClassUnderTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
|
||
namespace Fakes.Contrib.Tests.Classes | ||
{ | ||
|
||
public class ClassUnderTest | ||
{ | ||
public void TestMethod_ArrayOfLongs(IMethodsThatTakeArrays dependancy) | ||
{ | ||
dependancy.MethodTakesArray(new long[] { long.MinValue, 0, 1, 2, 3, long.MaxValue }); | ||
} | ||
|
||
public void TestMethod_LongParams(IMethodsThatTakeArrays dependancy) | ||
{ | ||
dependancy.MethodTakesParams(long.MinValue, 1, 2, 3, long.MaxValue); | ||
} | ||
|
||
|
||
public void TestMethod_ArrayOfLongs(IMethodsThatTakeArrays dependancy, long[] inputs) | ||
{ | ||
dependancy.MethodTakesArray(inputs); | ||
} | ||
|
||
public void TestMethod_ArrayOfInt(IMethodsThatTakeArrays dependancy) | ||
{ | ||
dependancy.MethodTakesArray(new int[] { int.MinValue, 0, 1, 2, 3, int.MaxValue }); | ||
} | ||
|
||
public void TestMethod_IntParams(IMethodsThatTakeArrays dependancy) | ||
{ | ||
dependancy.MethodTakesParams(int.MinValue, 1, 2, 3, int.MaxValue); | ||
} | ||
|
||
|
||
public void TestMethod_ArrayOfInt(IMethodsThatTakeArrays dependancy, int[] inputs) | ||
{ | ||
dependancy.MethodTakesArray(inputs); | ||
} | ||
|
||
public void TestMethod_ArrayOfString(IMethodsThatTakeArrays dependancy) | ||
{ | ||
dependancy.MethodTakesArray(new string[] { "", "foo", "bar", "baz", "bin" }); | ||
} | ||
|
||
public void TestMethod_StringParams(IMethodsThatTakeArrays dependancy) | ||
{ | ||
dependancy.MethodTakesParams("", "foo", "bar", "baz", "bin"); | ||
} | ||
|
||
|
||
public void TestMethod_ArrayOfString(IMethodsThatTakeArrays dependancy, string[] inputs) | ||
{ | ||
dependancy.MethodTakesArray(inputs); | ||
} | ||
|
||
public void TestMethod_ArrayOfObject(IMethodsThatTakeArrays dependancy) | ||
{ | ||
dependancy.MethodTakesArray<object>(new object[] { new object(), "bin", new ClassUnderTest() }); | ||
} | ||
|
||
public void TestMethod_ObjectParams(IMethodsThatTakeArrays dependancy) | ||
{ | ||
dependancy.MethodTakesParams<object>(new object(), "bin", new ClassUnderTest()); | ||
} | ||
|
||
|
||
public void TestMethod_ArrayOfObject(IMethodsThatTakeArrays dependancy, object[] inputs) | ||
{ | ||
dependancy.MethodTakesArray(inputs); | ||
} | ||
|
||
public void TestMethod_ArrayOfInterface(IMethodsThatTakeArrays dependancy) | ||
{ | ||
dependancy.MethodTakesArray(new IDisposable[] { new StreamReader(Stream.Null), new MemoryStream() }); | ||
} | ||
|
||
public void TestMethod_InterfaceParams(IMethodsThatTakeArrays dependancy) | ||
{ | ||
dependancy.MethodTakesParams<IDisposable>(new StreamReader(Stream.Null), new MemoryStream()); | ||
} | ||
|
||
|
||
public void TestMethod_ArrayOfInterface(IMethodsThatTakeArrays dependancy, IDisposable[] inputs) | ||
{ | ||
dependancy.MethodTakesArray(inputs); | ||
} | ||
|
||
public void TestMethod_ArrayOfGeneric(IMethodsThatTakeArrays dependancy) | ||
{ | ||
dependancy.MethodTakesArray(new List<int>[] { new List<int>() { 0, 1 }, new List<int>() { 3, 4 } }); | ||
} | ||
|
||
public void TestMethod_GenericParams(IMethodsThatTakeArrays dependancy) | ||
{ | ||
dependancy.MethodTakesParams(new List<int>() { 0, 1 }, new List<int>() { 3, 4 }); | ||
} | ||
|
||
|
||
public void TestMethod_ArrayOfGeneric(IMethodsThatTakeArrays dependancy, List<int>[] inputs) | ||
{ | ||
dependancy.MethodTakesArray(inputs); | ||
} | ||
|
||
public void TestMethod_ArrayOfDates(IMethodsThatTakeArrays dependancy) | ||
{ | ||
dependancy.MethodTakesArray(new DateTime[] { DateTime.MinValue, DateTime.MaxValue, DateTime.Now }); | ||
} | ||
|
||
public void TestMethod_DateParams(IMethodsThatTakeArrays dependancy) | ||
{ | ||
dependancy.MethodTakesParams(DateTime.MinValue, DateTime.MaxValue, DateTime.Now); | ||
} | ||
|
||
|
||
public void TestMethod_ArrayOfDates(IMethodsThatTakeArrays dependancy, DateTime[] inputs) | ||
{ | ||
dependancy.MethodTakesArray(inputs); | ||
} | ||
} | ||
|
||
|
||
} |
49 changes: 49 additions & 0 deletions
49
Fakes.Contrib/Fakes.Contrib.Tests.Classes/Fakes.Contrib.Tests.Classes.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{4B6BC67E-4782-4838-BA96-C6F7E56C73ED}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Fakes.Contrib.Tests.Classes</RootNamespace> | ||
<AssemblyName>Fakes.Contrib.Tests.Classes</AssemblyName> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<TargetFrameworkProfile /> | ||
</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="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.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="ClassUnderTest.cs" /> | ||
<Compile Include="MethodsThatTakeArrays.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
34 changes: 34 additions & 0 deletions
34
Fakes.Contrib/Fakes.Contrib.Tests.Classes/MethodsThatTakeArrays.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
namespace Fakes.Contrib.Tests.Classes | ||
{ | ||
public interface IMethodsThatTakeArrays | ||
{ | ||
void MethodTakesArray<T>(T[] inputs); | ||
void MethodTakesParams<T>(params T[] inputs); | ||
} | ||
|
||
public class MethodsThatTakeArrays : IMethodsThatTakeArrays | ||
{ | ||
public virtual void MethodTakesArray<T>(T[] inputs) | ||
{ | ||
} | ||
|
||
public virtual void MethodTakesParams<T>(params T[] inputs) | ||
{ | ||
} | ||
|
||
} | ||
|
||
public class NonVirtualMethodsThatTakeArrays : IMethodsThatTakeArrays | ||
{ | ||
public void MethodTakesArray<T>(T[] inputs) | ||
{ | ||
} | ||
|
||
public void MethodTakesParams<T>(params T[] inputs) | ||
{ | ||
} | ||
|
||
} | ||
|
||
|
||
} |
36 changes: 36 additions & 0 deletions
36
Fakes.Contrib/Fakes.Contrib.Tests.Classes/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("Fakes.Contrib.Tests.Classes")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("Fakes.Contrib.Tests.Classes")] | ||
[assembly: AssemblyCopyright("Copyright © 2018")] | ||
[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("4b6bc67e-4782-4838-ba96-c6f7e56c73ed")] | ||
|
||
// 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.*")] | ||
[assembly: AssemblyFileVersion("1.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+276 Bytes
Fakes.Contrib/Fakes.Contrib.Tests/Fakes/Fakes.Contrib.Tests.Classes.fakes
Binary file not shown.
Oops, something went wrong.