Exemple #1
0
        public async Task ShouldHandleCommand()
        {
            var command = new ChangeLoggingLevelCommand
            {
                MinimumLevel = LogEventLevel.Error
            };

            var remoteCommand = new RemoteCommand
            {
                Name = typeof(ChangeLoggingLevelCommand).FullName,
                Data = JsonConvert.SerializeObject(command)
            };

            ChangeLoggingLevelCommand capturedCommand = null;

            _commandHandlerMock.Setup(m => m.Handle(It.IsAny <ChangeLoggingLevelCommand>())).Returns(Task.CompletedTask)
            .Callback <ChangeLoggingLevelCommand>(c => capturedCommand = c);

            var guid = await _messageHub.Handle(remoteCommand);

            _commandHandlerMock.Verify(m => m.Handle(It.IsAny <ChangeLoggingLevelCommand>()), Times.Once);
            Assert.IsNotNull(capturedCommand);
            Assert.AreEqual(LogEventLevel.Error, capturedCommand.MinimumLevel);
            Assert.IsNotNull(guid);
        }
Exemple #2
0
    public NetServerSystem(GameSettings gameSettings, MessageHub messageHub, Serializer serializer, SharedContext sharedContext) : base(
            Aspect.All())
    {
        this.gameSettings  = gameSettings;
        this.serializer    = serializer;
        this.sharedContext = sharedContext;

        var serverListener = CreateServerListener();

        netServer = new NetManager(serverListener)
        {
            UnconnectedMessagesEnabled = true,
            AutoRecycle             = true,
            BroadcastReceiveEnabled = true,
            DisconnectTimeout       = 60000
        };

        messageHub.Handle <StartServerRequest, bool>(HandleStartServer);
        messageHub.Subscribe <InputsUpdatedMessage>(HandleSendInputs);
        this.messageHub = messageHub;
    }