Affecto.Logging.Tests.LoggerTests.AssertCall C# (CSharp) Method

AssertCall() private method

private AssertCall ( ICorrelation expectedCorrelation, LogEventLevel eventLevel, Exception exception, string formatMessage, object args ) : void
expectedCorrelation ICorrelation
eventLevel LogEventLevel
exception System.Exception
formatMessage string
args object
return void
        private void AssertCall(ICorrelation expectedCorrelation, LogEventLevel eventLevel, Exception exception, string formatMessage,
            object[] args)
        {
            Assert.AreEqual(1, logWriter.ReceivedCalls().Count());

            ICall call = logWriter.ReceivedCalls().First();
            object[] arguments = call.GetArguments();

            Assert.AreEqual(5, arguments.Length);

            if (expectedCorrelation == null)
            {
                Assert.IsNull(arguments[0]);
            }
            else
            {
                ICorrelation actualCorrelation = arguments[0] as ICorrelation;
                Assert.IsNotNull(actualCorrelation);

                if (!string.IsNullOrEmpty(expectedCorrelation.CallerId))
                {
                    Assert.AreEqual(expectedCorrelation.CallerId, actualCorrelation.CallerId);
                }

                if (!string.IsNullOrEmpty(expectedCorrelation.CorrelationId))
                {
                    Assert.AreEqual(expectedCorrelation.CorrelationId, actualCorrelation.CorrelationId);
                }
            }

            Assert.AreEqual(eventLevel, arguments[1]);
            Assert.AreEqual(exception, arguments[2]);
            Assert.AreEqual(formatMessage, arguments[3]);

            object[] messageParams = arguments[4] as object[];

            Assert.IsNotNull(messageParams);
            Assert.AreEqual(args.Length, messageParams.Length);

            for (int i = 0; i < messageParams.Length; i++)
            {
                Assert.AreEqual(args[i], messageParams[i]);
            }
        }