public void VerifyOneCallTo_action_should_work() { var exp = _mock.Expression(m => m.WithInt(2)); _test.WithInt(2); AssertExceptionNotThrown.WhenExecuting(() => _mock.VerifyOneCallTo(exp)); _test.WithInt(2); AssertExceptionMessageContaining("once, but was 2 times", () => _mock.VerifyOneCallTo(exp)); }
public void Any_Int_should_work() { ForTest.Scenarios(1, 2) .TestEach(scenario => { _mock.ResetCalls(); _test.WithInt(scenario); _mock.VerifyOneCallTo(x => x.WithInt(Any.Int)); }); }
public void Any_Int_should_work() { ForTest.Scenarios(1, 2) .TestEach(scenario => { _mock.Invocations.Clear(); _test.WithInt(scenario); _mock.Verify(x => x.WithInt(Any.Int), Times.Once); }); }
public void Where_extension_with_action_should_work() { _test.WithInt(7); AssertExceptionNotThrown.WhenExecuting(() => _mock.Verify(x => x.WithInt(It.Is <int>(i => i > 6)), Times.Once)); AssertExceptionNotThrown.WhenExecuting(() => _mock.Verify(x => x.WithInt(Any.Int.Where(i => Assert.IsTrue(i > 6))), Times.Once)); AssertExceptionThrown .OfType <AssertFailedException>() .WithMessageContaining("Assert.AreEqual failed. Expected:<3>. Actual:<7>") .WhenExecuting(() => _mock.Verify(x => x.WithInt(Any.Int.Where(i => Assert.AreEqual(3, i))), Times.Once)); AssertExceptionThrown .OfType <MockException>() .WithMessageContaining("once, but was 0 times") .WhenExecuting(() => _mock.Verify(x => x.WithString(Any.String.Where(s => s.Contains("x"))), Times.Once)); }