Ejemplo n.º 1
0
        public void NetworkLogger_Fatal()
        {
            var mockAuditEntry = new Mock <IAuditEntry>();
            var logTemplate    = GlobalConstants.WarewolfLogsTemplate;

            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(Config.Auditing.Endpoint)).Returns(mockWebSocketWrapper.Object).Verifiable();
            mockWebSocketPool.Setup(o => o.Release(It.IsAny <IWebSocketWrapper>())).Verifiable();

            var networkLogger = new NetworkLogger(mockSerializer.Object, mockWebSocketPool.Object);

            networkLogger.Fatal(logTemplate, mockAuditEntry.Object);

            mockSerializer.Verify(o => o.Serialize(It.IsAny <AuditCommand>()), Times.Once);
            mockWebSocketWrapper.Verify(o => o.SendMessage(It.IsAny <byte[]>()), Times.Once);
            mockWebSocketWrapper.Verify(o => o.IsOpen(), Times.Once);
            mockWebSocketWrapper.Verify(o => o.Connect(), Times.Once);
            mockWebSocketPool.Verify(o => o.Acquire(Config.Auditing.Endpoint), Times.Once);
            mockWebSocketPool.Verify(o => o.Release(It.IsAny <IWebSocketWrapper>()), Times.Once);
        }
Ejemplo n.º 2
0
        public void NetworkLogger_Fatal()
        {
            var mockAuditEntry = new Mock <IAuditEntry>();
            var logTemplate    = GlobalConstants.WarewolfLogsTemplate;

            var mockSerializer = new Mock <ISerializer>();

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

            var dev2WorkflowSettings = new Mock <Dev2.Common.Interfaces.IDev2WorkflowSettings>();

            dev2WorkflowSettings.Setup(o => o.ExecutionLogLevel).Returns(LogLevel.FATAL.ToString);

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

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

            var networkLogger = new NetworkLogger(mockSerializer.Object, mockWebSocketPool.Object, dev2WorkflowSettings.Object);

            networkLogger.Fatal(logTemplate, mockAuditEntry.Object);

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