public void SingleSetValueThread()
 {
     try
     {
         CookieContainer cookieContainer = new CookieContainer();
         string          textToSet       = "valueSettedInSession" + (nBlock.ToString() + "-" + nCall.ToString());
         HttpWebRequest  request1        = (HttpWebRequest)WebRequest.Create(
             TestHelpers_v2_0.DEFAULT_WITH_HELPERS +
             TestHelpers_v2_0.SET_SESSION_VAL_STRING +
             textToSet),
                         request2 = (HttpWebRequest)WebRequest.Create(
             TestHelpers_v2_0.DEFAULT_WITH_HELPERS +
             TestHelpers_v2_0.PRINT_SESSION_VAL_STRING);
         TestHelpers_v2_0.DoRequest(request1, cookieContainer);
         string result = TestHelpers_v2_0.DoRequest(request2, cookieContainer);
         lock (_lockObj)
         {
             if ((_testOk) &&
                 (!result.Contains(string.Format("<sessionVal>{0}</sessionVal>", textToSet))))
             {
                 _testOk       = false;
                 _errorMessage = "Failed. Bad content" + Environment.NewLine + result;
             }
         }
     }
     catch (Exception e)
     {
         lock (_lockObj)
         {
             _testOk       = false;
             _errorMessage = "Http Exception" + e.Message;
         }
     }
 }
示例#2
0
        public void JSonObectWithList()
        {
            CookieContainer cookieContainer = new CookieContainer();
            HttpWebRequest  request1        =
                (HttpWebRequest)WebRequest.Create(
                    TestHelpers_v2_0.BASE_URL +
                    TestHelpers_v2_0.SET_SESSION_VAL_JSON_SERIALIZELIST),
                            request2 = (HttpWebRequest)WebRequest.Create(
                TestHelpers_v2_0.BASE_URL +
                TestHelpers_v2_0.PRINT_SESSION_VAL_JSON_SERIALIZELIST);

            TestHelpers_v2_0.DoRequest(request1, cookieContainer);
            string result             = TestHelpers_v2_0.DoRequest(request2, cookieContainer);
            string expectedResultPart = @"<fieldset>
        <legend>PersonPetsList</legend>

        <div class=""display-label"">
            Name
        </div>
        <div class=""display-field"">
            Marc
        </div>

        <div class=""display-label"">
            Surname
        </div>
        <div class=""display-field"">
            Cortada
        </div>

        <div class=""display-label"">
            City
        </div>
        <div class=""display-field"">
            Barcelona
        </div>
        <div class=""display-field"">
            Barcelona
        </div>        
        
        <div class=""display-field"">
            Dog
        </div>
        
        <div class=""display-field"">
            Cat
        </div>
        
        <div class=""display-field"">
            Shark
        </div>
        
    </fieldset>
";

            StringAssert.Contains(TestHelpers_v2_0.RemoveSpace(result), TestHelpers_v2_0.RemoveSpace(expectedResultPart));
        }
示例#3
0
        public void InitBlankValue()
        {
            CookieContainer cookieContainer = new CookieContainer();
            HttpWebRequest  request         =
                (HttpWebRequest)WebRequest.Create(TestHelpers_v2_0.BASE_URL + TestHelpers_v2_0.PRINT_SESION_ACTION);
            string result = TestHelpers_v2_0.DoRequest(request, cookieContainer);

            // Blank value is expected
            StringAssert.Contains(result, string.Format("<sessionVal>{0}</sessionVal>", ""));
        }
示例#4
0
        public void SingleSetValueFloat()
        {
            double          sesVal          = 3.1416F;
            CookieContainer cookieContainer = new CookieContainer();
            HttpWebRequest  request1        = (HttpWebRequest)WebRequest.Create(TestHelpers_v2_0.BASE_URL + TestHelpers_v2_0.SET_SESSION_VAL_DOUBLE),
                            request2        = (HttpWebRequest)WebRequest.Create(TestHelpers_v2_0.BASE_URL + TestHelpers_v2_0.PRINT_SESION_DOUBLE);

            TestHelpers_v2_0.DoRequest(request1, cookieContainer);
            string result = TestHelpers_v2_0.DoRequest(request2, cookieContainer);

            StringAssert.Contains(result, string.Format("<sessionVal>{0}</sessionVal>", sesVal.ToString("G")));
        }
示例#5
0
        public void SingleSetValueInt()
        {
            CookieContainer cookieContainer = new CookieContainer();
            int             intToSet        = 1;
            HttpWebRequest  request1        = (HttpWebRequest)WebRequest.Create(TestHelpers_v2_0.BASE_URL + TestHelpers_v2_0.SET_SESSION_VAL_INT + intToSet),
                            request2        = (HttpWebRequest)WebRequest.Create(TestHelpers_v2_0.BASE_URL + TestHelpers_v2_0.PRINT_SESION_ACTION);

            TestHelpers_v2_0.DoRequest(request1, cookieContainer);
            string result = TestHelpers_v2_0.DoRequest(request2, cookieContainer);

            StringAssert.Contains(result, string.Format("<sessionVal>{0}</sessionVal>", intToSet));
        }
示例#6
0
        public void SetValueStringTwice()
        {
            CookieContainer cookieContainer = new CookieContainer();
            string          textToSet1 = "valueSettedInSession", textToSet2 = "valueSettedInSession2";
            HttpWebRequest  request1 = (HttpWebRequest)WebRequest.Create(TestHelpers_v2_0.BASE_URL + TestHelpers_v2_0.SET_SESSION_ACTION + textToSet1),
                            request2 = (HttpWebRequest)WebRequest.Create(TestHelpers_v2_0.BASE_URL + TestHelpers_v2_0.SET_SESSION_ACTION + textToSet2),
                            request3 = (HttpWebRequest)WebRequest.Create(TestHelpers_v2_0.BASE_URL + TestHelpers_v2_0.PRINT_SESION_ACTION);

            TestHelpers_v2_0.DoRequest(request1, cookieContainer);
            TestHelpers_v2_0.DoRequest(request2, cookieContainer);
            string result = TestHelpers_v2_0.DoRequest(request3, cookieContainer);

            StringAssert.Contains(result, string.Format("<sessionVal>{0}</sessionVal>", textToSet2));
        }
示例#7
0
        public void SessionAbandon()
        {
            CookieContainer cookieContainer = new CookieContainer();
            string          textToSet1      = "valueSettedInSession";
            HttpWebRequest  request1        = (HttpWebRequest)WebRequest.Create(TestHelpers_v2_0.BASE_URL + TestHelpers_v2_0.SET_SESSION_ACTION + textToSet1),
                            request2        = (HttpWebRequest)WebRequest.Create(TestHelpers_v2_0.BASE_URL + TestHelpers_v2_0.PRINT_SESION_ACTION),
                            request3        = (HttpWebRequest)WebRequest.Create(TestHelpers_v2_0.BASE_URL + TestHelpers_v2_0.SESSION_ABANDON_ACTION),
                            request4        = (HttpWebRequest)WebRequest.Create(TestHelpers_v2_0.BASE_URL + TestHelpers_v2_0.PRINT_SESION_ACTION);

            TestHelpers_v2_0.DoRequest(request1, cookieContainer);
            string result = TestHelpers_v2_0.DoRequest(request2, cookieContainer);

            Assert.IsTrue(result.Contains(string.Format("<sessionVal>{0}</sessionVal>", textToSet1)));
            TestHelpers_v2_0.DoRequest(request3, cookieContainer);
            result = TestHelpers_v2_0.DoRequest(request4, cookieContainer);
            // The expected text after abandon is an empty string
            StringAssert.Contains(result, string.Format("<sessionVal>{0}</sessionVal>", ""));
        }
示例#8
0
        public void SingleSetValueBool()
        {
            CookieContainer cookieContainer = new CookieContainer();
            HttpWebRequest  request1        = (HttpWebRequest)WebRequest.Create(TestHelpers_v2_0.BASE_URL + TestHelpers_v2_0.SET_SESSION_VAL_BOOL + true),
                            request2        = (HttpWebRequest)WebRequest.Create(TestHelpers_v2_0.BASE_URL + TestHelpers_v2_0.PRINT_SESION_ACTION),
                            request3        = (HttpWebRequest)WebRequest.Create(TestHelpers_v2_0.BASE_URL + TestHelpers_v2_0.SET_SESSION_VAL_BOOL + false),
                            request4        = (HttpWebRequest)WebRequest.Create(TestHelpers_v2_0.BASE_URL + TestHelpers_v2_0.PRINT_SESION_ACTION);

            //Trying setting with true
            TestHelpers_v2_0.DoRequest(request1, cookieContainer);
            string result = TestHelpers_v2_0.DoRequest(request2, cookieContainer);

            StringAssert.Contains(result.ToUpper(), string.Format("<sessionVal>{0}</sessionVal>", "True").ToUpper());

            //Trying setting with false
            TestHelpers_v2_0.DoRequest(request3, cookieContainer);
            result = TestHelpers_v2_0.DoRequest(request4, cookieContainer);
            StringAssert.Contains(result.ToUpper(), string.Format("<sessionVal>{0}</sessionVal>", "False").ToUpper());
        }