Exemple #1
0
        [Test] public void captureCurrentUser()
        {
            Assert.IsTrue(webServices.Capture_CurrentUser);

            webServices.Ping(10.randomLetters());

            Assert.IsNull(webServices.captureCurrentUser());

            //login
            Assert.NotNull(tfWebServices.login_As_Admin());

            var currentUser        = webServices.Current_User();
            var userName           = currentUser.UserName;
            var userId             = currentUser.UserId;
            var currentUser_as_Xml = currentUser.toXml();

            Assert.IsNotNull(currentUser);
            Assert.AreEqual(currentUser_as_Xml, webServices.getResponseData <TM_User>().toXml());

            Assert.IsNotNull(webServices.Cached_CurrentUser);
            Assert.AreEqual(currentUser_as_Xml, webServices.Cached_CurrentUser.toXml());

            //if the currentUserCapture is enabled these methods should work
            Assert.IsTrue(webServices.RBAC_IsAdmin());
            Assert.AreEqual(webServices.Current_User().toXml(), currentUser_as_Xml);
            Assert.AreEqual(webServices.GetUser_byName(userName).toXml(), currentUser_as_Xml);
            Assert.AreEqual(webServices.GetUser_byID(userId).toXml(), currentUser_as_Xml);
            Assert.IsNotEmpty(webServices.GetUser_AuthTokens(userId));

            //logout
            Assert.IsTrue(webServices.logout());
            Assert.IsNull(webServices.Cached_CurrentUser);
            Assert.IsNull(webServices.Current_User());
            Assert.IsNull(webServices.Cached_CurrentUser);

            //after logout these should throw an exception (or not work)
            Assert.Throws <SoapException>(() => webServices.GetUser_byName(userName).toXml());
            Assert.Throws <SoapException>(() => webServices.GetUser_byID(userId).toXml());
            Assert.Throws <SoapException>(() => webServices.GetUser_AuthTokens(userId));
        }
 [SetUp] public void setup()
 {
     Assert.IsTrue(webServices.logout());
 }