Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#20 added JustMock, but currently running into issues during testing … #21

Merged
merged 3 commits into from
Oct 17, 2021
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
1 change: 1 addition & 0 deletions BenchmarkMockNet/BenchmarkMockNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
<PackageReference Include="JustMock" Version="2021.3.915.1" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="NSubstitute" Version="4.2.2" />
<PackageReference Include="FakeItEasy" Version="7.2.0" />
Expand Down
12 changes: 12 additions & 0 deletions BenchmarkMockNet/Benchmarks/Callback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Moq;
using NSubstitute;
using Rocks;
using JustMock = Telerik.JustMock.Mock;

namespace BenchmarkMockNet.Benchmarks
{
Expand All @@ -27,6 +28,17 @@ public override bool FakeItEasy()
return called;
}

[Benchmark]
public override bool JustMockLite()
{
JustMock.Reset();
var called = false;
var thing = JustMock.Create<IThing>();
JustMock.Arrange(() => thing.DoSomething()).DoInstead(() => called = true);
thing.DoSomething();
return called;
}

[Benchmark]
public override bool Moq()
{
Expand Down
10 changes: 9 additions & 1 deletion BenchmarkMockNet/Benchmarks/Construction.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Attributes;
using BenchmarkMockNet.PCLMock;
using FakeItEasy;
using Moq;
using NSubstitute;
using Rocks;
using JustMock = Telerik.JustMock.Mock;

namespace BenchmarkMockNet.Benchmarks
{
Expand All @@ -15,6 +16,13 @@ public class Construction : MockingBenchmark<IThing>
[Benchmark]
public override IThing FakeItEasy() => A.Fake<IThing>();

[Benchmark]
public override IThing JustMockLite()
{
JustMock.Reset();
return JustMock.Create<IThing>();
}

[Benchmark]
public override IThing Moq() => new Mock<IThing>().Object;

Expand Down
9 changes: 9 additions & 0 deletions BenchmarkMockNet/Benchmarks/EmptyMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Moq;
using NSubstitute;
using Rocks;
using JustMock = Telerik.JustMock.Mock;

namespace BenchmarkMockNet.Benchmarks
{
Expand All @@ -23,6 +24,14 @@ public override void FakeItEasy()
fake.DoNothing();
}

[Benchmark]
public override void JustMockLite()
{
JustMock.Reset();
var thing = JustMock.Create<IThing>();
thing.DoNothing();
}

[Benchmark]
public override void Moq()
{
Expand Down
9 changes: 9 additions & 0 deletions BenchmarkMockNet/Benchmarks/EmptyReturn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Moq;
using NSubstitute;
using Rocks;
using JustMock = Telerik.JustMock.Mock;

namespace BenchmarkMockNet.Benchmarks
{
Expand All @@ -23,6 +24,14 @@ public override int FakeItEasy()
return fake.Zero();
}

[Benchmark]
public override int JustMockLite()
{
JustMock.Reset();
var thing = JustMock.Create<IThing>();
return thing.Zero();
}

[Benchmark]
public override int Moq()
{
Expand Down
9 changes: 9 additions & 0 deletions BenchmarkMockNet/Benchmarks/OneParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Moq;
using NSubstitute;
using Rocks;
using JustMock = Telerik.JustMock.Mock;

namespace BenchmarkMockNet.Benchmarks
{
Expand All @@ -23,6 +24,14 @@ public override void FakeItEasy()
fake.OneParameter(0);
}

[Benchmark]
public override void JustMockLite()
{
JustMock.Reset();
var thing = JustMock.Create<IThing>();
thing.OneParameter(0);
}

[Benchmark]
public override void Moq()
{
Expand Down
10 changes: 10 additions & 0 deletions BenchmarkMockNet/Benchmarks/Return.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Moq;
using NSubstitute;
using Rocks;
using JustMock = Telerik.JustMock.Mock;

namespace BenchmarkMockNet.Benchmarks
{
Expand All @@ -24,6 +25,15 @@ public override int FakeItEasy()
return fake.One();
}

[Benchmark]
public override int JustMockLite()
{
JustMock.Reset();
var thing = JustMock.Create<IThing>();
JustMock.Arrange(() => thing.One()).Returns(1);
return thing.One();
}

[Benchmark]
public override int Moq()
{
Expand Down
11 changes: 11 additions & 0 deletions BenchmarkMockNet/Benchmarks/Verify.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Moq;
using NSubstitute;
using Rocks;
using JustMock = Telerik.JustMock.Mock;
using Times = Moq.Times;

namespace BenchmarkMockNet.Benchmarks
Expand All @@ -27,6 +28,16 @@ public override void FakeItEasy()
A.CallTo(() => fake.DoSomething()).MustHaveHappened();
}

[Benchmark]
public override void JustMockLite()
{
JustMock.Reset();
var thing = JustMock.Create<IThing>();
JustMock.Arrange(() => thing.DoSomething());
thing.DoSomething();
JustMock.Assert(thing);
}

[Benchmark]
public override void Moq()
{
Expand Down
4 changes: 3 additions & 1 deletion BenchmarkMockNet/IMockingBenchmark.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
namespace BenchmarkMockNet
namespace BenchmarkMockNet
{
public interface IMockingBenchmark<out T>
{
T Stub();
T JustMockLite();
T Moq();
T NSubstitute();
T FakeItEasy();
Expand All @@ -13,6 +14,7 @@ public interface IMockingBenchmark<out T>
public interface IMockingBenchmark
{
void Stub();
void JustMockLite();
void Moq();
void NSubstitute();
void FakeItEasy();
Expand Down
4 changes: 3 additions & 1 deletion BenchmarkMockNet/MockingBenchmark.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;

namespace BenchmarkMockNet
Expand All @@ -13,6 +13,7 @@ public abstract class MockingBenchmark<T> : IMockingBenchmark<T>
public abstract T Rocks();
public abstract T Stub();
public abstract T PCLMock();
public abstract T JustMockLite();
}

[MemoryDiagnoser]
Expand All @@ -25,5 +26,6 @@ public abstract class MockingBenchmark : IMockingBenchmark
public abstract void FakeItEasy();
public abstract void Rocks();
public abstract void PCLMock();
public abstract void JustMockLite();
}
}