Esempio n. 1
0
        public void SetNotificationInformationNominal()
        {
            GroundAppNotificationServiceStub trainService = new GroundAppNotificationServiceStub();
            string notificationAddressString  = "http://127.0.0.1:8200/";
            Uri    notificationServiceAddress = new Uri(notificationAddressString);

            using (SessionServiceStub sessionService = new SessionServiceStub(_sessionManager, _train2groundClientMock.Object, _notificationSender))
                using (ServiceHost host = new ServiceHost(trainService, notificationServiceAddress))
                {
                    try
                    {
                        host.Open();

                        Guid sessionId = sessionService.Login("admin", "admin");
                        Assert.AreNotEqual(Guid.Empty, sessionId, "login function of session service didn't returned a valid session id");
                        Assert.IsTrue(sessionService.IsSessionValid(sessionId), "session id returned by login function isn't valid");
                        Assert.IsTrue(sessionService.SetNotificationInformation(sessionId, notificationAddressString), "SetNotificationInformation of session service didn't succeeded as expected");

                        string storedUrl;
                        Assert.AreEqual(string.Empty, _sessionManager.GetNotificationUrlBySessionId(sessionId, out storedUrl), "GetNotificaitonUrlBySessionId didn't succeeded as expected");
                        StringAssert.AreEqualIgnoringCase(notificationAddressString, storedUrl, "SetNotificationInformation does not persist notification url as expected");
                        host.Close();
                    }
                    finally
                    {
                        if (host.State == CommunicationState.Faulted)
                        {
                            host.Abort();
                        }
                    }
                }
        }
Esempio n. 2
0
 public void LoginLogoutNominalTest()
 {
     using (SessionServiceStub sessionService = new SessionServiceStub(_sessionManager, _train2groundClientMock.Object, _notificationSender))
     {
         Guid sessionId = sessionService.Login("admin", "admin");
         Assert.AreNotEqual(Guid.Empty, sessionId, "login function of session service didn't returned a valid session id");
         Assert.IsTrue(sessionService.IsSessionValid(sessionId), "session id returned by login function isn't valid");
         Assert.IsTrue(sessionService.Logout(sessionId), "logout function failed while expecting not.");
         Assert.IsFalse(sessionService.IsSessionValid(sessionId), "session id still valid after logout");
     }
 }
Esempio n. 3
0
        public void SetNotificationInformationUrlNotResponding()
        {
            GroundAppNotificationServiceStub trainService = new GroundAppNotificationServiceStub();
            string notificationAddressString  = "http://127.0.0.1:8200/";
            Uri    notificationServiceAddress = new Uri(notificationAddressString);

            using (SessionServiceStub sessionService = new SessionServiceStub(_sessionManager, _train2groundClientMock.Object, _notificationSender))
            {
                Guid sessionId = sessionService.Login("admin", "admin");
                Assert.AreNotEqual(Guid.Empty, sessionId, "login function of session service didn't returned a valid session id");
                Assert.IsTrue(sessionService.IsSessionValid(sessionId), "session id returned by login function isn't valid");
                Assert.IsFalse(sessionService.SetNotificationInformation(sessionId, notificationAddressString), "SetNotificationInformation of session service didn't failed as expected");

                string storedUrl;
                Assert.AreEqual(string.Empty, _sessionManager.GetNotificationUrlBySessionId(sessionId, out storedUrl), "GetNotificaitonUrlBySessionId didn't succeeded as expected");
                StringAssert.AreEqualIgnoringCase(string.Empty, storedUrl, "SetNotificationInformation updated the notification url associated to the session while expecting not.");
            }
        }
Esempio n. 4
0
        public void SetNotificationInformationUrlRobustnessAfterFailure_atvcm00750190()
        {
            GroundAppNotificationServiceStub trainService = new GroundAppNotificationServiceStub();
            string notificationAddressInvalidString       = "http://" + _machineIP + ":8200/notexist";
            string notificationAddressString  = "http://" + _machineIP + ":8200/";
            Uri    notificationServiceAddress = new Uri(notificationAddressString);

            using (SessionServiceStub sessionService = new SessionServiceStub(_sessionManager, _train2groundClientMock.Object, _notificationSender))
            {
                Guid sessionId = sessionService.Login("admin", "admin");
                Assert.AreNotEqual(Guid.Empty, sessionId, "login function of session service didn't returned a valid session id");
                Assert.IsTrue(sessionService.IsSessionValid(sessionId), "session id returned by login function isn't valid");

                for (int i = 0; i < 6; ++i)
                {
                    Assert.IsFalse(sessionService.SetNotificationInformation(sessionId, notificationAddressInvalidString), "SetNotificationInformation succeeded with invalid url '{0}'", notificationAddressInvalidString);
                }
                using (ServiceHost host = new ServiceHost(trainService, notificationServiceAddress))
                {
                    try
                    {
                        host.Open();

                        Assert.IsTrue(sessionService.SetNotificationInformation(sessionId, notificationServiceAddress.ToString()), "SetNotificationInformation of session service didn't succeeded as expected");
                        host.Close();
                    }
                    finally
                    {
                        if (host.State == CommunicationState.Faulted)
                        {
                            host.Abort();
                        }
                    }
                }
            }
        }