Questions tagged [fakeiteasy]

A .NET package to create fake objects, mocks, stubs for testing.

The following description is taken from the FakeItEasy homepage:

A .Net dynamic fake framework for creating all types of fake objects, mocks, stubs etc.

  • Easier semantics: all fake objects are just that — fakes. Usage determines whether they're mocks or stubs.
  • Context-aware fluent interface guides the developer
  • Easy to use and compatible with both C# and VB.Net.
359 questions
1
vote
1 answer

How to fake the object initiation using FakeItEasy?

Following is the code for which I want to write unit tests: public virtual ActionResult TryIt() { MemberViewModel viewModel = new MemberViewModel(); _memberViewModelLookupBuilder.PopulateSelectLists(viewModel); return…
Nirman
  • 6,715
  • 19
  • 72
  • 139
1
vote
1 answer

FakeItEasy - problems with new modifier

It appears that the following code doesn't behave as I would expect: using FakeItEasy; using Microsoft.VisualStudio.TestTools.UnitTesting; [TestClass] public class UnitTest1 { [TestMethod] public void TestMethod1() { var derived…
johnildergleidisson
  • 2,087
  • 3
  • 30
  • 50
1
vote
2 answers

Visual Studio tries to load FakeItEasy symbols from Z:\Builds\work

I was running a unit-test in Visual Studio today using FakeItEasy. I was offline and found the following symbol-loading to be happening and taking a long time: My question is, where does the path Z:\Builds\work\... come from and why is Visual…
Alexander Pacha
  • 9,187
  • 3
  • 68
  • 108
1
vote
1 answer

FakeItEasy: mocked method is not returning expected result

Im using FakeItEasy as mocking framework in my unit tests. Method fakeUserService.AddUser is mocked to returned new MwbeUser object with some non-empty values inside method AddUser A.CallTo(() => fakeUserService.AddUser(new…
P.K.
  • 1,746
  • 6
  • 25
  • 62
1
vote
1 answer

Fakeiteasy issue mocking soapclient

I'm trying to cover my business logic with unit tests using NUnit and fakeiteasy. But I suddenly stuck with faking calls to Soap client using fakeiteasy. I trying to do next thing var myFakedSoapClient = A.Fake(); var…
Maris
  • 4,608
  • 6
  • 39
  • 68
1
vote
1 answer

FakeItEasy: Get Arguments from protected method returning null

I am trying to test the argument passed in a protected virtual method to make sure the properties were set correctly. However the statement below is not setting my variable, but FakeItEasy does recognize that this call is being made. Is my syntax…
jmzagorski
  • 1,135
  • 18
  • 42
1
vote
1 answer

How to assert a fake object's method was called more than once using a different param for each call using FakeItEasy?

I am currently using FakeItEasy for unit testing. I'm faking NServiceBus .Send method call was made in a method. The problem I'm running across is I'm sending out two message on the bus in the method: bus.Send(new CommandOne(Id =…
Michael McCarthy
  • 1,502
  • 3
  • 18
  • 45
1
vote
1 answer

FakeItEasy - cannot fake ApplyAppPathModifier from HttpResponse

In my project we want to mock UrlHelper to test controller's actions. I found code that allows me to do it, unfortunately it's written in Moq: link There is a line, which i don't know hot to replace in FIE: response.Setup(s =>…
Radosław Maziarka
  • 655
  • 1
  • 6
  • 16
1
vote
2 answers

Assert that method was called in a unit test

I want to assert that a call on my real object (system under test) was called. Here is my test // Arrange var contextFactory = A.Fake(); var db = A.Fake(); A.CallTo(() => contextFactory.GetContext()).Returns(db); var vm =…
reggaeguitar
  • 1,795
  • 1
  • 27
  • 48
1
vote
1 answer

Trouble mocking return value of .Single() method in mocked repository

Scenario: I am learning how to unit test. Currently am working on tests for an mvc action method with nUnit and FakeItEasy. I have a test to verify that the method throws an exception if passed an id that doesn't exist. The action method calls a…
EF0
  • 2,940
  • 4
  • 17
  • 23
1
vote
2 answers

ASP.NET MVC FakeItEasy - Mocked session does not return correct value in unit test

I've mocked the Session-object in the MVC Controller using FakeItEasy by doing: var session = A.Fake(); A.CallTo(() => session["SomeKey"]).Returns("SomeValue"); Controller.ControllerContext = new…
AfroMogli
  • 577
  • 5
  • 18
1
vote
0 answers

Unit testing generic repository

I'm pretty new to unit testing and I'm having some problems with regards, to unit testing a generic repository in my application. I've implemented the unit of work pattern in my ASP.NET MVC application. My classes look like this: public class…
1
vote
1 answer

How do I find the underlying Type of a Fake object returned from FakeItEasy?

I've done fake1 = A.Fake() then I want to use 'reflection' on the fake to register the dependency with my dependency container as MyType. However, I'm having trouble figuring out how to get the underlying faked type. Any pointers?
Tim Lovell-Smith
  • 15,310
  • 14
  • 76
  • 93
1
vote
2 answers

How to use FakeItEasy to fake Enumerable class

I am learning to use/perform/write tests for my code and started using FakeItEasy for my fake/mock objects, now I have encountered a problem : I have the following class that implements IEnumerable and internal class that implements IEnumerator (not…
yshuki
  • 55
  • 1
  • 5
1
vote
0 answers

How can I add an Expression> as an interception to a faked object?

Is there an alternative way to intercept method calls in FakeItEasy if the method and arguments are already represented as an Expression>? Normally I would simply use IFoo foo = A.Fake(); A.CallTo(() => foo.SomeMethod("SomeString",…
thudbutt
  • 1,481
  • 1
  • 19
  • 32