Skip to content

Instantly share code, notes, and snippets.

@Kralizek
Last active February 19, 2018 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kralizek/1434867d7ca4018c7c5a92e4951b22a8 to your computer and use it in GitHub Desktop.
Save Kralizek/1434867d7ca4018c7c5a92e4951b22a8 to your computer and use it in GitHub Desktop.
AutoFakeItEasy live testing
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoFixture.AutoFakeItEasy" Version="4.1.0" />
<PackageReference Include="FakeItEasy" Version="4.4.0" />
<PackageReference Include="nunit" Version="3.9.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
</ItemGroup>
</Project>
using AutoFixture;
using AutoFixture.AutoFakeItEasy;
using Fakable;
using NUnit.Framework;
namespace Fakable
{
public interface IFakable
{
string ShouldntBeHere { get; }
void DefinitelyShouldBeHere(string testValue);
}
}
namespace Tests
{
public class Tests
{
private IFixture fixture;
[SetUp]
public void Setup()
{
fixture = new Fixture();
fixture.Customize(new AutoFakeItEasyCustomization());
}
[Test]
public void Test1()
{
var fakable = fixture.Create<IFakable>();
Assert.That(fakable.ShouldntBeHere, Is.Not.Null);
}
[Test]
public void Test2()
{
var fakable = fixture.Create<IFakable>();
var message = fixture.Create<string>();
fakable.DefinitelyShouldBeHere(message);
Assert.Pass();
}
}
}
@Kralizek
Copy link
Author

C:\Development\Tests\AutoFakeItEasyOneFile> dotnet test
Build started, please wait...
Build completed.

Test run for C:\Development\Tests\AutoFakeItEasyOneFile\bin\Debug\netcoreapp2.0\AutoFakeItEasyOneFile.dll(.NETCoreApp,Version=v2.0)
Microsoft (R) Test Execution Command Line Tool Version 15.5.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
NUnit Adapter 3.9.0.0: Test execution started
Running all tests in C:\Development\Tests\AutoFakeItEasyOneFile\bin\Debug\netcoreapp2.0\AutoFakeItEasyOneFile.dll
NUnit3TestExecutor converted 2 of 2 NUnit test cases
NUnit Adapter 3.9.0.0: Test execution complete

Total tests: 2. Passed: 2. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 1,3801 Seconds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment