コード例 #1
0
        public void SendTest()
        {
            LogItem message = new LogItem(category, level, msg, ids, GetException());
            var     qThread = new Mock <IQueued <LogItem> >(MockBehavior.Strict);
            var     writer  = new Mock <ILogWriter>(MockBehavior.Strict);

            qThread
            .Setup(s => s.Send(It.IsAny <LogItem>()));
            writer
            .Setup(s => s.GetTimeout())
            .Returns(timeout);
            qThread
            .Setup(s => s.SetTimeout(It.IsAny <int>()));

            LogCollector target = new LogCollector(qThread.Object, writer.Object);

            qThread
            .Verify(s => s.SetTimeout(It.Is <int>(a => a == timeout)));

            target.Send(message);

            qThread
            .Verify(s => s.Send(It.Is <LogItem>(i => i.Equals(message))), Times.Once());
        }