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 VB.NET issues with parameters

Ok, I am trying to teach myself testing using a mock framework and I work in VB.NET, I am new to lambda expressions and all my previous applications were written in version 2005 or earlier. I now have 2010. So I have tried Rhino.Mocks but found it…
Joe
  • 1
0
votes
1 answer

How to write the MSpec test for code containing calls to HttpContext using fakeiteasy?

I am getting the proverbial knickers in a twist. For this very simple code: public ActionResult Add() { this.HttpContext.Items["pm-page-title"] = "Some title"; return this.View(); } How do I go about writing the MSpec…
DavidS
  • 2,179
  • 4
  • 26
  • 44
0
votes
1 answer

MSpec and base class test failure while writing test for Asp.net mvc 3 controller

I am currently writing some MSpec specs for this controller which has already been implemented (yes I know doing it the "wrong" way round). It is a "simple" problem but I'm not sure what I'm doing wrong and hopefully someone will be able to point…
DavidS
  • 2,179
  • 4
  • 26
  • 44
0
votes
0 answers

Having trouble mocking methods on interfaces

Getting the following error trying to use CallTo() and .Returns() on methods of interfaces. Severity Code Description Project File Line Suppression State Error CS1929 'IReturnValueArgumentValidationConfiguration' does not contain a…
xofz
  • 5,600
  • 6
  • 45
  • 63
0
votes
1 answer

FakeItEasy mock interface not found

I'm new to FakeItEasy and mocking in general. I created a Visual Studio 2010 C# class library project. I added references to the NUnit DLL and the FakeItEasy DLL. I added "using" statements for both, then attempted to try some of the…
Buggieboy
  • 4,636
  • 4
  • 55
  • 79
0
votes
1 answer

How to fake an Interface method dynamically with FakeItEasy when testing ASP.NET Core controllers

Writing tests for CRUD controllers which follow this pattern. Get one or more parameters of various types from action method parameters Call some IEntityService.GetEntity(parameters from step 1) method If it returns null return NotFound Otherwise…
Alper
  • 663
  • 1
  • 7
  • 24
0
votes
1 answer

How to fake throwing an exception?

I have following setup A.CallTo(() => fakeChargeService .CreateAsync(A._, A._, A._)) .Throws((se) => stripeException); and then I assert var msg = await…
epitka
  • 17,275
  • 20
  • 88
  • 141
0
votes
2 answers

How to verify that there was no interaction with dependency in a test

I want my test to verify that there was no interaction with a dependency not just individual method or property. Is there a way to do that easily? Found answer here: What is the FakeItEasy equivalent of the Moq VerifyNoOtherCalls() method
epitka
  • 17,275
  • 20
  • 88
  • 141
0
votes
0 answers

How to assert method invocation?

Trying to verify that my service has been invoked. I don't care about the arguments, just that it was called once. I tried this A.CallTo(() => topicWriterFake.Write(A.Ignored, A.Ignored, A>.Ignored)) …
epitka
  • 17,275
  • 20
  • 88
  • 141
0
votes
0 answers

Mock Entity Framework models

I want to fake my complex object (an object with 5 objects properties) to test the post method in the controller. When I use FakeItEasy, I get the object with nulls, and I can't insert the object to the DbContext. So how can I fake this?…
0
votes
1 answer

In my test, the connection string is blank after the first call to the database. Why?

I'm using XUnit, FakeItEasy and Dapper. I'm testing a .NET Core 2.1 WebAPI call. When I spin up the actual web site, I have no errors. Something seems to be wrong with my test. For XUnit I'm using a DatabaseFixture like so: public class…
rball
  • 6,925
  • 7
  • 49
  • 77
0
votes
1 answer

testing private methods in the test classes

I am testing a class that has a method which is private and is internally called from a public method. I want to be able to fake this test method so that the actual method is never called. public class Service { public int MethodA(int a) { …
hussian
  • 399
  • 6
  • 19
0
votes
0 answers

How to set autoincrement Id in test with fake it easy

Scenario I have method in PreviewService.AddPreview. I would like to test it whether it add new Preview or not. I use C# and EntityFremework. How to program test to create id of Preview with autoincrementation? I know that I should have repository…
zolty13
  • 1,943
  • 3
  • 17
  • 34
0
votes
0 answers

FakeitEasy - EntityFramework

I am writing an unit test to test my EF project . while doing the test I am getting an error while configuraing the fake for the DBSet. My Call stack is System.NotImplementedException The member 'IQueryable.ElementType' has not been implemented on…
Dinesh
  • 193
  • 2
  • 14
0
votes
1 answer

How to test a CacheProvider

I have a Cache class as follows: public class MyCache : ICacheProvider { private readonly IMemoryCache _cache; private readonly MemoryCacheOptions _options; private readonly ILogger _logger; public…
DarthVader
  • 52,984
  • 76
  • 209
  • 300