Пример #1
0
        public void ExecutionLogger_LogExecutionCompleted_ExecutionSucceeded()
        {
            var mockExecutionHistory = new Mock <IExecutionHistory>();

            var mockSerializer = new Mock <ISerializer>();

            mockSerializer.Setup(o => o.Serialize(It.IsAny <AuditCommand>())).Verifiable();

            var mockWebSocketPool    = new Mock <IWebSocketPool>();
            var mockWebSocketWrapper = new Mock <IWebSocketWrapper>();

            mockWebSocketWrapper.Setup(o => o.SendMessage(It.IsAny <byte[]>())).Verifiable();
            mockWebSocketPool.Setup(o => o.Acquire(Dev2.Common.Config.Auditing.Endpoint)).Returns(mockWebSocketWrapper.Object).Verifiable();
            mockWebSocketPool.Setup(o => o.Release(It.IsAny <IWebSocketWrapper>())).Verifiable();

            var executionLogger = new ExecutionLogger(mockSerializer.Object, mockWebSocketPool.Object);

            executionLogger.ExecutionSucceeded(mockExecutionHistory.Object);

            mockSerializer.Verify(o => o.Serialize(It.IsAny <AuditCommand>()), Times.Once);
            mockWebSocketWrapper.Verify(o => o.SendMessage(It.IsAny <byte[]>()), Times.Once);
            mockWebSocketPool.Verify(o => o.Acquire(Dev2.Common.Config.Auditing.Endpoint), Times.Once);
            mockWebSocketPool.Verify(o => o.Release(It.IsAny <IWebSocketWrapper>()), Times.Once);
        }