Minor naming fixes and cleaning

This commit is contained in:
Scott Bilas 2018-11-21 15:46:01 +01:00
Родитель b0e69eea0f
Коммит 50aefd0765
4 изменённых файлов: 15 добавлений и 43 удалений

Просмотреть файл

@ -112,7 +112,7 @@ namespace NSubstitute.Elevated
{
var found = field.GetValue(null);
if (found == null)
throw new SubstituteException("Unexpected static unmock of an already unmocked type");
throw new SubstituteException("Unexpected static unmock of an already-unmocked type");
if (found != callRouter)
throw new SubstituteException("Discovered unexpected call router attached in static mock context");

Просмотреть файл

@ -37,7 +37,7 @@ namespace NSubstitute.Elevated.Weaver
var patchResults = new Dictionary<string, PatchResult>(StringComparer.OrdinalIgnoreCase);
var mockInjector = new MockInjector();
EnsureMockTypesInFolder(testAssemblyPath.Parent);
EnsureMockTypesAssemblyInFolder(testAssemblyPath.Parent);
for (var toProcessIndex = 0; toProcessIndex < toProcess.Count; ++toProcessIndex)
{
@ -120,7 +120,7 @@ namespace NSubstitute.Elevated.Weaver
return patchResults.Values;
}
static void EnsureMockTypesInFolder(NPath targetFolder)
static void EnsureMockTypesAssemblyInFolder(NPath targetFolder)
{
// ensure that our assembly with the mock types is discoverable by putting in the same folder as the dll that is having its types
// injected into it. we could mess with the assembly resolver to avoid this, but that won't solve the issue for appdomains and

Просмотреть файл

@ -152,14 +152,14 @@ namespace NSubstitute.Elevated.Tests
{
var sub = Substitute.For<SimpleClass>();
sub.VoidMethod(5);
sub.VoidMethodWithParam(5);
sub.Modified.ShouldBe(0);
sub.ReturnMethod(5).ShouldBe(0);
sub.ReturnMethodWithParam(5).ShouldBe(0);
sub.Modified.ShouldBe(0);
sub.ReturnMethod(5).Returns(10);
sub.ReturnMethod(5).ShouldBe(10);
sub.ReturnMethodWithParam(5).Returns(10);
sub.ReturnMethodWithParam(5).ShouldBe(10);
sub.Modified.ShouldBe(0);
}
@ -168,14 +168,14 @@ namespace NSubstitute.Elevated.Tests
{
var sub = Substitute.ForPartsOf<SimpleClass>();
sub.VoidMethod(5);
sub.VoidMethodWithParam(5);
sub.Modified.ShouldBe(5);
sub.ReturnMethod(3).ShouldBe(8);
sub.ReturnMethodWithParam(3).ShouldBe(8);
sub.Modified.ShouldBe(8);
sub.ReturnMethod(4).Returns(10);
sub.ReturnMethod(4).ShouldBe(10);
sub.ReturnMethodWithParam(4).Returns(10);
sub.ReturnMethodWithParam(4).ShouldBe(10);
sub.Modified.ShouldBe(8);
}
}

Просмотреть файл

@ -1,17 +1,15 @@
using System;
//using NSubstitute.Elevated.WeaverInternals;
//using NSubstitute.Elevated.WeaverInternals;
#if TEST_ICALLS
using System.Runtime.CompilerServices;
#endif
#pragma warning disable 169
// ReSharper disable ClassNeverInstantiated.Global
// ReSharper disable InconsistentNaming
// ReSharper disable MemberInitializerValueIgnored
// ReSharper disable PublicConstructorInAbstractClass
// ReSharper disable UnusedMember.Local
// ReSharper disable UnusedMember.Global
// ReSharper disable UnusedParameter.Local
namespace SystemUnderTest
@ -91,35 +89,9 @@ namespace SystemUnderTest
{
public int Modified;
//actual
public void VoidMethod() => ++Modified;
public int ReturnMethod() => ++Modified;
//hack until patching works
public void VoidMethod(int count)
{
/*if (PatchedAssemblyBridgeX.TryMock(typeof(SimpleClass), this, typeof(void), out var _, Type.EmptyTypes, new object[] { count }))
return;*/
Modified += count;
}
public int ReturnMethod(int count)
{
/*if (PatchedAssemblyBridgeX.TryMock(typeof(SimpleClass), this, typeof(int), out var returnValue, Type.EmptyTypes, new object[] { count }))
return (int)returnValue;#1#*/
return Modified += count;
}
public void VoidMethodWithParam(int count) => Modified += count;
public int ReturnMethodWithParam(int count) => Modified += count;
}
}
/*namespace NSubstitute.Elevated.WeaverInternals
{
public static class PatchedAssemblyBridgeX
{
public delegate bool TryMockProc(Type actualType, object instance, Type mockedReturnType, out object mockedReturnValue, Type[] methodGenericTypes, object[] args);
public static TryMockProc TryMock;
}
}*/