When I try to run the tests, I get a message saying that the tests are not loaded or are disabled. I cannot see how to enable or activate the test code that has been created.
This seems to be a common error when installing/using addon Nunit or Moq but I have yet to find a link that has a solution.
If you know how to solve this problem ...
We've been trying write unit tests for a worker class written in C#, which mocks out a third party API (COM based) using moq to dynamically create the mock objects. NUnit is our unit testing framework.
This third party component implements a couple of interfaces, but also needs to call back into our worker class using events. Our plan w...
At my job we are using Moq for mocking and Unity for an IOC container. I am fairly new to this and do not have many resources at work to help me out with determining the best practices I should use.
Right now, I have a group of repository interfaces (Ex: IRepository1, IRepository2... IRepository4) that a particular process needs to use ...
I am fairly new to TDD but have been using it for long enough to understand how to use mocks, stubs, dependency injection, inversion of control to solve 'similar' problems... but for some reason I feel very uneasy about using dependency injection and passing in an 'IThread' (or similar).
To give it some basic context - I am trying to ad...
I've just started to explore BDD for my current project. I'm using moq with mspec to get nice test outputs.
However, i can't find enough examples of what i'm trying to do, maybe i'm using the wrong approach or perhaps just don't understand the syntax enough, please advise.
The problem is i'm trying to verify whether a property has been ...
I'm just starting to practice BDD using the GWT approach to the following code exert and just realised that I can't do the second test.
My GWT goes something like
Given there exists an open query
When the user replies to the query
Then it should save the reply if the reply is not blank
Then it should notify the user and not save the ...
I am trying to test the following code
public void CleanUp()
{
List<ITask> tasks = _cleanupTaskFactory.GetTasks();
//Make sure each task has the task.Execute() method called on them
}
In my test I create a mocked implementation of _cleanupTaskFactory, and I want to stub the GetTasks() method to return a ty...
Is it possible to Mock a Linq Expression via Moq using a Generic class such as ~1Repository. ~IRepository being something that is injected via an IoC such as StructureMap or Windsor?
CODE TO TEST:
var person = _repository.Find<Person>()
.Where(p => p.Id == person.Id).SingleOrDefault();
TEST:
var rep...
Hi,
I'm trying to get Figure 3 Fake Database from IRepository using the example here
http://msdn.microsoft.com/en-us/magazine/dd263069.aspx
public class InMemoryRepository : IRepository
{
private readonly Cache<Type, object> _types;
private MockUnitOfWork _lastUnitOfWork;
public InMemoryRepository()
{
_types = n...
I am using Moq and I am sort of new to it.
I need to test a private method.
I have 2 assemblies.
CustomerTest.dll
CustomerBusiness.dll
So
CustomerTest dll has a class as follows:
[TestFixture]
public class CustomerTestFixture
{
var customerMock=new Mock<ICustomer>()
customerMock.Protected().S...
Hi everyone!
I'm using Moq & NUnit as a unit test framework.
I've written a method that is given a NetworkStream object as a parameter:
public static void ReadDataIntoBuffer(NetworkStream networkStream, Queue dataBuffer)
{
if ((networkStream != null) && (dataBuffer != null))
{
while (networkStream.DataAvailable)
{
...
Hi,
I have a private method that should return true.I m using Nunit and MOQ
So i have as follows:
[TestFixture]
public class CustomerTestFixture
{
var customerMock=new Mock<ICustomer>()
customerMock.Protected().Setup<bool>("CanTestPrivateMethod").Returns(true);
// How do I assert it now since I cannot...
I'm new to Moq, and just started on a project that's already in development. I'm responsible for setting up unit testing. There's a custom class for the DatabaseFactory that uses EnterpriseLibrary and looks like this:
public Database CreateCommonDatabase()
{
return CreateDatabaseInstance(string.Empty);
}
private static Database Creat...
Is it possible to modify an invocation parameter of a mocked method? In particular I'm looking to change buffer in the following example to a pre-populated byte array.
Example:
int MockedClass.Read(byte[] buffer, int offset, int count)
Explanation:
Calling Read loads count bytes reading from offset into the supplied byte array buffer.
...
Hi
I am trying to test a property that is nested in a child class.
I always get an error.
Am I missing something?
Is it possible to test a child property in moq.
I have the following
[Test]
public void Should_be_able_to_test_orderCollection()
{
var orderViewMock = new Mock<IOrderView>();
orderViewMock.SetupGet...
I'm brand new to unit testing and mocking and still wet behind the ears. I'm using the Moq framework and I need to mock a collection such that it yields a single member with a value I supply.
The collection class in question is a System.Configuration.SettingsPropertyCollection, which contains SettingsProperty objects.
In turn, the Sett...
When testing a class that uses a Moq dependency, I'd like the class to supply the arguments to a Moq method, rather than creating the arguments myself in the test case.
I have an interface, that has one method, which takes one argument.
public interface IMessageForwardProxy
{
IMessage Send(IMessage request);
}
I have a class that...
If I do this:
var repository = new Mock<IRepository<Banner>>();
repository.Setup(x => x.Where(banner => banner.Is.AvailableForFrontend())).Returns(list);
"Where" is a method on my repository that takes a Func<T, ISpecification<T>. AvailableForFrontend returns an implementation of ISpecification, and list is an IEnumberable of the gene...
If I have a method that calls itself under a certain condition, is it possible to write a test to verify the behavior? I'd love to see an example, I don't care about the mock framework or language. I'm using RhinoMocks in C# so I'm curious if it is a missing feature of the framework, or if I'm misunderstanding something fundamental, or i...
Hi
I'm trying to write a test for an ASP.Net MVC controller action.
I'd like to test that the action invokes a particular method on an injected service, so I'm mocking the service and using .Verify.
So in the simple case, I have the following action in my controller:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(st...