Skip to content

Instantly share code, notes, and snippets.

[Test]
public void GetAll_ReturnAccountsFromRepository()
{
//Arrange
var mockAccountRepository = A.Fake<IAccountReposiory>();
var accountManager = new AccountManager(mockAccountRepository);
//Build Expected
List<Account> expected = new List<Account>{};
@blairconrad
blairconrad / PiggybackArgumentValueFormatter.cs
Last active February 3, 2016 14:46
"Tests" that show FakeItEasy ArgumentValueFormatter behaviour and sort of a proposed interface to extend
namespace FakeItEasyQuestions
{
using FakeItEasy;
using NUnit.Framework;
public class ArgumentValueFormatterTests
{
public class NamedValue
{
public string Name;
@blairconrad
blairconrad / FixtureInitializationSample.cs
Last active August 29, 2015 14:21
FakeItEasy FixtureInitialization sample
public class FixtureInitializationSample
{
public interface IFoo
{
string Boo();
}
public class SystemUnderTest
{
private readonly IFoo foo;
### Keybase proof
I hereby claim:
* I am blairconrad on github.
* I am blairconrad (https://keybase.io/blairconrad) on keybase.
* I have a public key whose fingerprint is 6835 2E52 5E40 21AF 2203 A008 49C0 3357 06DA E5F6
To claim this, I am signing this object:
@blairconrad
blairconrad / gist:a8f90d9d8ea04cee5e84
Created October 13, 2014 11:12
26329057/fakeiteasy-throws-expectationexception - Blair's passing test
internal class JorgBTests
{
public interface IUser
{
string Username { get; }
}
internal class UserSignupRequest
{
public string Username { get; set; }
@blairconrad
blairconrad / IntTimesExtensions.cs
Created August 30, 2014 12:17
A slightly more fluent version of MustHaveHappend(Repeated.Exactly(times)). For https://github.com/FakeItEasy/FakeItEasy/issues/354
// Allows
// A.CallTo(() => fake.Add(A<object>._))
// .MustHaveHappened(2.Times());
//
// but then the ints all have a Times method on them.
public static class IntTimesExtensions
{
public static Repeated Times(this int i)
{
public class SomeClass
{
public virtual int Method(int arg1, int arg2)
{
return 7;
}
}
[TestFixture]
public class TestFixture
@blairconrad
blairconrad / FIE_1.19.0_startup.md
Last active August 29, 2015 13:59
FakeItEasy 1.19.0 startup time improvements

In case anyone is interested, the faster FakeItEasy 1.19.0 startup does indeed seem to be faster. I started using 1.19.0 at the Day Job today, and got these results for a test run in the IDE (ReSharper test runner):

shadow copies no shadow copies
1.18.0 5.9s 2.5s
1.19.0 0.86s 0.63s
@blairconrad
blairconrad / gist:8474567
Created January 17, 2014 14:47
Fun with encodings!
> var defaultEncoding = Encoding.Default;
> var myEncoding = Encoding.GetEncoding(defaultEncoding.CodePage, new EncoderReplacementFallback("?"), new DecoderReplacementFallback("?"));
> (int)(defaultEncoding.GetBytes("\u042E")[0]) // \u042E is "Ю" - Yu (Cyrillic)
63 // "?"
> (int)(myEncoding.GetBytes("\u042E")[0])
63
> (int)(defaultEncoding.GetBytes("\u99AC")[0]) // \u99AC is "馬" - Horse
63
> (int)(myEncoding.GetBytes("\u99AC")[0])
63