Skip to content
This repository was archived by the owner on Jun 30, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017 Daniel Cazzulino and Contributors
Copyright (c) Daniel Cazzulino and Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions src/Acceptance/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)../../../nugetizer/bin'));
$(RestoreSources)
</RestoreSources>
<RestoreSources Condition="Exists('$(MSBuildThisFileDirectory)../../../stunts/bin/')">
$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)../../../stunts/bin'));
<RestoreSources Condition="Exists('$(MSBuildThisFileDirectory)../../../avatar/bin/')">
$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)../../../avatar/bin'));
$(RestoreSources)
</RestoreSources>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Acceptance/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<ItemGroup>
<PackageVersion Include="NuGetizer" Version="0.4.9" />
<PackageVersion Update="NuGetizer" Version="42.42.42" Condition="Exists('$(MSBuildThisFileDirectory)..\..\..\nugetizer\bin\')" />
<PackageReference Update="Stunts" Version="$(StuntsVersion)" />
<PackageReference Update="Avatar" Version="$(AvatarVersion)" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Acceptance/Dynamic/Dynamic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
<PackageReference Include="Moq" Version="$(Version)" />
<PackageReference Include="ManualStunts" Version="$(StuntsVersion)" />
<PackageReference Include="ManualAvatars" Version="$(AvatarVersion)" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/Acceptance/Static/Static.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
<PackageReference Include="Moq" Version="$(Version)" />
<PackageReference Include="ManualStunts" Version="$(StuntsVersion)" />
<PackageReference Include="ManualAvatars" Version="$(AvatarVersion)" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<RestoreSources>https://pkg.kzu.io/index.json;https://api.nuget.org/v3/index.json;$(RestoreSources)</RestoreSources>
<RestoreSources Condition="Exists('$(MSBuildThisFileDirectory)..\..\nugetizer\bin\')">$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\..\nugetizer\bin'));$(RestoreSources)</RestoreSources>
<RestoreSources Condition="Exists('$(MSBuildThisFileDirectory)..\..\stunts\bin\')">$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\..\stunts\bin'));$(RestoreSources)</RestoreSources>
<RestoreSources Condition="Exists('$(MSBuildThisFileDirectory)..\..\avatar\bin\')">$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\..\avatar\bin'));$(RestoreSources)</RestoreSources>
<RestoreSources Condition="Exists('$(MSBuildThisFileDirectory)..\..\ThisAssembly\bin\')">$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\..\ThisAssembly\bin'));$(RestoreSources)</RestoreSources>

<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)Moq.snk</AssemblyOriginatorKeyFile>
Expand Down
14 changes: 7 additions & 7 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>

<PropertyGroup>
<StuntsVersion>42.42.42-main.175</StuntsVersion>
<StuntsVersion Condition="Exists('$(MSBuildThisFileDirectory)..\..\stunts\bin\')">42.42.42</StuntsVersion>
<AvatarVersion>42.42.42-main.249</AvatarVersion>
<AvatarVersion Condition="Exists('$(MSBuildThisFileDirectory)..\..\avatar\bin\')">42.42.42</AvatarVersion>
</PropertyGroup>

<ItemGroup Label="Core">
Expand All @@ -12,10 +12,10 @@
<PackageVersion Update="ThisAssembly" Version="42.42.42" Condition="Exists('$(MSBuildThisFileDirectory)..\..\ThisAssembly\bin\')" />
<PackageVersion Include="NuGetizer" Version="0.4.9" />
<PackageVersion Update="NuGetizer" Version="42.42.42" Condition="Exists('$(MSBuildThisFileDirectory)..\..\nugetizer\bin\')" />
<PackageVersion Include="Stunts" Version="$(StuntsVersion)" />
<PackageVersion Include="Stunts.CodeAnalysis" Version="$(StuntsVersion)" />
<PackageVersion Include="Stunts.DynamicProxy" Version="$(StuntsVersion)" />
<PackageVersion Include="Stunts.StaticProxy" Version="$(StuntsVersion)" />
<PackageVersion Include="Avatar" Version="$(AvatarVersion)" />
<PackageVersion Include="Avatar.CodeAnalysis" Version="$(AvatarVersion)" />
<PackageVersion Include="Avatar.DynamicProxy" Version="$(AvatarVersion)" />
<PackageVersion Include="Avatar.StaticProxy" Version="$(AvatarVersion)" />
</ItemGroup>

<ItemGroup Label="Roslyn">
Expand Down Expand Up @@ -50,7 +50,7 @@
<PackageVersion Include="coverlet.collector" Version="1.3.0" />
<PackageVersion Include="coverlet.msbuild" Version="2.9.0" />
<PackageVersion Include="System.ComponentModel.Composition" Version="4.7.0" />
<PackageVersion Include="ManualStunts" Version="$(StuntsVersion)" />
<PackageVersion Include="ManualAvatars" Version="$(AvatarVersion)" />
</ItemGroup>

<ItemGroup Label="MSBuild">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.VisualBasic;
using Stunts;
using Avatars;

/// <summary>
/// Class for turning strings into documents and getting the diagnostics on them
Expand Down
2 changes: 1 addition & 1 deletion src/Moq.CodeAnalysis/MockNamingConvention.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Moq.Sdk;
using Stunts.CodeAnalysis;
using Avatars.CodeAnalysis;

namespace Moq
{
Expand Down
2 changes: 1 addition & 1 deletion src/Moq.CodeAnalysis/MockValidateTypesAnalyzer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Stunts.CodeAnalysis;
using Avatars.CodeAnalysis;

namespace Moq
{
Expand Down
4 changes: 2 additions & 2 deletions src/Moq.CodeAnalysis/Moq.CodeAnalysis.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Stunts" />
<PackageReference Include="Stunts.CodeAnalysis" />
<PackageReference Include="Avatar" />
<PackageReference Include="Avatar.CodeAnalysis" />
<PackageReference Include="Superpower" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Pack="false" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Pack="false" />
Expand Down
8 changes: 4 additions & 4 deletions src/Moq.DynamicProxy/DynamicMockFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
using System.Reflection;
using System.Threading;
using Castle.DynamicProxy;
using Stunts;
using Avatars;

namespace Moq.Sdk
{
/// <summary>
/// Provides an <see cref="IMockFactory"/> that creates types at run-time using Castle DynamicProxy.
/// </summary>
public class DynamicMockFactory : DynamicStuntFactory, IMockFactory
public class DynamicMockFactory : DynamicAvatarFactory, IMockFactory
{
/// <inheritdoc />
public object CreateMock(Assembly mocksAssembly, Type baseType, Type[] implementedInterfaces, object[] constructorArguments)
=> CreateStunt(mocksAssembly, baseType, implementedInterfaces, constructorArguments);
=> CreateAvatar(mocksAssembly, baseType, implementedInterfaces, constructorArguments);

/// <summary>
/// Creates the mock proxy.
Expand Down Expand Up @@ -48,7 +48,7 @@ private class MockInterceptor : IInterceptor
public void Intercept(IInvocation invocation)
{
if (invocation.Method.DeclaringType == typeof(IMocked))
invocation.ReturnValue = LazyInitializer.EnsureInitialized(ref mock, () => new DefaultMock((IStunt)invocation.Proxy));
invocation.ReturnValue = LazyInitializer.EnsureInitialized(ref mock, () => new DefaultMock((IAvatar)invocation.Proxy));
else
invocation.Proceed();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Moq.DynamicProxy/Moq.DynamicProxy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Stunts" />
<PackageReference Include="Avatar" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Moq.Package/Moq.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

<PropertyGroup>
<MoqAnalyzerDir>$(MSBuildThisFileDirectory)..\..\tools\netstandard2.0</MoqAnalyzerDir>
<!-- SourceGeneratorSupported provided by Stunts.targets -->
<!-- SourceGeneratorSupported provided by Avatar.targets -->
<RegisterStaticMockFactory Condition="'$(RegisterStaticMockFactory)' == '' and
'$(SourceGeneratorSupported)' == 'true'">true</RegisterStaticMockFactory>
</PropertyGroup>

<!-- Stunts provides this property -->
<!-- Avatar provides this property -->
<ItemGroup Condition="'$(SourceGeneratorSupported)' == 'true'">
<CompilerVisibleProperty Include="DebugMoqSourceGenerator" />
<CompilerVisibleProperty Include="MoqAnalyzerDir" />
Expand Down
6 changes: 3 additions & 3 deletions src/Moq.Sdk.Tests/DefaultMockTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Reflection;
using System.Threading;
using Stunts;
using Avatars;
using Xunit;

namespace Moq.Sdk.Tests
Expand Down Expand Up @@ -102,12 +102,12 @@ public void TracksTargetObject()
public void InitializesState()
=> Assert.NotNull(new FakeStunt().Mock.State);

private class FakeStunt : IStunt, IMocked
private class FakeStunt : IAvatar, IMocked
{
private readonly BehaviorPipeline pipeline = new BehaviorPipeline();
private DefaultMock mock;

public IList<IStuntBehavior> Behaviors => pipeline.Behaviors;
public IList<IAvatarBehavior> Behaviors => pipeline.Behaviors;

public IMock Mock => LazyInitializer.EnsureInitialized(ref mock, () => new DefaultMock(this));

Expand Down
2 changes: 1 addition & 1 deletion src/Moq.Sdk.Tests/EqualityTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using Stunts;
using Avatars;
using Xunit;

namespace Moq.Sdk.Tests
Expand Down
2 changes: 1 addition & 1 deletion src/Moq.Sdk.Tests/EventBehaviorTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.ComponentModel;
using System.Reflection;
using Stunts;
using Avatars;
using Xunit;

namespace Moq.Sdk.Tests
Expand Down
6 changes: 3 additions & 3 deletions src/Moq.Sdk.Tests/Fakes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using Stunts;
using Avatars;

namespace Moq.Sdk.Tests
{
public class FakeMock : IStunt, IMocked
public class FakeMock : IAvatar, IMocked
{
private readonly DefaultMock mock;

protected BehaviorPipeline Pipeline = new BehaviorPipeline();

public FakeMock() => mock = new DefaultMock(this);

public IList<IStuntBehavior> Behaviors => Pipeline.Behaviors;
public IList<IAvatarBehavior> Behaviors => Pipeline.Behaviors;

public IMock Mock => mock;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Moq.Sdk.Tests/MockBehaviorPipelineTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Stunts;
using Avatars;
using Xunit;

namespace Moq.Sdk.Tests
Expand Down
4 changes: 2 additions & 2 deletions src/Moq.Sdk.Tests/MockBehaviorTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using Sample;
using Stunts;
using Avatars;
using Xunit;

namespace Moq.Sdk.Tests
Expand Down Expand Up @@ -57,7 +57,7 @@ public void ThrowsForNonIMocked()
[Fact]
public void WhenAddingMockBehavior_ThenCanInterceptSelectively()
{
var calculator = new CalculatorInterfaceStunt();
var calculator = new CalculatorInterfaceAvatar();

// TODO: this is not adding a mock behavior but a regular stunt behavior
calculator.AddBehavior((m, n) => m.CreateValueReturn(CalculatorMode.Scientific), m => m.MethodBase.Name == "get_Mode");
Expand Down
2 changes: 1 addition & 1 deletion src/Moq.Sdk.Tests/MockExtensionsTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using Xunit;
using Stunts;
using Avatars;
using System.Reflection;

namespace Moq.Sdk.Tests
Expand Down
2 changes: 1 addition & 1 deletion src/Moq.Sdk.Tests/MockTrackingBehaviorTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Reflection;
using Stunts;
using Avatars;
using Xunit;

namespace Moq.Sdk.Tests
Expand Down
8 changes: 4 additions & 4 deletions src/Moq.Sdk.Tests/Mocked.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading;
using Stunts;
using Avatars;

namespace Moq.Sdk.Tests
{
public class Mocked : IMocked, IStunt
public class Mocked : IMocked, IAvatar
{
private IMock mock;
private readonly IList<IStuntBehavior> behaviors = new ObservableCollection<IStuntBehavior>();
private readonly IList<IAvatarBehavior> behaviors = new ObservableCollection<IAvatarBehavior>();

public IMock Mock => LazyInitializer.EnsureInitialized(ref mock, () => new DefaultMock(this));

public IList<IStuntBehavior> Behaviors => behaviors;
public IList<IAvatarBehavior> Behaviors => behaviors;
}
}
2 changes: 1 addition & 1 deletion src/Moq.Sdk.Tests/Moq.Sdk.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PackageReference Include="xunit.runner.visualstudio" />
<PackageReference Include="coverlet.collector" />
<PackageReference Include="coverlet.msbuild" />
<PackageReference Include="ManualStunts" />
<PackageReference Include="ManualAvatars" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Moq.Sdk.Tests/PropertyBehaviorTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Reflection;
using Stunts;
using Avatars;
using Xunit;

namespace Moq.Sdk.Tests
Expand Down
10 changes: 5 additions & 5 deletions src/Moq.Sdk/DefaultMock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
using System.Collections.Specialized;
using System.Diagnostics;
using System.Linq;
using Stunts;
using Avatars;

namespace Moq.Sdk
{
/// <summary>
/// Default implementation of the mock introspection API <see cref="IMock"/>,
/// which also ensures that the <see cref="IStunt.Behaviors"/> contains
/// which also ensures that the <see cref="IAvatar.Behaviors"/> contains
/// the <see cref="MockContextBehavior"/> when initially created.
/// </summary>
[DebuggerDisplay("Invocations = {Invocations.Count}", Name = nameof(IMocked) + "." + nameof(IMocked.Mock))]
public class DefaultMock : IMock
{
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private readonly IStunt stunt;
private readonly IAvatar stunt;
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private readonly ConcurrentDictionary<IMockSetup, IMockBehaviorPipeline> setupBehaviorMap = new ConcurrentDictionary<IMockSetup, IMockBehaviorPipeline>();

/// <summary>
/// Initializes the default <see cref="IMock"/> implementation for the given <paramref name="stunt"/>.
/// </summary>
public DefaultMock(IStunt stunt)
public DefaultMock(IAvatar stunt)
{
this.stunt = stunt ?? throw new ArgumentNullException(nameof(stunt));
var behaviors = stunt.Behaviors;
Expand All @@ -40,7 +40,7 @@ public DefaultMock(IStunt stunt)
}

/// <inheritdoc />
public IList<IStuntBehavior> Behaviors => stunt.Behaviors;
public IList<IAvatarBehavior> Behaviors => stunt.Behaviors;

/// <inheritdoc />
public ICollection<IMethodInvocation> Invocations { get; } = new List<IMethodInvocation>();
Expand Down
2 changes: 1 addition & 1 deletion src/Moq.Sdk/DelegateMockBehavior.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Diagnostics;
using Stunts;
using Avatars;

namespace Moq.Sdk
{
Expand Down
6 changes: 3 additions & 3 deletions src/Moq.Sdk/EventBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using Stunts;
using Avatars;

namespace Moq.Sdk
{
/// <summary>
/// An <see cref="IStuntBehavior"/> that keeps track of backing delegates
/// An <see cref="IAvatarBehavior"/> that keeps track of backing delegates
/// for events, combining and removing handlers from them as += and -=
/// are invoked on the mock. Also raises events when an <see cref="EventRaiser"/>
/// exists in the <see cref="CallContext"/>.
/// </summary>
public class EventBehavior : IStuntBehavior
public class EventBehavior : IAvatarBehavior
{
/// <summary>
/// Determines whether the given invocation is an event
Expand Down
Loading