Exemple #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);
        }
Exemple #2
0
        public void ServiceConnectorDeviceGetValueTest()
        {
            // arrange
            IServiceConnector serviceConnector = ServiceConnector.GetInstance();

            serviceConnector.SetAddress("http://localhost:5000/");
            // it must a non exist device
            const long id = 12345678L;
            // act
            var result = serviceConnector.DeviceGetValue(id);

            // assert
            Assert.AreEqual(0, result);
        }
Exemple #3
0
        public void ServiceConnectorGetAllUsersTest()
        {
            // arrange
            IServiceConnector serviceConnector = ServiceConnector.GetInstance();

            serviceConnector.SetAddress("http://localhost:5000/");

            // act
            var result = serviceConnector.GetAllUsers();

            // assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Any());
        }
Exemple #4
0
        public void ServiceConnectorGetMessagesTest()
        {
            // arrange
            IServiceConnector serviceConnector = ServiceConnector.GetInstance();

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

            // act
            var result = serviceConnector.GetMessages(_adminUserId);

            // assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Any());
            Assert.AreEqual("Hallo ich bin der Admin Benutzer", result.First().Text);
        }
Exemple #5
0
        public void ServiceConnectorSetUserAndGetAllUsersTest()
        {
            // arrange
            IServiceConnector serviceConnector = ServiceConnector.GetInstance();

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

            // act
            var result = serviceConnector.GetAllUsers();

            // assert
            Assert.IsNotNull(result);
            // only admin, well it show only other not self user
            Assert.AreEqual(1, result.Length);
        }
Exemple #6
0
        public void ServiceConnectorTrySetUsernameTest()
        {
            // arrange
            IServiceConnector serviceConnector = ServiceConnector.GetInstance();

            serviceConnector.SetAddress("http://localhost:5000/");
            const string username = "******";

            // act
            var success = serviceConnector.TrySetUsername(username, out var result);

            // assert
            Assert.IsTrue(success);
            Assert.IsNotNull(result);
            Assert.AreEqual(username, result.Username);
            Assert.AreNotEqual(0, result.ID);
        }
Exemple #7
0
        public void ServiceConnectorDeviceSendComandTextTest()
        {
            // arrange
            IServiceConnector serviceConnector = ServiceConnector.GetInstance();

            serviceConnector.SetAddress("http://localhost:5000/");
            serviceConnector.DeviceGetText(1L);
            string sendText = "Hello";

            // act
            var result     = serviceConnector.DeviceSendCommand(1L, sendText);
            var resultText = serviceConnector.DeviceGetText(1L);

            // assert
            Assert.IsTrue(result);
            Assert.AreEqual(sendText, resultText);
        }
Exemple #8
0
        public void ServiceConnectorDeviceSendComandValueTest()
        {
            // arrange
            IServiceConnector serviceConnector = ServiceConnector.GetInstance();

            serviceConnector.SetAddress("http://localhost:5000/");
            serviceConnector.DeviceGetValue(1L);
            const long value = 234L;

            // act
            var result      = serviceConnector.DeviceSendCommand(1L, 234);
            var resultValue = serviceConnector.DeviceGetValue(1L);

            // assert
            Assert.IsTrue(result);
            Assert.AreEqual(value, resultValue);
        }
Exemple #9
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);
        }
Exemple #10
0
        public void ServiceConnectorDeviceSendComandGetResponseTest()
        {
            // arrange
            IServiceConnector serviceConnector = ServiceConnector.GetInstance();

            serviceConnector.SetAddress("http://localhost:5000/");
            serviceConnector.DeviceGet(1L);
            const long id       = 1L;
            const long value    = 456L;
            string     sendText = "Hello";

            // act
            var result         = serviceConnector.DeviceSendCommand(id, value, sendText);
            var resultResponse = serviceConnector.DeviceGet(id);

            // assert
            Assert.IsTrue(result);
            Assert.AreEqual(sendText, resultResponse.Text);
            Assert.AreEqual(value, resultResponse.Value);
        }