Hey!
Mockito is the "official" mocking framework for I haven't seen any
samples of using Mockito in a practical example using injections.
In C#.net you could use moq to inject mocks into methods (not as a parameter).
For example:
In the class Repository.cs
namespace ObjectFactory
{
public class Repository
{
public object GetObject(string Type, string ID)
{
Duck d = new Duck(1, GetData(ID), "Black");
return d;
}
public virtual string GetData(string ID)
{
return "K";
}
}
}
In the class RepositoryTest.cs
using NUnit.Framework;
using Moq;
namespace ObjectFactory
{
[TestFixture]
public class RepositoryTest
{
[Test]
public void TestGetObject()
{
Duck d = new Duck(1, "Ducky", "Black");
var mock = new Mock<Repository>();
mock.Expect(x => x.GetData(It.IsAny<string>())).Returns("Ducky");
Duck getValue = (Duck)mock.Object.GetObject("Duck", "1");
Assert.AreEqual(getValue, d);
mock.Verify();
}
}
}
Instead of GetData returning "K" like it should, it returns "Ducky"
Is this possible using Mockito? If so, does anyone have an example?
Thanks,
Laura
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email