Example #1
0
        protected T ExpectMsgPf <T>(TimeSpan?timeout, string hint, TestKitBase probe, Func <object, T> function)
        {
            MessageEnvelope envelope;
            var             success = probe.TryReceiveOne(out envelope, timeout);

            if (!success)
            {
                Assertions.Fail(string.Format("expected message of type {0} but timed out after {1}", typeof(T), GetTimeoutOrDefault(timeout)));
            }
            var message = envelope.Message;

            Assertions.AssertTrue(message != null, string.Format("expected {0} but got null message", hint));
            //TODO: Check next line.
            Assertions.AssertTrue(function.GetMethodInfo().GetParameters().Any(x => x.ParameterType.IsInstanceOfType(message)), string.Format("expected {0} but got {1} instead", hint, message));
            return(function.Invoke(message));
        }