public void That_returns_true_if_expectation_is_not_met_by_async_selected_value(Parameter <CompositeParameter> parameter, IConstraint constraint, CompositeParameter testParameter) { Mock.Get(constraint).Setup(p => p.ApplyTo(It.IsAny <string>())).Returns((string value) => new ConstraintResult(constraint, value, false)); var mock = new Mock <IServiceWithCompositeParameter>(); mock.Setup(p => p.DoSomething(It.IsAny <CompositeParameter>())); var service = mock.Object; service.DoSomething(testParameter); Assert.That(() => mock.Verify(p => p.DoSomething(ParameterExtensions.That(parameter, p => p.GetString(), constraint))), Throws.InstanceOf <MockException>()); Mock.Get(constraint).Verify(p => p.ApplyTo(testParameter.StringProperty)); }
public void Assert_returns_true_if_expectation_is_met_by_selected_value(Parameter <CompositeParameter> parameter, IConstraint constraint, CompositeParameter testParameter) { Mock.Get(constraint).Setup(p => p.ApplyTo(It.IsAny <string>())).Returns((string value) => new ConstraintResult(constraint, value, true)); Mock.Get(constraint).Setup(p => p.Resolve()).Returns(constraint); var mock = new Mock <IServiceWithCompositeParameter>(); mock.Setup(p => p.DoSomething(It.IsAny <CompositeParameter>())); var service = mock.Object; service.DoSomething(testParameter); mock.Verify(p => p.DoSomething(ParameterExtensions.Assert(parameter, p => p.StringProperty, constraint))); Mock.Get(constraint).Verify(p => p.ApplyTo(testParameter.StringProperty)); }