Ejemplo n.º 1
0
        public void ServiceConnectorSendMessageTest()
        {
            // arrange
            IServiceConnector serviceConnector = ServiceConnector.GetInstance();

            serviceConnector.SetAddress("http://localhost:5000/");
            serviceConnector.TrySetUsername("testUser", out var testUser);

            // act
            var result = serviceConnector.SendMessage(_adminUserId, "Hallo test");

            // assert
            Assert.IsNotNull(result);
        }
Ejemplo n.º 2
0
        public void ServiceConnectorSendMessageAndGetMessageTest()
        {
            // arrange
            IServiceConnector serviceConnector = ServiceConnector.GetInstance();

            serviceConnector.SetAddress("http://localhost:5000/");
            serviceConnector.TrySetUsername("testUser", out _);

            // act
            serviceConnector.SendMessage(_adminUserId, "Hallo test");
            var result = serviceConnector.GetMessages(_adminUserId);

            // assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Any());
            Assert.AreEqual("Hallo test", result.Last().Text);
        }
Ejemplo n.º 3
0
        private void SendMessageButton_OnClick(object sender, RoutedEventArgs e)
        {
            var player = PlayersListView.SelectedItem as Player;

            if (player == null)
            {
                return;
            }

            var message = new PlayerMessage
            {
                Message    = MessageContentTextBox.Text,
                SenderId   = _myId,
                ReceiverId = player.Id
            };

            _messages.Add(message);
            _serviceConnector.SendMessage(message.ReceiverId.ToString(), message.Message);
            MessageContentTextBox.Text = "";
        }