1

So I have this fake object definition, that has a fake method in it :

// Note: This is a simplified version of my code. 
// If it turns out that such issues could come from complex method prototypes, 
// then I'll post the full setup.

IFooRepositoryClass fooRepo = A.Fake<IFooRepositoryClass>();

A.CallTo(() => fooRepo.FooFunctionAsync(A<Guid>.Ignored).ReturnsLazily(
    (Guid fooId) => {
        fooInternalObject.DoSomething(fooId);
    }
);

As you can see, nothing out of the ordinary.

Later, in my XUnit tests, I call the fake function :

Guid testGuid = new Guid("aaaaaaaa-9a88-4746-914b-aaaaaaaaaaaa"); //I changed to "aaaaa" to make it easily recognizable
await fooRepo.FooFunctionAsync(testGuid).configureAwait(false);

I put a breakpoint on that instruction : await fooRepo.FooFunctionAsync(testGuid).configureAwait(false); ...I see that testGuid is indeed aaaaaaaa-9a88-4746-914b-aaaaaaaaaaaa

But then I put a breakpoint inside, on this instruction : fooInternalObject.DoSomething(fooId);

To my great surprise, fooId has a weird value with lots of zeros, different at each run!

f933b838-007b-0000-0000-000000000000

785bb288-001a-0000-0000-000000000000

4d4bb8d8-0012-0000-0000-000000000000 etc. As you can see it's not Guid.Empty, just Guids that look suspiciously manufactured.

What the hell is going on? Can FakeItEasy do that to Guids?

Even weirder : I shared my branch to a colleague, and he checked it out. So he has the exact same code as me. ...But for him, fooId has the expected value, i.e. the value of testGuid! We peeked at each other's screen and every execution conditions seem identical. Only the Guid differs at the breakpoint : Expected value for him, bogus values for me. I cleaned the solution, rebuilt, even restarted VS. to no avail!

What the hell is going on? x2

I'm not expecting anyone to fix my unit tests, but maybe this is a well-known behaviour under certain conditions. Ever seen that? Especially those weird 000000 Guid values? Something has to differ between our setups, but I need a lead to know where to look.

jeancallisti
  • 1,046
  • 1
  • 11
  • 21

0 Answers0