Mock.NonPublic.Arrange(StaticClass,
"PrivatedMethod"
, Arg.IsAny<
object
>()).CallOriginal();
public static string MethodStaticA()
{
return MethodStaticB();
}
public static string MethodStaticB()
{
//Make something
}
Mock.SetupStatic(typeof(MfsUtils));
Mock.Arrange(() => MfsUtils.MethodStaticA()).Returns("MyString"); I can see in the logs that actually is calling to MethodStaticB() and I do not want to call it How can we properly mock this??
I thought that MustBeCalled would fail on the Assert in the following situation but the test passes (note, no call is made to the "MustBeCalled" method).
Public Class Foo
Public Shared Sub Bar()
Debug.Print("Wahoo!")
End Sub
End Class
<TestMethod()> _
Public Sub Foo_Test()
Mock.SetupStatic(GetType(Foo), Behavior.Strict)
Mock.Arrange(Sub() Foo.Bar()).MustBeCalled()
Mock.Assert(GetType(Foo))
End Sub
I am using version 2013.3.1119.2 of JustMock in Visual Studio 2012 and I have verified that the Profiler is enabled. If I don't arrange the Foo.Bar call, the test fails, as expected because the behavior is set to Strict. Is there another way to do the Arrange or Assert so that this works as expected?
// Both of these pass
Mock.Assert(() => mock.Foo(
null
,
null
), Args.Ignore(), Occurs.Never());
Mock.Assert(() => mock.Foo(
null
,
null
), Args.Ignore());
I have tried to use Just Mock with link expression that uses Update All and a Set statement but I keep getting the following error:
Source instance must be an OpenAccess LINQ expression, not an 'System.Linq.EnumerableQuery`1[[IveyCore.Member.MemberLogin, IveyCore, Version=2013.7.18.1916, Culture=neutral, PublicKeyToken=null]]'.
are there any examples of doing this?
public
interface
IFoo
{
IBar GetBar(
string
x);
}
public
interface
IBar
{
void
DoBar(
int
x);
}
public
class
Tests
{
[Fact]
public
void
First()
{
var foo = Mock.Create<IFoo>();
foo.GetBar(
"a"
).DoBar(1);
Mock.Assert(() => foo.GetBar(
"b"
).DoBar(1));
}
}