I have an interface with a method that expects an array of Foo:
public interface IBar {
void DoStuff(Foo[] arr);
}
I am mocking this interface using Mockito, and I'd like to assert that DoStuff() is called, but I don't want to validate what argument are passed - "don't care".
How do I write the following code using any(), the gener...
I am using VS2010 B2 and EF4 B2 and trying to use Rhino Mocks to mock the entity context generated by EEF.
var context = MockRepository.GenerateMock<SomeDBEntities>();
IObjectSet<TxMode> objectSet = new List<TxMode> { mode }.AsObjectSet();
context.Expect(c => c.TxModes).Return(objectSet);
The problem is that c.TxModes is a property of...
Hi all:
I'm using JsTestDriver and a bit of Jack (only when needed). Does anyone know how to verify that a javascript function has been called during unit testing?
E.g.
function MainFunction()
{
var someElement = ''; // or = some other type
anotherFunction(someElement);
}
And in the test code:
Test.prototype.test_mainFunct...
Hi ,
I'm trying to read the incoming request & set the mock response depending on a value comming in the request in soapUI 3.0. I use the following groovy script for this.
def typeElement = mockRequest.getContentElement().execQuery("//ProductType");
def records = new XmlParser().parseText(typeElement[0].xmlText())
if (records.text()==...
Hi,
I'm new to mocking, I have a method which takes a lambda as a parameter, how can I mock it using Rhino Mocks? Thanks.
...
I have TimeMachine class which provides me current date/time values. The class looks like this:
public class TimeMachine
{
public virtual DateTime GetCurrentDateTime(){ return DateTime.Now; };
public virtual DateTime GetCurrentDate(){ return GetCurrentDateTime().Date; };
public virtual TimeSpan GetCurrentTime(){ return GetCurrentDate...
I am using Moq - but could easily swap to another mock framework if needed.
I have a interface defined:
public interface IBaseEngineManagerImp
{
void SetClientCallbackSender(IClientCallbackSender clientCallbackSender);
}
I then mock IBaseEngineManagerImp with
mockEngineManagerImp = new Mock<IEngineManagerImp>();
EngineManager eng...
My application connects to db and gets tree of categories from here. In debug regime I can see this big tree object and I just thought of ability to save this object somewhere on disk to use in test stubs. Like this:
mockedDao = mock(MyDao.class);
when(mockedDao.getCategoryTree()).thenReturn(mySavedObject);
Assuming mySavedObject - is...
Not sure if it has been asked before, here is the question.
Code first:
public class Customer {
public string Password { get; set; }
public string PasswordHash { get; set; }
}
public class CustomerService {
private ICustomerRepository _repo;
public CustomerService(ICustomerRepository repo) {
_repo...
I am running TDD on an ASP.NET MVC web app.
Is it standard practice to create integration tests to demonstrate the correct instantiation of a type via the DI container (in my case Castle Windsor)?
If so, would you mock out the container, or simply use it as is?
Or... is this simply not done for some reason?
Thanks.
...
I have a static class that wraps some native methods from winspool:
public static class WinSpool
{
[DllImport("winspool.drv")]
public static extern int OpenPrinter(string pPrinterName, out IntPtr phPrinter, IntPtr pDefault);
...
//some more methods here
}
I would like to mock them for unit testing, but couldn't fin...
I have a switch statement in a factory that returns a command based on the value of the enum passed in. Something like:
public ICommand Create(EnumType enumType)
{
switch (enumType)
{
case(enumType.Val1):
return new SomeCommand();
case(enumType.Val2):
return new SomeCommand();
case(enumType.Val3...
I have just crafted the following test using Rhino mocks. Does my test look valid and make sense to those more experienced with mocking?
I am a a little confused that I haven't had to use the DynamicMock() or StrictMock() methods to create a seemingly valid test.
This test tests that the Add method was invoked on the supplied ICachingS...
Anybody know of a mocking framework that supports C# 4.0? Doesn't matter which one ATM, just need something that will work.
...
We have just released a re-written(for the 3rd time) module for our proprietary system. This module, which we call the Load Manager, is by far the most complicated of all the modules in our system to date. We are trying to get a comprehensive test suite because every time we make any kind of significant change to this module there is h...
I'm writing some code that integrates pretty tightly with lots of internal and sealed classes inside of System.Data ( like DbDataRecord and ObjectStateEntry ) for an EntityFramework project I'm working on. Of course the mocking frameworks fall to pieces trying to mock these things.
I still need to test these objects and AFAIK my only ...
I am trying to setup unit tests for my Linq To SQL code. My code uses the System.Data.Linq.Table class (generated by the designer).
Because this class is sealed and the constructor is internal it is completely impervious to unit testing frameworks like Rhino Mocks. (Unless you want to alter you code to use the repository pattern, whic...
I tried with NMock2 but I get TypeLoadExceptions when trying to pass the mocks into the constructor, also I saw TypeMock can do that but it costs 80$
...
I am working in an enterprise project and my team is responsible for creating front end of the application and there is another team developing webservices and has provided WSDL for all the services that will be available as part of this project. In development phase our local dev environment will point to one of the development box of t...
What is the best and easiest way to unit test a Class that uses LINQ to SQL and returns back a decimal, is it by Mocking? If so how do I go about this?
...