public void EventDispatcherSendReceiveTest()
        {
            // Arrange
            var eventPublisher = new EventPublisher();
            var gameRoomEvent  = new GameRoomEventMock("Minor.WSA.GameRoom.Created");

            gameRoomEvent.GameRoomId   = 1;
            gameRoomEvent.GameRoomName = "Chess-01";

            using (var eventDispatcherMock = new EventDispatcherMock())
            {
                // Act
                eventPublisher.Publish(gameRoomEvent);

                Thread.Sleep(1000);

                // Assert
                Assert.AreEqual(1, eventDispatcherMock.GameRoomCreatedCalled);
                Assert.AreEqual(gameRoomEvent.GameRoomId, eventDispatcherMock.GameRoomEventMock.GameRoomId);
                Assert.AreEqual(gameRoomEvent.GameRoomName, eventDispatcherMock.GameRoomEventMock.GameRoomName);
                Assert.AreEqual(gameRoomEvent.TimeStamp, eventDispatcherMock.GameRoomEventMock.TimeStamp);
                Assert.AreEqual(gameRoomEvent.RoutingKey, eventDispatcherMock.GameRoomEventMock.RoutingKey);
                Assert.AreEqual(gameRoomEvent.CorrelationId, eventDispatcherMock.GameRoomEventMock.CorrelationId);
            }
        }
 public void EventDispatcherFindsDispatchMethods()
 {
     using (var result = new EventDispatcherMock())
     {
         Assert.Equal(2, result.DispatcherModel.Handlers.Count());
     }
 }
        public void EventDispatcherBusOptionsNotNullExpectGivenValuesTest()
        {
            // Arrange
            var expectedBusOptions = new BusOptions
            {
                ExchangeName = "Exchange",
                HostName     = "localhost",
                UserName     = "******",
                Password     = "******",
                QueueName    = "QueueName",
                Port         = 123987
            };

            // Act
            using (var eventDispatcher = new EventDispatcherMock(expectedBusOptions))
            {
                // Assert
                Assert.AreEqual(expectedBusOptions.ExchangeName, eventDispatcher.BusOptions.ExchangeName);
                Assert.AreEqual(expectedBusOptions.QueueName, eventDispatcher.BusOptions.QueueName);
                Assert.AreEqual(expectedBusOptions.HostName, eventDispatcher.BusOptions.HostName);
                Assert.AreEqual(expectedBusOptions.Port, eventDispatcher.BusOptions.Port);
                Assert.AreEqual(expectedBusOptions.UserName, eventDispatcher.BusOptions.UserName);
                Assert.AreEqual(expectedBusOptions.Password, eventDispatcher.BusOptions.Password);
            }
        }
Exemple #4
0
        public void AuditLogAgentSendEvents()
        {
            //Assert



            var agentOptions = new AuditLogAgentCommandOptions();


            using (var auditLog = new AuditLog())
            {
                var eventPublisher = new EventPublisher();
                var gameRoomEvent  = new GameRoomEventMock("Minor.WSA.GameRoom.Created");
                gameRoomEvent.GameRoomId   = 1;
                gameRoomEvent.GameRoomName = "Chess-01";

                eventPublisher.Publish(gameRoomEvent);



                using (var eventDispatcher = new EventDispatcherMock(auditLog))
                {
                    Thread.Sleep(1000);

                    //Act
                    eventDispatcher.UpdateFromAuditLog();
                    Thread.Sleep(1000);


                    //Assert
                    Assert.AreEqual(1, eventDispatcher.GameRoomCreatedCalled);
                }
            }
        }
    public void EventDispatcherDispatchesEvents()
    {
        using (var publisher = new EventPublisher())
            using (var target = new EventDispatcherMock())
            {
                target.Open();

                publisher.Publish(new TestEvent());

                Thread.Sleep(100);

                Assert.True(target.TestEventHandlerHasBeenCalled);
            }
    }
    public void EventDispatcherDispatchesEventWithCorrectTimestamp()
    {
        using (var publisher = new EventPublisher())
            using (var target = new EventDispatcherMock())
            {
                target.Open();

                var evt = new TestEvent();
                publisher.Publish(evt);

                Thread.Sleep(100);

                Assert.Equal(evt.Timestamp, target.SomeTimestamp);
            }
    }
    public void EventDispatcherDispatchesEventWithCorrectData()
    {
        using (var publisher = new EventPublisher())
            using (var target = new EventDispatcherMock())
            {
                target.Open();

                publisher.Publish(new AnotherEvent()
                {
                    SomeValue = 7
                });

                Thread.Sleep(100);

                Assert.Equal(7, target.SomeValue);
            }
    }
        public void EventDispatcherBusOptionsNullExpectDefaultTest()
        {
            // Arrange
            using (var eventDispatcher = new EventDispatcherMock())
            {
                // Act
                var expectedBusOptions = new BusOptions();

                // Assert
                Assert.AreEqual(expectedBusOptions.ExchangeName, eventDispatcher.BusOptions.ExchangeName);
                Assert.AreEqual(expectedBusOptions.HostName, eventDispatcher.BusOptions.HostName);
                Assert.AreEqual(expectedBusOptions.Port, eventDispatcher.BusOptions.Port);
                Assert.AreEqual(expectedBusOptions.UserName, eventDispatcher.BusOptions.UserName);
                Assert.AreEqual(expectedBusOptions.Password, eventDispatcher.BusOptions.Password);

                Assert.IsNotNull(eventDispatcher.BusOptions.QueueName);
            }
        }
Exemple #9
0
        public void AuditLogAgentOptionsTest()
        {
            //Assert
            var agentOptions = new AuditLogAgentCommandOptions();

            using (var auditLog = new AuditLog())
                using (var eventDispatcher = new EventDispatcherMock(auditLog))
                {
                    //Act
                    eventDispatcher.UpdateFromAuditLog();

                    //Assert

                    Assert.AreEqual(agentOptions.StartDate, eventDispatcher.AgentOptions.StartDate);
                    Assert.AreEqual(agentOptions.EndDate, eventDispatcher.AgentOptions.EndDate);
                    Assert.AreEqual(agentOptions.RoutingKeyFilter, eventDispatcher.AgentOptions.RoutingKeyFilter);
                }
        }
Exemple #10
0
        public void AuditLogAgentSendCommand()
        {
            //Assert
            var agentOptions = new AuditLogAgentCommandOptions();

            using (var auditLog = new AuditLog())
                using (var eventDispatcher = new EventDispatcherMock(auditLog))
                {
                    //Act
                    eventDispatcher.UpdateFromAuditLog();

                    Thread.Sleep(1000);

                    //Assert
                    Assert.AreEqual(1, auditLog.auditLogCommandsRecieved.Count);
                    Assert.AreEqual(agentOptions.StartDate, auditLog.auditLogCommandsRecieved.First().StartDate);
                    Assert.AreEqual(agentOptions.EndDate, auditLog.auditLogCommandsRecieved.First().EndDate);
                    Assert.AreEqual(agentOptions.RoutingKeyFilter, auditLog.auditLogCommandsRecieved.First().RoutingKeyFilter);
                }
        }