You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if I make IInput not implementing IEnumerable, then NullRef does not occur.
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
[TestClass]
public class FooTest
{
[TestMethod]
public void ShouldCalculate()
{
var mocks = new MockRepository(MockBehavior.Loose);
var service = mocks.Create<IDependency>();
var input1 = mocks.OneOf<IInput>();
service.Setup(x => x.Run(input1)).Returns(1);
var input2 = mocks.OneOf<IInput>();
service.Setup(x => x.Run(input2)).Returns(2);
var foo = new Foo(service.Object);
foo.Calculate(input1);
foo.Calculate(input2);
}
}
public interface IDependency
{
decimal Run(IInput input);
}
public interface IInput : IEnumerable<int>
{
}
public class Foo
{
private readonly IDependency dependency;
public Foo(IDependency dependency)
{
this.dependency = dependency;
}
public void Calculate(IInput input)
{
this.dependency.Run(input);
}
}
The text was updated successfully, but these errors were encountered:
if I make IInput not implementing IEnumerable, then NullRef does not occur.
The text was updated successfully, but these errors were encountered: