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
0
votes
1 answer

FakeItEasy to test domain services + UnitOfWork

I started doing some experimentation with unit testing so that we can include them in our domain layer. However i dont know if I'm following the right path, thus i'm going to explain what i'm currently doing to see if i'm on the right track.…
krafo
  • 183
  • 5
  • 20
0
votes
1 answer

variable casting error in c#

public CommandModule(ICommandFetcher fetcher,ICommandBus commandBus) { Post["/"] = parameters => { var commandRequest = this.Bind(); var command = fetcher.FetchFrom(commandRequest); …
user3044294
  • 205
  • 1
  • 15
0
votes
1 answer

Unable to set controller.Url property for simple test

I am trying to set the controller.Url property, but this test fails. I wrote this test because I could not test a controller action due to controller.Url being null. [TestMethod] public void AccountController_Url_ShouldNotBeNull() { var…
Rick Rat
  • 1,732
  • 1
  • 16
  • 32
0
votes
2 answers

FakeItEasy mock error inside method

I have a method I am trying to test and need to test if an error is thrown. If the employee repository throws an error, I want to make sure I get the EmployeeServiceError back. I am using the FakeItEasy mock framework. Here is the FakeItEasy…
Chance Robertson
  • 468
  • 1
  • 7
  • 15
0
votes
2 answers

How to assert a choice of calls with FakeItEasy

With FakeItEasy, how to assert, that any of calls has happened? The use case is I'm writing a class that works with a repository and as a result of a method, the class should remove some elements from the repository, either by calling DeleteAll, or…
voidengine
  • 2,504
  • 1
  • 17
  • 29
0
votes
1 answer

MustHaveHappened not being called when using IoC

I'm trying to test that a service call is made. I have an IAuthenticationService that makes an UpdateUserProfile call. The IAuthenticationService is in the IoC (StructureMap in my case). MustHaveHappened is returning 0 calls, but I know it happened…
AlignedDev
  • 8,102
  • 9
  • 56
  • 91
-1
votes
1 answer

How to mock a protected method of a non-fake class using FakeItEasy?

I'm trying to add FakeItEasy-based unit tests to a REST API controller of an ASP.NET core app. The public controller methods I need to test call the protected authorization methods implemented in the parent class that rely on the runtime data not…
Alek Davis
  • 10,628
  • 2
  • 41
  • 53
-1
votes
1 answer

when mocked method with ref parameter is used, assert MustHaveHappened fails

Im using FakeItEasy to mock methods for unit tests. One of method (using REF parameter - maybe this is important) saves data in database, so it's mocked as 'Does Nothing' A.CallTo(() => mockedUserRepository.Save(ref mwbeUserData)).DoesNothing(); .…
P.K.
  • 1,746
  • 6
  • 25
  • 62
-1
votes
1 answer

Unit Test Case for Private Methods and Properties using FakeItEasy

How to test private methods and properties using FakeItEasy Frame Work
pasupati
  • 57
  • 9
-1
votes
1 answer

ASP.NET MVC Unit test pattern design

Anybody can suggest some good guideline or pattern for design asp.net mvc unit test. I am new to mvc unit test framework design. I have checked Microsoft fake, Moq, Fakeiteasy. But more preferable is Microsoft fake. Can you please suggest any good…
Furqan Misarwala
  • 1,743
  • 6
  • 26
  • 53
-1
votes
1 answer

Visual Studio throwing an error on called async function from test code

I have the following code from AccountController.cs and I am attempting (at my mananger's instruction) to run a unit test against a portion of the login function that validates the ModelState. Here is the function: // // POST: /Account/Login …
Highspeed
  • 442
  • 3
  • 18
-2
votes
1 answer

FakeItEasy: how to unit test abstract class

I want to mock abstract class public method to returns different values. Is it doable using fakeiteasy? public class Worker: IInterface { private readonly ILogger _logger; provate readonly IServiceProvider _serviceProvider; public…
susanna
  • 1,395
  • 3
  • 20
  • 32
-2
votes
1 answer

Assert that Fun was invoked

Given the following class, how can I test that when MethodUnderTest is called, GetSomething is invoked? public class SystemUnderTest { private Foo foo; public string MethodUnderTest(int input) { return foo.Get(x =>…
Marshal
  • 6,551
  • 13
  • 55
  • 91
-2
votes
2 answers

FakeItEasy does not return expected value

I'm trying to test a method that takes a dictionary as a parameter, filters it by removing some unnecessary entries and returns the resulting dictionary. I have separately written the tests for the filtering class working correctly so this test is…
Karol Skrobot
  • 450
  • 3
  • 19
1 2 3
23
24