Moq (pronounced "Mock-you" or just "Mock") is a mocking framework for .NET that makes heavy use of lambdas and LINQ expression trees. This tag is specific to Moq version 3.0.
Questions tagged [moq-3]
36 questions
0
votes
1 answer
All Moq testCases pass without checking any logic?
I am following this intro to unit testing tutorial.
I have not implemented a logic to determine what credit score should return "Maybe", "Declined" but Moq test passes all the Unit Tests.
public interface ICreditDecisionService {
string…

DevelopZen
- 375
- 4
- 6
0
votes
1 answer
How to mock config file for unit test
I have a class in which there is a parameter less constructor. But when this constructor is called, there are five properties of the class that gets values from config file in the constructor. There are two method in the class which uses the…

Vicky
- 624
- 2
- 12
- 35
0
votes
1 answer
Want to bypass Microsoft.Practices.EnterpriseLibrary.Logging in MOQ test
I want to test my code which is depend on Microsoft logging and i want to mock it or by pass it. in this method i am validating the input.
it gives me below error "The LogWriter has not been set for the Logger static class. Set it invoking the…

yogs
- 23
- 1
- 9
0
votes
2 answers
C# mock not working in actual code
I currently have the following method with code:
public bool SendMail(ref MailData data)
SmtpClient smtpClient = this.smtpClient;
Console.WriteLine("SMTP CLIENT: " + smtpClient.ToString());
Console.WriteLine("SMTP PORT: " +…

gigha
- 41
- 1
- 10
0
votes
1 answer
MOQing a controller in MVC
I have the following controller
public class ProviderController : Controller
{
private static readonly IProviderRepository _repository = new ProviderRepository();
private static readonly Ilogger Logger = new Logger();
[HttpPost]
…

A NewBie
- 181
- 1
- 5
- 18
-2
votes
1 answer
Mocking BlobServiceClient using MOQ
In my implementation code, I am fetching accountname from BlobServiceClient object. However when I try to mock it using MOQ, I see the error below. Is there a way to get around this error?
storageClientMock = new…

Punter Vicky
- 15,954
- 56
- 188
- 315