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 exception method does not have an implementation

I have an ordinary unit test and try to create a fake of an interface in the setup-method: [TestInitialize] public void Setup() { var unityContainer = A.Fake(); var addTagAction = A.Fake(); …
xeraphim
  • 4,375
  • 9
  • 54
  • 102
0
votes
1 answer

AutoFake The specified object is not recognized as a fake object. issue when try stubing sut's method

I have encountered an issue that is related with mocking sut object's own method like following. AutoFake FakeResolver = new AutoFake(); ProductQueryService _sut = FakeResolver.Resolve(); // stubing another virtual method in the…
0
votes
1 answer

FakeItEasy: Mocking MessageBox

I need to avoid(mock) unit testing of line of code displaying messagebox using FakeItEasy framework. Code is here, public class XYZ { public static int nValue = 0; public void AddInetegers(int i) { int j = i * 100; int…
Sujeet Singh
  • 165
  • 3
  • 13
0
votes
0 answers

While i am using A.CallTo() method of FakeItEasy and using not a fake object inside it. It's throwing exception:

Below code throwing exception at run time: A.CallTo(() => myObject.Add(dummyobject)).Returns(result); below is the exception: Object 'myObject' of type 'classType' not recognized as a fake object.' where i can not create fake object of…
Gaurav Panwar
  • 974
  • 10
  • 11
0
votes
1 answer

FakeItEasy fake instansiation of a Poco class

I have a class: public class WeekCompareModel { public WeekData Week1 {get; set;} public WeekData Week1 {get; set;} } This object is created like this: var model = new WeekCompareModel { Week1 = Repo.FirstOrDefault(x => x.Typ ==…
h3li0s
  • 613
  • 9
  • 25
0
votes
2 answers

Want to test a function that takes a lambda as input parameter. I use fakeiteasy

The function that I want to test: string theText = _resourceManager.GetString(x => x.TheKeyAsString); The template is a class containing textrexources. TheKeyAsString is a string that is the Key for…
0
votes
1 answer

Testing WebAPI 2 Controllers with FakeItEasy not working as expected

I am using xUnit and trying to unit test my WebAPI controller below: public IHttpActionResult Post(UserSearchRequest userSearchRequest) { int? numberOfRecords; var users = this._userRepository.Search(userSearchRequest, out…
VasilisP
  • 136
  • 2
  • 11
0
votes
1 answer

How to query for linked notes?

I've got a method that will link an annotation to a sales order: /// Links. /// Unique identifier for the note. /// Unique identifier for the…
Alex Gordon
  • 57,446
  • 287
  • 670
  • 1,062
0
votes
1 answer

Converting an MOQ property setup to FakeItEasy

In one of the "builders" we have following method that uses MOQ SetupGet. I tried re-writing it to use FakeItEasy, but there does not seem to be a way to do it, as WithReturnType provides only generic version, where type has to be known up…
epitka
  • 17,275
  • 20
  • 88
  • 141
0
votes
1 answer

is ther a way to fake the Uri class

I ma writing unit testcases using NUnit and Fake it Easy for MVC4 Controllers. In one of the controller, I should be getting exception. ExceptionDetail exception = new ExceptionDetail() { Description = "Test", ErrorCode =…
AMDI
  • 895
  • 2
  • 17
  • 40
0
votes
0 answers

how to setup Fake controller context and httpsession

I am using NUnit and Fake it easy. I am planning to Setup which can be reusable across the project. here is my setupCode: IClient fake; SampleController sController; [SetUp] public void Setup() { sController = new SampleController(); fake =…
AMDI
  • 895
  • 2
  • 17
  • 40
0
votes
1 answer

facing issue while tring to fake method in class

Here is my controller test class method which will initialize fake class public void InitializeFake() { fakeHttpSession = A.Fake(); fakeHttpContext = A.Fake(); nmsFake =…
AMDI
  • 895
  • 2
  • 17
  • 40
0
votes
2 answers

Facing issue when trying to fake helper function

I am using Nunit and FakeItEasy for my MVC Controller functions. My Test Code: [Test] public async Task Search_Success() { if (!isFakeInitialized) InitializeFake(); url =…
AMDI
  • 895
  • 2
  • 17
  • 40
0
votes
1 answer

Random issue with argument constraints

I'm having a super weird issue when using FakeItEasy in my unit tests... I'm asserting whether a call has been made to a mock and I specify a constraint on one of the method's parameter, something like: A.CallTo(() =>…
ThomasWeiss
  • 1,292
  • 16
  • 30
0
votes
1 answer

What is the reason for mocking frameworks not throwing exceptions

In the example below FakeItEasy return 0 even though the IThing member GetValue() has not been defined. My question is; why is a value of 0 returned from an undefined member call and not an exception thrown; is there some general…
user152949