示例#1
0
        protected void ToSnapshot <T>(IAfterExecutionResult result) where T : class
        {
            var returnValue = result.ReturnValue as T;
            var asJson      = JsonConvert.SerializeObject(returnValue, Formatting.Indented);

            Snapshots.Add($"{result.Rule.MethodName}", asJson);
        }
示例#2
0
        protected void AssertReturnValue(string forMethod, bool hasReturnValue, IAfterExecutionResult inResult)
        {
            _originalImplementation.Message.Should().Be($"Invoked: {forMethod}", because: "the method should have been invoked before the callback. ");

            inResult.Should().NotBeNull(because: "the callback should have been invoked with the return value result. ");
            using (var scope = new AssertionScope())
            {
                inResult.HasReturnValue.Should().Be(hasReturnValue, because: "a void method has no return value. ");
            }

            inResult.Rule.Should().NotBeNull(because: "the intercept rule should always be passed to the callback. ");
            inResult.Rule.MethodName.Should().Be(forMethod);
        }
示例#3
0
        protected void AssertReturnValueIsVoid(string forMethod, IAfterExecutionResult inResult)
        {
            AssertReturnValue(forMethod, false, inResult);

            inResult.ReturnValue.Should().BeNull(because: "by design, we ensure that a void method will return null; use HasReturnValue as a discriminator. ");
        }
示例#4
0
        protected void AssertReturnValue(string forMethod, int isValue, IAfterExecutionResult inResult)
        {
            AssertReturnValue(forMethod, hasReturnValue: true, inResult);

            inResult.ReturnValue.Should().Be(isValue, because: "that is the hard coded value returned from the method. ");
        }