├── .gitignore
├── Build
├── Build.ps1
├── Common.ps1
├── Package.ps1
├── Smocks.nuspec
└── nuget.exe
├── LICENSE.md
├── README.md
└── Source
├── Settings.StyleCop
├── Smocks.Dummy
├── Properties
│ └── AssemblyInfo.cs
├── Smocks.Dummy.Net40.csproj
├── Smocks.Dummy.Net45.csproj
└── StaticClass.cs
├── Smocks.Net40.sln
├── Smocks.Net45.sln
├── Smocks.Tests.NUnit3
├── Issues
│ └── IssueNineteenTests.cs
├── Properties
│ └── AssemblyInfo.cs
├── Smocks.Tests.NUnit3.Net40.csproj
├── Smocks.Tests.NUnit3.Net45.csproj
└── packages.config
├── Smocks.Tests
├── AppDomains
│ ├── AppDomainContextTests.cs
│ ├── AssemblyLoaderFactoryTests.cs
│ ├── AssemblyLoaderTests.cs
│ ├── AssemblyResolverTests.cs
│ ├── CecilAssemblyResolverTests.cs
│ ├── EnumerableReturnValueTransformerTests.cs
│ ├── GenericEnumerableReturnValueTransformerTests.cs
│ ├── LoadedAssemblyFinderTests.cs
│ └── SerializableLambdaTests.cs
├── ArgumentMatchingTests.cs
├── CallbackExceptionTests.cs
├── CallbackExceptionTests.tt
├── CallbackTests.Generated.cs
├── CallbackTests.Generated.tt
├── CallbackTests.cs
├── EventsTests.cs
├── FuncTests.cs
├── IL
│ ├── ArgumentGeneratorTests.cs
│ ├── CompiledDynamicMethodTests.cs
│ ├── Dependencies
│ │ ├── DependencyGraphBuilderTests.cs
│ │ ├── DependencyGraphNodeTests.cs
│ │ └── DependencyGraphTests.cs
│ ├── Filters
│ │ ├── AllowAllModuleFilterTests.cs
│ │ └── DirectReferencesModuleFilterTests.cs
│ ├── ILGeneratorInstructionVisitorTests.cs
│ ├── ILGeneratorWrapperTests.cs
│ ├── InstructionExtensionsTests.cs
│ ├── InstructionHelperTests.cs
│ ├── ParameterDeducerTests.cs
│ ├── ParameterTests.cs
│ ├── Resolvers
│ │ ├── AssemblyTypeContainerTests.cs
│ │ └── FieldResolverTests.cs
│ └── SetupExtractorTests.cs
├── Injection
│ ├── ServiceCreatorTests.cs
│ ├── ServiceLocatorContainerTests.cs
│ └── ServiceLocatorTests.cs
├── Issues
│ ├── IssueEightTests.cs
│ ├── IssueElevenTests.cs
│ ├── IssueTwelveTests.cs
│ └── IssueTwentySixTests.cs
├── Logging
│ └── LoggerExtensionsTests.cs
├── MethodTests.cs
├── OutParameterTests.cs
├── Properties
│ └── AssemblyInfo.cs
├── RefParameterTests.cs
├── ReturnsCallbackTests.cs
├── Serialization
│ └── SerializerTests.cs
├── Settings.StyleCop
├── Setups
│ ├── ArgumentMatcherTests.cs
│ ├── GenericSetupTests.cs
│ ├── InvocationTrackerTests.cs
│ ├── RewriteTargetMatcherTests.cs
│ ├── SetupManagerTests.cs
│ ├── SetupMatcherTests.cs
│ ├── SetupTargetCollectionTests.cs
│ ├── SetupTargetTests.cs
│ ├── SetupTests.cs
│ └── TargetMatcherTests.cs
├── Smocks.Tests.Net40.csproj
├── Smocks.Tests.Net45.csproj
├── TargetMatchingTests.cs
├── TestUtility
│ ├── AppDomainUtility.cs
│ ├── AssemblyUtility.cs
│ ├── CecilUtility.cs
│ ├── ReflectionUtility.cs
│ ├── TestDataFactory.cs
│ └── TestFunctions.cs
├── ThrowsTests.cs
├── Utility
│ ├── ArgumentCheckerTests.cs
│ ├── DiscovererTests.cs
│ ├── ImmutableListTests.cs
│ └── MethodCallInfoTests.cs
├── VerifiableTests.cs
└── packages.config
├── Smocks.licenseheader
├── Smocks.snk
├── Smocks
├── .gitignore
├── AppDomains
│ ├── AppDomainContext.cs
│ ├── AssemblyLoader.cs
│ ├── AssemblyLoaderFactory.cs
│ ├── AssemblyResolver.cs
│ ├── CecilAssemblyResolver.cs
│ ├── EnumerableReturnValueTransformer.cs
│ ├── GenericEnumerableReturnValueTransformer.cs
│ ├── IAppDomainContext.cs
│ ├── IAssemblyLoader.cs
│ ├── IAssemblyLoaderFactory.cs
│ ├── ILoadedAssemblyFinder.cs
│ ├── IReturnValueTransformer.cs
│ ├── ISerializableLambdaFilter.cs
│ ├── InvocationResult.cs
│ ├── LoadedAssemblyFinder.cs
│ ├── SerializableLambda.cs
│ └── SerializableLambdaInvoker.cs
├── Configuration.cs
├── Exceptions
│ ├── SetupExtractionException.cs
│ └── VerificationException.cs
├── IL
│ ├── ArgumentGenerator.cs
│ ├── AssemblyRewriter.cs
│ ├── CompiledDynamicMethod.cs
│ ├── Dependencies
│ │ ├── DependencyGraph.cs
│ │ ├── DependencyGraphBuilder.cs
│ │ ├── DependencyGraphNode.cs
│ │ ├── IDependencyGraph.cs
│ │ ├── IDependencyGraphBuilder.cs
│ │ └── IDependencyNodeContainer.cs
│ ├── DisassembleResult.cs
│ ├── DynamicMethodCompiler.cs
│ ├── EventAccessorExtractor.cs
│ ├── EventRewriteTarget.cs
│ ├── EventTargetExtractor.cs
│ ├── ExpressionDecompiler.cs
│ ├── Filters
│ │ ├── AllowAllModuleFilter.cs
│ │ ├── DirectReferencesModuleFilter.cs
│ │ ├── IModuleFilter.cs
│ │ ├── IModuleFilterFactory.cs
│ │ └── ModuleFilterFactory.cs
│ ├── FixedPdbReaderProvider.cs
│ ├── IArgumentGenerator.cs
│ ├── IAssemblyPostProcessor.cs
│ ├── IAssemblyRewriter.cs
│ ├── ICompiledMethod.cs
│ ├── IEventAccessorExtractor.cs
│ ├── IEventTargetExtractor.cs
│ ├── IExpressionDecompiler.cs
│ ├── IILGenerator.cs
│ ├── IInstructionHelper.cs
│ ├── IInstructionsCompiler.cs
│ ├── ILGeneratorInstructionVisitor.cs
│ ├── ILGeneratorWrapper.cs
│ ├── IMethodDisassembler.cs
│ ├── IMethodImporter.cs
│ ├── IMethodRewriter.cs
│ ├── IOpCodeMapper.cs
│ ├── IParameterDeducer.cs
│ ├── ISetupExtractor.cs
│ ├── InstructionExtensions.cs
│ ├── InstructionHelper.cs
│ ├── MethodDisassembler.cs
│ ├── MethodRewriter.cs
│ ├── ModuleDefinitionMethodImporter.cs
│ ├── ModuleReferenceComparer.cs
│ ├── OpCodeMapper.cs
│ ├── Parameter.cs
│ ├── ParameterDeducer.cs
│ ├── PostProcessors
│ │ ├── AssemblyAttributesFilter.cs
│ │ └── ModuleMvidPostProcessor.cs
│ ├── Resolvers
│ │ ├── AssemblyTypeContainer.cs
│ │ ├── FieldResolver.cs
│ │ ├── GenericBindingContext.cs
│ │ ├── IFieldResolver.cs
│ │ ├── IMethodResolver.cs
│ │ ├── IModuleResolver.cs
│ │ ├── ITypeContainer.cs
│ │ ├── ITypeResolver.cs
│ │ ├── MethodResolver.cs
│ │ ├── ModuleResolver.cs
│ │ └── TypeResolver.cs
│ ├── RewriteContext.cs
│ ├── SetupExtractor.cs
│ ├── VariableOperation.cs
│ ├── VariableUsage.cs
│ └── Visitors
│ │ ├── IInstructionVisitor.cs
│ │ ├── InstructionVisitorBase.cs
│ │ ├── NumberPoppedVisitor.cs
│ │ └── NumberPushedVisitor.cs
├── ISmocksContext.cs
├── Injection
│ ├── DefaultServiceLocatorSetup.cs
│ ├── IServiceCreator.cs
│ ├── IServiceLocator.cs
│ ├── IServiceLocatorContainer.cs
│ ├── IServiceLocatorSetup.cs
│ ├── ServiceCreator.cs
│ ├── ServiceLocator.cs
│ └── ServiceLocatorContainer.cs
├── Logging
│ ├── LogLevel.cs
│ ├── Logger.cs
│ └── LoggerExtensions.cs
├── Matching
│ └── It.cs
├── Properties
│ └── AssemblyInfo.cs
├── Scope.cs
├── Serialization
│ ├── ISerializer.cs
│ └── Serializer.cs
├── Setups
│ ├── ArgumentMatcher.cs
│ ├── EventAccessorPair.cs
│ ├── EventInterceptor.cs
│ ├── EventSurrogate.cs
│ ├── Fluent
│ │ ├── ICallback.Generated.cs
│ │ ├── ICallback.Generated.tt
│ │ ├── ICallback.Generic.Generated.cs
│ │ ├── ICallback.Generic.Generated.tt
│ │ ├── ICallback.Generic.cs
│ │ ├── ICallback.cs
│ │ ├── IReturns.Generated.cs
│ │ ├── IReturns.Generated.tt
│ │ ├── IReturns.cs
│ │ ├── IThrows.cs
│ │ └── IVerifiable.cs
│ ├── IArgumentMatcher.cs
│ ├── IInternalSetup.Generic.cs
│ ├── IInternalSetup.cs
│ ├── IInternalSetupBase.cs
│ ├── IInvocationTracker.cs
│ ├── IItIsMatcher.cs
│ ├── IRewriteTarget.cs
│ ├── IRewriteTargetCollection.cs
│ ├── IRewriteTargetMatcher.cs
│ ├── ISetup.Generic.cs
│ ├── ISetup.cs
│ ├── ISetupManager.cs
│ ├── ISetupMatcher.cs
│ ├── ITargetMatcher.cs
│ ├── Interceptor.cs
│ ├── InterceptorResult.Generic.cs
│ ├── InterceptorResult.cs
│ ├── InvocationTracker.cs
│ ├── ItIsMatcher.cs
│ ├── RewriteTargetCollection.cs
│ ├── RewriteTargetMatcher.cs
│ ├── Setup.Generated.cs
│ ├── Setup.Generated.tt
│ ├── Setup.Generic.Generated.cs
│ ├── Setup.Generic.Generated.tt
│ ├── Setup.Generic.cs
│ ├── Setup.cs
│ ├── SetupBase.cs
│ ├── SetupManager.cs
│ ├── SetupMatcher.cs
│ ├── SetupTarget.cs
│ └── TargetMatcher.cs
├── Smock.cs
├── Smock.tt
├── Smock1.cs
├── Smocks.Net40.csproj
├── Smocks.Net45.csproj
├── SmocksContext.cs
├── Utility
│ ├── ArgumentChecker.cs
│ ├── Discoverer.cs
│ ├── ExpressionCompiler.cs
│ ├── ExpressionHelper.cs
│ ├── IExpressionCompiler.cs
│ ├── IExpressionHelper.cs
│ ├── ImmutableList.cs
│ ├── MethodCallInfo.cs
│ └── Unit.cs
└── packages.config
└── SolutionInfo.cs
/Build/Build.ps1:
--------------------------------------------------------------------------------
1 | # Credits to Json.NET for parts of this script.
2 | param(
3 | [string]$configuration="Debug"
4 | )
5 |
6 | $scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
7 | $baseDir = resolve-path "$scriptPath\.."
8 | $buildDir = "$baseDir\Build"
9 | $sourceDir = "$baseDir\Source"
10 | $targets = "Clean", "Build"
11 | $targetsOption = "/t:" + [string]::Join(",", $targets)
12 |
13 | . $buildDir\Common.ps1
14 |
15 | $msbuild = (Get-Command msbuild.exe -errorAction SilentlyContinue | Select -Property Definition).Definition
16 |
17 | if (-Not $msbuild) {
18 | Write-Host "MSbuild not found!"
19 | return
20 | }
21 |
22 | # Manual cleaning, since the "clean" target does not seem to delete contents of the 'obj' folder generated
23 | # by the solutions for other framework versions.
24 | Write-Host "Cleaning solution..."
25 | Get-ChildItem -include "obj","bin" -recurse $sourceDir | ?{ $_.PSIsContainer } | foreach ($_) {Remove-Item -Recurse -Force -ErrorVariable capturedErrors -ErrorAction SilentlyContinue $_.fullname}
26 |
27 | foreach ($build in Get-Builds)
28 | {
29 | $name = $build.Name
30 |
31 | Write-Host
32 | Write-Host "Restoring"
33 | [Environment]::SetEnvironmentVariable("EnableNuGetPackageRestore", "true", "Process")
34 | & $buildDir\NuGet.exe update -self
35 | & $buildDir\NuGet.exe restore "$sourceDir\$name.sln" | Out-Default
36 |
37 | & $msbuild "$sourceDir\$name.sln" "/property:Configuration=$configuration" $targetsOption
38 | }
--------------------------------------------------------------------------------
/Build/Common.ps1:
--------------------------------------------------------------------------------
1 | function Get-Builds
2 | {
3 | $builds = @(
4 | @{Name = "Smocks.Net40"; FinalDir="Net40"; NuGetDir = "net40"; },
5 | @{Name = "Smocks.Net45"; FinalDir="Net45"; NuGetDir = "net45"; }
6 | )
7 |
8 | return $builds
9 | }
--------------------------------------------------------------------------------
/Build/Smocks.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Smocks
5 | 1.0.0.0
6 | Smocks
7 | Tom van der Kleij
8 | https://github.com/vanderkleij/Smocks/blob/master/LICENSE.md
9 | https://github.com/vanderkleij/Smocks
10 | Copyright 2015 Tom van der Kleij
11 | false
12 | Smocks is a library for mocking the normally unmockable. It can mock static and non-virtual methods and properties, amongst others.
13 | Mock Mocking Static Moq Fakes Moles Unit Testing Smock Smocks
14 |
15 |
--------------------------------------------------------------------------------
/Build/nuget.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vanderkleij/Smocks/58ee0f4454c3c421288537f63fa89d24273b01b3/Build/nuget.exe
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Tom van der Kleij
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/Source/Smocks.Dummy/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | //// The MIT License (MIT)
3 | ////
4 | //// Copyright (c) 2015 Tom van der Kleij
5 | ////
6 | //// Permission is hereby granted, free of charge, to any person obtaining a copy of
7 | //// this software and associated documentation files (the "Software"), to deal in
8 | //// the Software without restriction, including without limitation the rights to
9 | //// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10 | //// the Software, and to permit persons to whom the Software is furnished to do so,
11 | //// subject to the following conditions:
12 | ////
13 | //// The above copyright notice and this permission notice shall be included in all
14 | //// copies or substantial portions of the Software.
15 | ////
16 | //// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | //// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 | //// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 | //// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 | //// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | //// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | #endregion License
23 |
24 | using System.Reflection;
25 | using System.Runtime.InteropServices;
26 |
27 | // General Information about an assembly is controlled through the following
28 | // set of attributes. Change these attribute values to modify the information
29 | // associated with an assembly.
30 | [assembly: AssemblyTitle("Smocks.Dummy")]
31 | [assembly: AssemblyProduct("Smocks.Dummy")]
32 |
33 | // Setting ComVisible to false makes the types in this assembly not visible
34 | // to COM components. If you need to access a type in this assembly from
35 | // COM, set the ComVisible attribute to true on that type.
36 | [assembly: ComVisible(false)]
37 |
38 | // The following GUID is for the ID of the typelib if this project is exposed to COM
39 | [assembly: Guid("4141096e-9f63-4010-9abd-1cdaf158437a")]
--------------------------------------------------------------------------------
/Source/Smocks.Dummy/StaticClass.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | //// The MIT License (MIT)
3 | ////
4 | //// Copyright (c) 2015 Tom van der Kleij
5 | ////
6 | //// Permission is hereby granted, free of charge, to any person obtaining a copy of
7 | //// this software and associated documentation files (the "Software"), to deal in
8 | //// the Software without restriction, including without limitation the rights to
9 | //// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10 | //// the Software, and to permit persons to whom the Software is furnished to do so,
11 | //// subject to the following conditions:
12 | ////
13 | //// The above copyright notice and this permission notice shall be included in all
14 | //// copies or substantial portions of the Software.
15 | ////
16 | //// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | //// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 | //// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 | //// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 | //// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | //// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | #endregion License
23 |
24 | using System;
25 |
26 | namespace Smocks.Dummy
27 | {
28 | ///
29 | /// A dummy static class used for testing.
30 | ///
31 | public static class StaticClass
32 | {
33 | ///
34 | /// Tests the date time.
35 | ///
36 | /// The current time.
37 | public static DateTime TestDateTime()
38 | {
39 | return DateTime.Now;
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/Source/Smocks.Net40.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Smocks.Net40", "Smocks\Smocks.Net40.csproj", "{B62B3313-CE1E-40BA-8E58-23FC6CE89ACF}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Smocks.Tests.Net40", "Smocks.Tests\Smocks.Tests.Net40.csproj", "{7E8E2112-B2F7-49A6-A628-5BECEC0C919F}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Smocks.Dummy.Net40", "Smocks.Dummy\Smocks.Dummy.Net40.csproj", "{89B26A82-4B5B-4A16-A8BB-277AD4F0DBF9}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Smocks.Tests.NUnit3.Net40", "Smocks.Tests.NUnit3\Smocks.Tests.NUnit3.Net40.csproj", "{E48875E6-6FE9-453C-A6DD-E5DCB64FBBA2}"
13 | EndProject
14 | Global
15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
16 | Debug|Any CPU = Debug|Any CPU
17 | Release|Any CPU = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
20 | {B62B3313-CE1E-40BA-8E58-23FC6CE89ACF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {B62B3313-CE1E-40BA-8E58-23FC6CE89ACF}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {B62B3313-CE1E-40BA-8E58-23FC6CE89ACF}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {B62B3313-CE1E-40BA-8E58-23FC6CE89ACF}.Release|Any CPU.Build.0 = Release|Any CPU
24 | {7E8E2112-B2F7-49A6-A628-5BECEC0C919F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25 | {7E8E2112-B2F7-49A6-A628-5BECEC0C919F}.Debug|Any CPU.Build.0 = Debug|Any CPU
26 | {7E8E2112-B2F7-49A6-A628-5BECEC0C919F}.Release|Any CPU.ActiveCfg = Release|Any CPU
27 | {7E8E2112-B2F7-49A6-A628-5BECEC0C919F}.Release|Any CPU.Build.0 = Release|Any CPU
28 | {89B26A82-4B5B-4A16-A8BB-277AD4F0DBF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29 | {89B26A82-4B5B-4A16-A8BB-277AD4F0DBF9}.Debug|Any CPU.Build.0 = Debug|Any CPU
30 | {89B26A82-4B5B-4A16-A8BB-277AD4F0DBF9}.Release|Any CPU.ActiveCfg = Release|Any CPU
31 | {89B26A82-4B5B-4A16-A8BB-277AD4F0DBF9}.Release|Any CPU.Build.0 = Release|Any CPU
32 | {E48875E6-6FE9-453C-A6DD-E5DCB64FBBA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33 | {E48875E6-6FE9-453C-A6DD-E5DCB64FBBA2}.Debug|Any CPU.Build.0 = Debug|Any CPU
34 | {E48875E6-6FE9-453C-A6DD-E5DCB64FBBA2}.Release|Any CPU.ActiveCfg = Release|Any CPU
35 | {E48875E6-6FE9-453C-A6DD-E5DCB64FBBA2}.Release|Any CPU.Build.0 = Release|Any CPU
36 | EndGlobalSection
37 | GlobalSection(SolutionProperties) = preSolution
38 | HideSolutionNode = FALSE
39 | EndGlobalSection
40 | EndGlobal
41 |
--------------------------------------------------------------------------------
/Source/Smocks.Tests.NUnit3/Issues/IssueNineteenTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using NUnit.Framework;
3 |
4 | namespace Smocks.Tests.NUnit3.Issues
5 | {
6 | [TestFixture]
7 | public class IssueNineteenTests
8 | {
9 | [TestCase(Description = "The issue was that Smocks was not compatible with NUnit3. This test is an NUnit 3 test that does a basic Smocks operation. This used to fail before Smocks supported NUnit3.")]
10 | public void Issue19()
11 | {
12 | Smock.Run(context =>
13 | {
14 | context.Setup(() => DateTime.Now).Returns(new DateTime(2000, 1, 1));
15 |
16 | Assert.AreEqual(2000, DateTime.Now.Year);
17 | });
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/Source/Smocks.Tests.NUnit3/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 | [assembly: AssemblyTitle("Smocks.Tests.NUnit3")]
8 | [assembly: AssemblyProduct("Smocks.Tests.NUnit3")]
9 |
10 | // Setting ComVisible to false makes the types in this assembly not visible
11 | // to COM components. If you need to access a type in this assembly from
12 | // COM, set the ComVisible attribute to true on that type.
13 | [assembly: ComVisible(false)]
14 |
15 | // The following GUID is for the ID of the typelib if this project is exposed to COM
16 | [assembly: Guid("e48875e6-6fe9-453c-a6dd-e5dcb64fbba2")]
--------------------------------------------------------------------------------
/Source/Smocks.Tests.NUnit3/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Source/Smocks.Tests/AppDomains/CecilAssemblyResolverTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using NUnit.Framework;
3 | using Smocks.AppDomains;
4 |
5 | namespace Smocks.Tests.AppDomains
6 | {
7 | [TestFixture]
8 | public class CecilAssemblyResolverTests
9 | {
10 | [TestCase]
11 | public void Constructor_ConfigurationNull_ThrowsArgumentNullException()
12 | {
13 | var exception = Assert.Throws(() => new CecilAssemblyResolver(default(Configuration)));
14 | Assert.AreEqual("configuration", exception.ParamName);
15 | }
16 |
17 | [TestCase]
18 | public void Constructor_ConfigurationWithSearchDirectories_AddsSearchDirectories()
19 | {
20 | const string searchPath = @"c:\my\search\path";
21 |
22 | var configuration = new Configuration
23 | {
24 | AssemblySearchDirectories = new[] { searchPath }
25 | };
26 |
27 | var subject = new CecilAssemblyResolver(configuration);
28 |
29 | Assert.Contains(searchPath, subject.GetSearchDirectories());
30 | }
31 |
32 | [TestCase]
33 | public void Constructor_ConfigurationWithSearchDirectoriesNull_DoesntThrow()
34 | {
35 | var configuration = new Configuration
36 | {
37 | AssemblySearchDirectories = null
38 | };
39 |
40 | Assert.DoesNotThrow(() => new CecilAssemblyResolver(configuration));
41 | }
42 |
43 | [TestCase]
44 | public void Constructor_WithConfiguration_AddsAppDomainBaseDirectoryAsSearchPath()
45 | {
46 | var subject = new CecilAssemblyResolver(new Configuration());
47 | Assert.Contains(AppDomain.CurrentDomain.BaseDirectory, subject.GetSearchDirectories());
48 | }
49 |
50 | [TestCase]
51 | public void Constructor_WithOutConfiguration_AddsAppDomainBaseDirectoryAsSearchPath()
52 | {
53 | var subject = new CecilAssemblyResolver();
54 | Assert.Contains(AppDomain.CurrentDomain.BaseDirectory, subject.GetSearchDirectories());
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/Source/Smocks.Tests/AppDomains/LoadedAssemblyFinderTests.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | //// The MIT License (MIT)
3 | ////
4 | //// Copyright (c) 2015 Tom van der Kleij
5 | ////
6 | //// Permission is hereby granted, free of charge, to any person obtaining a copy of
7 | //// this software and associated documentation files (the "Software"), to deal in
8 | //// the Software without restriction, including without limitation the rights to
9 | //// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10 | //// the Software, and to permit persons to whom the Software is furnished to do so,
11 | //// subject to the following conditions:
12 | ////
13 | //// The above copyright notice and this permission notice shall be included in all
14 | //// copies or substantial portions of the Software.
15 | ////
16 | //// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | //// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 | //// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 | //// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 | //// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | //// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | #endregion
23 |
24 | using System;
25 | using System.Diagnostics.CodeAnalysis;
26 | using System.Reflection;
27 | using NUnit.Framework;
28 | using Smocks.AppDomains;
29 |
30 | namespace Smocks.Tests.AppDomains
31 | {
32 | [ExcludeFromCodeCoverage]
33 | [TestFixture]
34 | public class LoadedAssemblyFinderTests
35 | {
36 | [TestCase]
37 | public void Find_LoadedAssembly_ReturnsAssembly()
38 | {
39 | var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
40 | var assembly = loadedAssemblies[0];
41 |
42 | var subject = new LoadedAssemblyFinder();
43 | var result = subject.Find(assembly.GetName());
44 |
45 | Assert.AreEqual(assembly, result);
46 | }
47 |
48 | [TestCase]
49 | public void Find_NonLoadedAssembly_ReturnsNull()
50 | {
51 | var subject = new LoadedAssemblyFinder();
52 | var result = subject.Find(new AssemblyName(Guid.NewGuid().ToString()));
53 |
54 | Assert.AreEqual(null, result);
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/Source/Smocks.Tests/IL/CompiledDynamicMethodTests.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | //// The MIT License (MIT)
3 | ////
4 | //// Copyright (c) 2015 Tom van der Kleij
5 | ////
6 | //// Permission is hereby granted, free of charge, to any person obtaining a copy of
7 | //// this software and associated documentation files (the "Software"), to deal in
8 | //// the Software without restriction, including without limitation the rights to
9 | //// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10 | //// the Software, and to permit persons to whom the Software is furnished to do so,
11 | //// subject to the following conditions:
12 | ////
13 | //// The above copyright notice and this permission notice shall be included in all
14 | //// copies or substantial portions of the Software.
15 | ////
16 | //// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | //// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 | //// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 | //// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 | //// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | //// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | #endregion
23 |
24 | using System;
25 | using System.Diagnostics.CodeAnalysis;
26 | using System.Reflection.Emit;
27 | using NUnit.Framework;
28 | using Smocks.IL;
29 |
30 | namespace Smocks.Tests.IL
31 | {
32 | [ExcludeFromCodeCoverage]
33 | [TestFixture]
34 | public class CompiledDynamicMethodTests
35 | {
36 | [TestCase]
37 | public void Constructor_MethodNull_ThrowsArgumentNullException()
38 | {
39 | var exception = Assert.Throws(
40 | () => new CompiledDynamicMethod(null));
41 |
42 | Assert.AreEqual("method", exception.ParamName);
43 | }
44 |
45 | [TestCase("Hello, world!")]
46 | public void Invoke_StaticMethod_PassesArgumentsAndReturnsReturnValue(string message)
47 | {
48 | var method = new DynamicMethod("Test", typeof(string), new[] { typeof(string) });
49 | var generator = method.GetILGenerator();
50 |
51 | generator.Emit(OpCodes.Ldarg_0);
52 | generator.Emit(OpCodes.Ret);
53 |
54 | var subject = new CompiledDynamicMethod(method);
55 | var result = subject.Invoke(new object[] { message });
56 |
57 | Assert.AreEqual(message, result);
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/Source/Smocks.Tests/IL/Dependencies/DependencyGraphNodeTests.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | //// The MIT License (MIT)
3 | ////
4 | //// Copyright (c) 2015 Tom van der Kleij
5 | ////
6 | //// Permission is hereby granted, free of charge, to any person obtaining a copy of
7 | //// this software and associated documentation files (the "Software"), to deal in
8 | //// the Software without restriction, including without limitation the rights to
9 | //// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10 | //// the Software, and to permit persons to whom the Software is furnished to do so,
11 | //// subject to the following conditions:
12 | ////
13 | //// The above copyright notice and this permission notice shall be included in all
14 | //// copies or substantial portions of the Software.
15 | ////
16 | //// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | //// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 | //// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 | //// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 | //// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | //// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | #endregion
23 | using System;
24 | using System.Diagnostics.CodeAnalysis;
25 | using NUnit.Framework;
26 | using Smocks.IL;
27 | using Smocks.IL.Dependencies;
28 | using Smocks.Tests.TestUtility;
29 |
30 | namespace Smocks.Tests.IL.Dependencies
31 | {
32 | [ExcludeFromCodeCoverage]
33 | [TestFixture]
34 | public class DependencyGraphNodeTests
35 | {
36 | [TestCase]
37 | public void Constructor_ModuleComparerNull_ThrowsArgumentNullException()
38 | {
39 | var module = CecilUtility.Import(typeof(object)).Resolve().Module;
40 | var exception = Assert.Throws(
41 | () => new DependencyGraphNode(module, null));
42 |
43 | Assert.AreEqual("moduleComparer", exception.ParamName);
44 | }
45 |
46 | [TestCase]
47 | public void Constructor_ModuleNull_ThrowsArgumentNullException()
48 | {
49 | var exception = Assert.Throws(
50 | () => new DependencyGraphNode(null, new ModuleReferenceComparer()));
51 |
52 | Assert.AreEqual("module", exception.ParamName);
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/Source/Smocks.Tests/IL/Dependencies/DependencyGraphTests.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | //// The MIT License (MIT)
3 | ////
4 | //// Copyright (c) 2015 Tom van der Kleij
5 | ////
6 | //// Permission is hereby granted, free of charge, to any person obtaining a copy of
7 | //// this software and associated documentation files (the "Software"), to deal in
8 | //// the Software without restriction, including without limitation the rights to
9 | //// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10 | //// the Software, and to permit persons to whom the Software is furnished to do so,
11 | //// subject to the following conditions:
12 | ////
13 | //// The above copyright notice and this permission notice shall be included in all
14 | //// copies or substantial portions of the Software.
15 | ////
16 | //// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | //// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 | //// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 | //// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 | //// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | //// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | #endregion
23 | using System;
24 | using System.Diagnostics.CodeAnalysis;
25 | using NUnit.Framework;
26 | using Smocks.IL;
27 | using Smocks.IL.Dependencies;
28 | using Smocks.Tests.TestUtility;
29 |
30 | namespace Smocks.Tests.IL.Dependencies
31 | {
32 | [ExcludeFromCodeCoverage]
33 | [TestFixture]
34 | public class DependencyGraphTests
35 | {
36 | [TestCase]
37 | public void Constructor_ModuleComparerNull_ThrowsArgumentNullException()
38 | {
39 | var module = CecilUtility.Import(typeof(object)).Resolve().Module;
40 | var exception = Assert.Throws(
41 | () => new DependencyGraph(module, null));
42 |
43 | Assert.AreEqual("moduleComparer", exception.ParamName);
44 | }
45 |
46 | [TestCase]
47 | public void Constructor_ModuleNull_ThrowsArgumentNullException()
48 | {
49 | var exception = Assert.Throws(
50 | () => new DependencyGraph(null, new ModuleReferenceComparer()));
51 |
52 | Assert.AreEqual("module", exception.ParamName);
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/Source/Smocks.Tests/IL/Filters/AllowAllModuleFilterTests.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | //// The MIT License (MIT)
3 | ////
4 | //// Copyright (c) 2015 Tom van der Kleij
5 | ////
6 | //// Permission is hereby granted, free of charge, to any person obtaining a copy of
7 | //// this software and associated documentation files (the "Software"), to deal in
8 | //// the Software without restriction, including without limitation the rights to
9 | //// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10 | //// the Software, and to permit persons to whom the Software is furnished to do so,
11 | //// subject to the following conditions:
12 | ////
13 | //// The above copyright notice and this permission notice shall be included in all
14 | //// copies or substantial portions of the Software.
15 | ////
16 | //// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | //// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 | //// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 | //// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 | //// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | //// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | #endregion
23 | using System.Diagnostics.CodeAnalysis;
24 | using NUnit.Framework;
25 | using Smocks.IL.Filters;
26 | using Smocks.Tests.TestUtility;
27 |
28 | namespace Smocks.Tests.IL.Filters
29 | {
30 | [ExcludeFromCodeCoverage]
31 | [TestFixture]
32 | public class AllowAllModuleFilterTests
33 | {
34 | [TestCase]
35 | public void Accepts_ReturnsTrue()
36 | {
37 | var subject = new AllowAllModuleFilter();
38 |
39 | Assert.IsTrue(subject.Accepts(null));
40 | Assert.IsTrue(subject.Accepts(CecilUtility.Import(typeof(object)).Resolve().Module));
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/Source/Smocks.Tests/IL/ParameterTests.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | //// The MIT License (MIT)
3 | ////
4 | //// Copyright (c) 2015 Tom van der Kleij
5 | ////
6 | //// Permission is hereby granted, free of charge, to any person obtaining a copy of
7 | //// this software and associated documentation files (the "Software"), to deal in
8 | //// the Software without restriction, including without limitation the rights to
9 | //// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10 | //// the Software, and to permit persons to whom the Software is furnished to do so,
11 | //// subject to the following conditions:
12 | ////
13 | //// The above copyright notice and this permission notice shall be included in all
14 | //// copies or substantial portions of the Software.
15 | ////
16 | //// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | //// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 | //// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 | //// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 | //// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | //// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | #endregion
23 |
24 | using System;
25 | using System.Diagnostics.CodeAnalysis;
26 | using NUnit.Framework;
27 | using Smocks.IL;
28 | using Smocks.Tests.TestUtility;
29 |
30 | namespace Smocks.Tests.IL
31 | {
32 | [ExcludeFromCodeCoverage]
33 | [TestFixture]
34 | public class ParameterTests
35 | {
36 | [TestCase]
37 | public void Constructor_ParameterTypeNull_ThrowsArgumentNullException()
38 | {
39 | var exception = Assert.Throws(
40 | () => new Parameter(null, 1));
41 |
42 | Assert.AreEqual("parameterType", exception.ParamName);
43 | }
44 |
45 | [TestCase]
46 | public void Constructor_SetsProperties()
47 | {
48 | const int index = 42;
49 | var type = CecilUtility.Import(typeof(string));
50 |
51 | var subject = new Parameter(type, index);
52 |
53 | Assert.AreSame(type, subject.ParameterType);
54 | Assert.AreEqual(index, subject.Index);
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/Source/Smocks.Tests/IL/Resolvers/FieldResolverTests.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | //// The MIT License (MIT)
3 | ////
4 | //// Copyright (c) 2015 Tom van der Kleij
5 | ////
6 | //// Permission is hereby granted, free of charge, to any person obtaining a copy of
7 | //// this software and associated documentation files (the "Software"), to deal in
8 | //// the Software without restriction, including without limitation the rights to
9 | //// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10 | //// the Software, and to permit persons to whom the Software is furnished to do so,
11 | //// subject to the following conditions:
12 | ////
13 | //// The above copyright notice and this permission notice shall be included in all
14 | //// copies or substantial portions of the Software.
15 | ////
16 | //// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | //// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 | //// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 | //// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 | //// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | //// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | #endregion
23 |
24 | using System;
25 | using System.Diagnostics.CodeAnalysis;
26 | using NUnit.Framework;
27 | using Smocks.IL.Resolvers;
28 |
29 | namespace Smocks.Tests.IL.Resolvers
30 | {
31 | [ExcludeFromCodeCoverage]
32 | [TestFixture]
33 | public class FieldResolverTests
34 | {
35 | [TestCase]
36 | public void Constructor_TypeResolverNull_ThrowsArgumentNullException()
37 | {
38 | var exception = Assert.Throws(() =>
39 | new FieldResolver(default(ITypeResolver)));
40 |
41 | Assert.AreEqual("typeResolver", exception.ParamName);
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/Source/Smocks.Tests/Issues/IssueEightTests.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | //// The MIT License (MIT)
3 | ////
4 | //// Copyright (c) 2015 Tom van der Kleij
5 | ////
6 | //// Permission is hereby granted, free of charge, to any person obtaining a copy of
7 | //// this software and associated documentation files (the "Software"), to deal in
8 | //// the Software without restriction, including without limitation the rights to
9 | //// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10 | //// the Software, and to permit persons to whom the Software is furnished to do so,
11 | //// subject to the following conditions:
12 | ////
13 | //// The above copyright notice and this permission notice shall be included in all
14 | //// copies or substantial portions of the Software.
15 | ////
16 | //// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | //// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 | //// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 | //// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 | //// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | //// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | #endregion
23 |
24 | using Moq;
25 | using NUnit.Framework;
26 |
27 | namespace Smocks.Tests.Issues
28 | {
29 | [TestFixture]
30 | public class IssueEightTests
31 | {
32 | [TestCase]
33 | public void Issue8()
34 | {
35 | Smock.Run(context =>
36 | {
37 | context.Setup(() => It.IsAny().Fetch(It.IsAny())).Returns((object)null);
38 |
39 | new EmployeeProcess().Load(new object());
40 | });
41 | }
42 |
43 | internal class ClassDatabase
44 | {
45 | public object Fetch(bool val2)
46 | {
47 | return null;
48 | }
49 | }
50 |
51 | internal sealed class EmployeeProcess
52 | {
53 | public void Load(object ei)
54 | {
55 | if (ei != null)
56 | {
57 | new ClassDatabase().Fetch(false);
58 | }
59 | }
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Source/Smocks.Tests/Issues/IssueElevenTests.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | //// The MIT License (MIT)
3 | ////
4 | //// Copyright (c) 2015 Tom van der Kleij
5 | ////
6 | //// Permission is hereby granted, free of charge, to any person obtaining a copy of
7 | //// this software and associated documentation files (the "Software"), to deal in
8 | //// the Software without restriction, including without limitation the rights to
9 | //// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10 | //// the Software, and to permit persons to whom the Software is furnished to do so,
11 | //// subject to the following conditions:
12 | ////
13 | //// The above copyright notice and this permission notice shall be included in all
14 | //// copies or substantial portions of the Software.
15 | ////
16 | //// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | //// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 | //// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 | //// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 | //// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | //// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | #endregion
23 |
24 | using Moq;
25 | using NUnit.Framework;
26 |
27 | namespace Smocks.Tests.Issues
28 | {
29 | [TestFixture]
30 | public class IssueElevenTests
31 | {
32 | [TestCase]
33 | public void Issue11()
34 | {
35 | Smock.Run(context =>
36 | {
37 | bool called = false;
38 | Message message = new Message();
39 |
40 | context.Setup(() => It.IsAny().Send(message)).Callback((Message m) =>
41 | {
42 | called = true;
43 | Assert.AreEqual(m, message);
44 | });
45 |
46 | new MessageQueue().Send(message);
47 |
48 | Assert.IsTrue(called);
49 | });
50 | }
51 |
52 | public class Message
53 | {
54 | }
55 |
56 | public class MessageQueue
57 | {
58 | public void Send(object message)
59 | {
60 | }
61 | }
62 | }
63 | }
--------------------------------------------------------------------------------
/Source/Smocks.Tests/Issues/IssueTwelveTests.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | //// The MIT License (MIT)
3 | ////
4 | //// Copyright (c) 2015 Tom van der Kleij
5 | ////
6 | //// Permission is hereby granted, free of charge, to any person obtaining a copy of
7 | //// this software and associated documentation files (the "Software"), to deal in
8 | //// the Software without restriction, including without limitation the rights to
9 | //// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10 | //// the Software, and to permit persons to whom the Software is furnished to do so,
11 | //// subject to the following conditions:
12 | ////
13 | //// The above copyright notice and this permission notice shall be included in all
14 | //// copies or substantial portions of the Software.
15 | ////
16 | //// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | //// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 | //// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 | //// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 | //// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | //// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | #endregion
23 |
24 | using System;
25 | using NUnit.Framework;
26 |
27 | namespace Smocks.Tests.Issues
28 | {
29 | [TestFixture]
30 | public class IssueTwelveTests
31 | {
32 | [TestCase]
33 | public void Issue12()
34 | {
35 | var now = DateTime.Now.AddMonths(18);
36 |
37 | Smock.Run(ctx =>
38 | {
39 | var person = new Person { FirstName = "John", LastName = "Doe", Age = 24 };
40 | ctx.Setup(() => DateTime.Now).Returns(now);
41 |
42 | var name = person.FirstName;
43 |
44 | Assert.AreNotEqual(now, person.AccessedOn);
45 | });
46 | }
47 |
48 | public class Person
49 | {
50 | public DateTime AccessedOn { get; set; }
51 |
52 | public string FirstName { get; set; }
53 |
54 | public string LastName { get; set; }
55 |
56 | public int Age { get; set; }
57 | }
58 | }
59 | }
--------------------------------------------------------------------------------
/Source/Smocks.Tests/Issues/IssueTwentySixTests.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using Aspose.Cells;
3 | using Moq;
4 | using NUnit.Framework;
5 |
6 | namespace Smocks.Tests.Issues
7 | {
8 | [TestFixture]
9 | public class IssueTwentySixTests
10 | {
11 | public interface IEntityWorksheetReaderFactory
12 | {
13 | void EntityWorksheetReader(Worksheet worksheet, CellArea cellArea);
14 | }
15 |
16 | [Test]
17 | public void Issue26()
18 | {
19 | // The issue was that this code was throwing a MethodAccessException. By resolving this issue,
20 | // it now throws a MockException.
21 | Assert.Throws(() =>
22 | {
23 | Smock.Run(context =>
24 | {
25 | // The Aspose.Cells assembly has the assembly attribute AllowPartiallyTrustedCallersAttribute set.
26 | // This causes issues when we rewrite the methods in the assembly to call into Smocks to handle
27 | // interception. We resolve this by simply removing said attribute, so that the calls into
28 | // Smocks are then allowed.
29 | var workbook = new Workbook(new MemoryStream());
30 | var worksheet = workbook.Worksheets.Add("Wal-Mart Stores");
31 | context.Setup(() => workbook.Worksheets[It.IsAny()]).Returns(worksheet);
32 |
33 | var worksheetReaderFactory = Mock.Of();
34 |
35 | Mock.Get(worksheetReaderFactory).Verify(m => m.EntityWorksheetReader(
36 | worksheet,
37 | It.Is(
38 | ca => ca.StartRow == 1 && ca.EndRow == 5 && ca.StartColumn == 0 && ca.EndColumn == 5)),
39 | Times.Once);
40 | });
41 | });
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/Source/Smocks.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | //// The MIT License (MIT)
3 | ////
4 | //// Copyright (c) 2015 Tom van der Kleij
5 | ////
6 | //// Permission is hereby granted, free of charge, to any person obtaining a copy of
7 | //// this software and associated documentation files (the "Software"), to deal in
8 | //// the Software without restriction, including without limitation the rights to
9 | //// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10 | //// the Software, and to permit persons to whom the Software is furnished to do so,
11 | //// subject to the following conditions:
12 | ////
13 | //// The above copyright notice and this permission notice shall be included in all
14 | //// copies or substantial portions of the Software.
15 | ////
16 | //// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | //// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 | //// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 | //// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 | //// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | //// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | #endregion
23 |
24 | using System.Reflection;
25 | using System.Runtime.InteropServices;
26 |
27 | // General Information about an assembly is controlled through the following
28 | // set of attributes. Change these attribute values to modify the information
29 | // associated with an assembly.
30 | [assembly: AssemblyTitle("Smocks.Tests")]
31 | [assembly: AssemblyProduct("Smocks.Tests")]
32 |
33 | // Setting ComVisible to false makes the types in this assembly not visible
34 | // to COM components. If you need to access a type in this assembly from
35 | // COM, set the ComVisible attribute to true on that type.
36 | [assembly: ComVisible(false)]
37 |
38 | // The following GUID is for the ID of the typelib if this project is exposed to COM
39 | [assembly: Guid("55aff6a9-cd87-4dee-8af7-34d7e62528aa")]
--------------------------------------------------------------------------------
/Source/Smocks.Tests/Settings.StyleCop:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | False
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Source/Smocks.Tests/TestUtility/AssemblyUtility.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | //// The MIT License (MIT)
3 | ////
4 | //// Copyright (c) 2015 Tom van der Kleij
5 | ////
6 | //// Permission is hereby granted, free of charge, to any person obtaining a copy of
7 | //// this software and associated documentation files (the "Software"), to deal in
8 | //// the Software without restriction, including without limitation the rights to
9 | //// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10 | //// the Software, and to permit persons to whom the Software is furnished to do so,
11 | //// subject to the following conditions:
12 | ////
13 | //// The above copyright notice and this permission notice shall be included in all
14 | //// copies or substantial portions of the Software.
15 | ////
16 | //// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | //// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 | //// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 | //// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 | //// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | //// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | #endregion
23 |
24 | using System;
25 | using System.Diagnostics.CodeAnalysis;
26 | using System.IO;
27 | using System.Reflection;
28 | using System.Reflection.Emit;
29 |
30 | namespace Smocks.Tests.TestUtility
31 | {
32 | [ExcludeFromCodeCoverage]
33 | internal static class AssemblyUtility
34 | {
35 | internal static string CreateDummyAssembly(AssemblyName assemblyName)
36 | {
37 | string directory = Path.GetTempPath();
38 | string filename = Guid.NewGuid() + ".dll";
39 |
40 | var assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName,
41 | AssemblyBuilderAccess.Save, directory);
42 | assemblyBuilder.Save(filename);
43 |
44 | return Path.Combine(directory, filename);
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/Source/Smocks.Tests/TestUtility/CecilUtility.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | //// The MIT License (MIT)
3 | ////
4 | //// Copyright (c) 2015 Tom van der Kleij
5 | ////
6 | //// Permission is hereby granted, free of charge, to any person obtaining a copy of
7 | //// this software and associated documentation files (the "Software"), to deal in
8 | //// the Software without restriction, including without limitation the rights to
9 | //// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10 | //// the Software, and to permit persons to whom the Software is furnished to do so,
11 | //// subject to the following conditions:
12 | ////
13 | //// The above copyright notice and this permission notice shall be included in all
14 | //// copies or substantial portions of the Software.
15 | ////
16 | //// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | //// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 | //// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 | //// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 | //// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | //// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | #endregion
23 |
24 | using System;
25 | using System.Diagnostics.CodeAnalysis;
26 | using System.Linq.Expressions;
27 | using System.Reflection;
28 | using Mono.Cecil;
29 |
30 | namespace Smocks.Tests.TestUtility
31 | {
32 | [ExcludeFromCodeCoverage]
33 | internal static class CecilUtility
34 | {
35 | public static MethodReference Import(MethodBase method)
36 | {
37 | ModuleDefinition module = ModuleDefinition.CreateModule("Dummy", ModuleKind.Dll);
38 | return module.ImportReference(method);
39 | }
40 |
41 | public static TypeReference Import(Type type)
42 | {
43 | ModuleDefinition module = ModuleDefinition.CreateModule("Dummy", ModuleKind.Dll);
44 | return module.ImportReference(type);
45 | }
46 |
47 | public static FieldReference Import(FieldInfo fieldInfo)
48 | {
49 | ModuleDefinition module = ModuleDefinition.CreateModule("Dummy", ModuleKind.Dll);
50 | return module.ImportReference(fieldInfo);
51 | }
52 |
53 | public static MethodReference Import(Expression expression)
54 | {
55 | return Import(ReflectionUtility.GetMethod(expression));
56 | }
57 | }
58 | }
--------------------------------------------------------------------------------
/Source/Smocks.Tests/Utility/ArgumentCheckerTests.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | //// The MIT License (MIT)
3 | ////
4 | //// Copyright (c) 2015 Tom van der Kleij
5 | ////
6 | //// Permission is hereby granted, free of charge, to any person obtaining a copy of
7 | //// this software and associated documentation files (the "Software"), to deal in
8 | //// the Software without restriction, including without limitation the rights to
9 | //// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10 | //// the Software, and to permit persons to whom the Software is furnished to do so,
11 | //// subject to the following conditions:
12 | ////
13 | //// The above copyright notice and this permission notice shall be included in all
14 | //// copies or substantial portions of the Software.
15 | ////
16 | //// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | //// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 | //// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 | //// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 | //// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | //// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | #endregion
23 |
24 | using System;
25 | using System.Diagnostics.CodeAnalysis;
26 | using NUnit.Framework;
27 | using Smocks.Utility;
28 |
29 | namespace Smocks.Tests.Utility
30 | {
31 | [ExcludeFromCodeCoverage]
32 | [TestFixture]
33 | public class ArgumentCheckerTests
34 | {
35 | [TestCase(default(string))]
36 | public void NotNull_ArgumentNull_ThrowsArgumentNullException(string testArgument)
37 | {
38 | var exception = Assert.Throws(() =>
39 | ArgumentChecker.NotNull(testArgument, () => testArgument));
40 |
41 | Assert.AreEqual("testArgument", exception.ParamName);
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/Source/Smocks.Tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Source/Smocks.licenseheader:
--------------------------------------------------------------------------------
1 | extensions: designer.cs generated.cs
2 | extensions: .cs .tt
3 | #region License
4 | //// The MIT License (MIT)
5 | ////
6 | //// Copyright (c) 2015 Tom van der Kleij
7 | ////
8 | //// Permission is hereby granted, free of charge, to any person obtaining a copy of
9 | //// this software and associated documentation files (the "Software"), to deal in
10 | //// the Software without restriction, including without limitation the rights to
11 | //// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
12 | //// the Software, and to permit persons to whom the Software is furnished to do so,
13 | //// subject to the following conditions:
14 | ////
15 | //// The above copyright notice and this permission notice shall be included in all
16 | //// copies or substantial portions of the Software.
17 | ////
18 | //// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | //// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
20 | //// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
21 | //// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
22 | //// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | //// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | #endregion
25 |
26 |
--------------------------------------------------------------------------------
/Source/Smocks.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vanderkleij/Smocks/58ee0f4454c3c421288537f63fa89d24273b01b3/Source/Smocks.snk
--------------------------------------------------------------------------------
/Source/Smocks/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vanderkleij/Smocks/58ee0f4454c3c421288537f63fa89d24273b01b3/Source/Smocks/.gitignore
--------------------------------------------------------------------------------
/Source/Smocks/AppDomains/CecilAssemblyResolver.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Mono.Cecil;
3 | using Smocks.Utility;
4 |
5 | namespace Smocks.AppDomains
6 | {
7 | public class CecilAssemblyResolver : DefaultAssemblyResolver
8 | {
9 | public CecilAssemblyResolver(Configuration configuration)
10 | {
11 | ArgumentChecker.NotNull(configuration, nameof(configuration));
12 |
13 | AddSearchDirectory(AppDomain.CurrentDomain.BaseDirectory);
14 |
15 | if (configuration.AssemblySearchDirectories != null)
16 | {
17 | foreach (string searchDirectory in configuration.AssemblySearchDirectories)
18 | {
19 | AddSearchDirectory(searchDirectory);
20 | }
21 | }
22 | }
23 |
24 | public CecilAssemblyResolver()
25 | : this(new Configuration())
26 | {
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/Source/Smocks/AppDomains/EnumerableReturnValueTransformer.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | //// The MIT License (MIT)
3 | ////
4 | //// Copyright (c) 2015 Tom van der Kleij
5 | ////
6 | //// Permission is hereby granted, free of charge, to any person obtaining a copy of
7 | //// this software and associated documentation files (the "Software"), to deal in
8 | //// the Software without restriction, including without limitation the rights to
9 | //// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10 | //// the Software, and to permit persons to whom the Software is furnished to do so,
11 | //// subject to the following conditions:
12 | ////
13 | //// The above copyright notice and this permission notice shall be included in all
14 | //// copies or substantial portions of the Software.
15 | ////
16 | //// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | //// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 | //// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 | //// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 | //// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | //// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | #endregion
23 |
24 | using System;
25 | using System.Collections;
26 | using System.Linq;
27 |
28 | namespace Smocks.AppDomains
29 | {
30 | internal class EnumerableReturnValueTransformer : IReturnValueTransformer
31 | {
32 | public bool CanTransform(Type type, object returnValue)
33 | {
34 | return type == typeof(IEnumerable);
35 | }
36 |
37 | public TReturnValue Transform(TReturnValue returnValue)
38 | {
39 | if (returnValue == null)
40 | {
41 | return default(TReturnValue);
42 | }
43 |
44 | var list = ((IEnumerable)returnValue).Cast