A mocking framework, used in unit tests for injecting "fake" implementations of interfaces as dependencies of the system under test. Use this tag for code reviews of unit testing methods that use this specific mocking framework.

learn more… | top users | synonyms

1
vote
1answer
59 views

Unit test with Moq callback anonymous function

I have the following unit test that is testing predicate logic in a repository (Note: mockOpportunityRepository.Setup): ...
5
votes
1answer
291 views

Service-Repository pattern with IoC, NPoco micro-ORM and unit tests

I'm trying to build a Web API using best practices, based on a simple proof-of-concept using students. My goal is to build the system using: Onion Architecture to seperate concerns. ...
2
votes
1answer
65 views

Mocking IElasticClient in unit tests

I'm trying to unit test how my class responds to a NEST 1.7 IElasticClient's return values, using NUnit 2.6.4 and Moq 4.2. I feel mocking the ...
4
votes
1answer
344 views

Unit testing with dependency injection and MOQ

I'm just learning how dependency injection and mocking work, but I'd like some feedback on how I'm setting up a couple of tests. I can get them to pass, but I'm not sure this is all I need. This is ...
2
votes
1answer
954 views

Same setup for many properties in Moq

I'm trying to use Moq to mock a rather large set of interfaces in an object. I'm trying to capture the behavior of retaining a dirty flag when properties are set and I'm hoping there is a cleaner way ...
5
votes
2answers
2k views

Using the builder pattern to build mock objects and nested builders

No, this question has no roosting construction workers. I'm not sure if what I'm doing is a good use of the builder pattern or whether its a bastardization of what its intended purpose was. I'm ...
6
votes
1answer
4k views

Unit tests using C#, Moq, AutoFixture, FluentAssertions

Could you give any suggestion on the following unit tests? How to make it more readable, maintainable and trustworthy. If it is not a problem - post some code with the suggestions. ...
2
votes
1answer
73 views

Multiple Services and Test Setup

Class To Test Some methods hidden for clarity ...
2
votes
2answers
283 views

Using MOQ in unit-testing for a shipping calculator

I am fairly new to writing unit tests, and I was wondering if this approach I have taken is on the right track? Given the following interfaces/classes: ...
4
votes
2answers
8k views

REST Web Api unit test endpoint validity with NUnit and Moq

I am unit testing that the URL that I give to my IRestClient is valid. This client talks to a third party Web API. The test is as below: ...
0
votes
1answer
255 views

Verify collection as a method parameter

How can I verify that ohterClassMock.MethodToTest() was called with contracts? That it was called with ...
3
votes
1answer
305 views
14
votes
3answers
1k views

Unit tests for testing error codes

Both unit tests pass and they both test the same thing. The production code uses the right error codes. System Under Test (SUT) ...
6
votes
2answers
807 views

Is this UnitTest for updating an object in data-access layer sensible?

I'm still trying to learn how to write good tests (and write testable code). This is the function I want to verify, ...
5
votes
1answer
3k views

Unit tests for methods that access the file system

Basically I have some methods that access the file system and to avoid that in the unit test I have broken those sections out into a protected virtual method. In the Unit Test I then use Moq to setup ...
0
votes
1answer
7k views

Mocking the class under test with private method calls

Consider the scenario below. It covers multiple methods of my unit under test. ...