Пример #1
0
        static int Main()
        {
            ITypedSessionManagement target = null;
            P2000LoginReply p2000LoginReply = null;

            try
            {
                target = new SessionManagementService(Config.PegasysUrl);
                p2000LoginReply = target.P2000Login(Config.ValidSuperUserName, Config.ValidSuperUserPassword);

                TestRtl(p2000LoginReply.SessionInfo);
//                TestAlarmGetListEx(p2000LoginReply.SessionInfo);
            }
            catch(Exception e)
            {
                Console.WriteLine("EXCEPTION: " + e.Message);
            }

            if (target != null && p2000LoginReply != null)
            {
                target.P2000Logout(Config.ValidSuperUserName, p2000LoginReply.SessionInfo.SessionGuid);
            }

            Console.WriteLine("Press any key to continue...");
            Console.ReadLine();

            return 0;
        }
        [Ignore] // TODO: Move integration tests into a different project
        public void LogOnTest()
        {
            // Arrange
            ITypedSessionManagement target = new SessionManagementService(_config.PegasysUrl);

            // Act
            var p2000Reply = target.P2000Login(_config.ValidSuperUserName, _config.ValidSuperUserPassword);

            // Assert - nothing to do, just checking to make sure no exception thrown

            // Cleanup the Session
            target.P2000Logout(_config.ValidSuperUserName, p2000Reply.SessionInfo.SessionGuid);
        }
        [TestCategory("IntegrationTest")] // TODO: Move integration tests into a different project
        public void Login_VerifyP2000ReplyTest()
        {
            // Arrange
            ITypedSessionManagement target = new SessionManagementService(_config.PegasysUrl);

            // Act
            var p2000Reply = target.P2000Login(_config.ValidSuperUserName, _config.ValidSuperUserPassword);

            // Assert
            Assert.IsTrue(p2000Reply.UserDetails.Partitions.Length > 0);

            // Cleanup the Session
            target.P2000Logout(_config.ValidSuperUserName, p2000Reply.SessionInfo.SessionGuid);
        }
            public void UsernameNull_ArgumentExceptionIsThrown()
            {
                // Arrange
                var hbService = new SessionManagementService(_config.PegasysUrl);

                // Act + Assert
                ActionAssert.Throws<ArgumentException>(() => hbService.P2000SessionHeartbeat(null, "notwhitespace"), "userName");
            }
            public void InvalidUserInvalidSession_ThrowsException()
            {
                // Arrange
                var hbService = new SessionManagementService(_config.PegasysUrl);

                // Act + Assert
                ActionAssert.Throws<ServiceOperationException>(() => hbService.P2000SessionHeartbeat("not_a_real_user", "not_a_real_sessionid"));
            }
            public void SessionGuidWhitespace_ArgumentExceptionIsThrown()
            {
                // Arrange
                var hbService = new SessionManagementService(_config.PegasysUrl);

                // Act + Assert
                ActionAssert.Throws<ArgumentException>(() => hbService.P2000SessionHeartbeat("userName", "  "), "sessionGuid");
            }