Exemplo n.º 1
0
        public void ComplexEnumStringsInts()
        {
            //Arrange
            int       vala  = 123;
            int       valb  = 545;
            string    valsa = "String1";
            string    valsb = "ZXCVFDSW";
            eLocateBy loc   = eLocateBy.ByName;

            PayLoad pl = new PayLoad("ComplexEnumStringsInts");

            pl.AddValue(vala);
            pl.AddValue(valb);
            pl.AddValue(valsa);
            pl.AddValue(valsb);
            pl.AddEnumValue(loc);
            pl.ClosePackage();

            // Act
            byte[] b = pl.GetPackage();

            PayLoad pl2    = new PayLoad(b);
            int     vala2  = pl2.GetValueInt();
            int     valb2  = pl2.GetValueInt();
            string  valsa2 = pl2.GetValueString();
            string  valsb2 = pl2.GetValueString();
            string  Loc2   = pl2.GetValueEnum();

            //Assert
            Assert.AreEqual(vala, vala2);
            Assert.AreEqual(valb, valb2);
            Assert.AreEqual(valsa, valsa2);
            Assert.AreEqual(valsb, valsb2);
            Assert.AreEqual(loc.ToString(), Loc2);
        }
Exemplo n.º 2
0
        public void ComplexStringWith2Ints()
        {
            //Arrange
            int    vala = 1237435;
            int    valb = -185;
            string vals = "Not so long String";

            PayLoad pl = new PayLoad("ComplexStringWith2Ints");

            pl.AddValue(vala);
            pl.AddValue(valb);
            pl.AddValue(vals);
            pl.ClosePackage();

            // Act
            byte[] b = pl.GetPackage();

            PayLoad pl2   = new PayLoad(b);
            int     vala2 = pl2.GetValueInt();
            int     valb2 = pl2.GetValueInt();
            string  vals2 = pl2.GetValueString();

            //Assert
            Assert.AreEqual(vala, vala2);
            Assert.AreEqual(valb, valb2);
            Assert.AreEqual(vals, vals2);
        }
Exemplo n.º 3
0
        ObservableList <ControlProperty> IWindowExplorerTreeItem.GetElementProperties()
        {
            PayLoad Request = new PayLoad(JavaDriver.CommandType.WindowExplorerOperation.ToString());

            Request.AddEnumValue(JavaDriver.WindowExplorerOperationType.GetProperties);
            Request.AddValue("ByXPath");
            Request.AddValue(JavaElementInfo.XPath);
            Request.ClosePackage();

            JavaDriver d        = (JavaDriver)JavaElementInfo.WindowExplorer;
            PayLoad    Response = d.Send(Request);

            if (Response.IsErrorPayLoad())
            {
                string ErrMSG = Response.GetValueString();
                return(null);
            }

            if (Response.Name == "ControlProperties")
            {
                ObservableList <ControlProperty> list = new ObservableList <ControlProperty>();
                List <PayLoad> props = Response.GetListPayLoad();
                foreach (PayLoad prop in props)
                {
                    string PropName  = prop.GetValueString();
                    string PropValue = String.Empty;
                    if (PropName != "Value")
                    {
                        PropValue = prop.GetValueString();
                    }
                    else
                    {
                        List <String> valueList = prop.GetListString();
                        if (valueList.Count != 0)
                        {
                            PropValue = valueList.ElementAt(0);
                        }
                    }

                    list.Add(new ControlProperty()
                    {
                        Name = PropName, Value = PropValue
                    });
                }
                return(list);
            }
            else
            {
                //TODO: handle err
                return(null);
            }
        }
Exemplo n.º 4
0
        public PayLoad Pack()
        {
            //TODO: not used!? remove as in java driver there is special pack per action type
            PayLoad pl = new PayLoad("ActJavaElement");

            pl.AddEnumValue(WaitforIdle);
            pl.AddEnumValue(LocateBy);
            pl.AddValue(LocateValue);
            pl.AddValue(Value);
            pl.AddEnumValue(ControlAction);
            pl.ClosePackage();
            return(pl);
        }
Exemplo n.º 5
0
        internal PayLoad GetPayLoad()
        {
            PayLoad PL = new PayLoad("SwitchWindow");

            if (string.IsNullOrEmpty(LocateValueCalculated) == false)
            {
                PL.AddValue(LocateValueCalculated);
            }
            else
            {
                PL.AddValue(ValueForDriver);
            }
            PL.ClosePackage();
            return(PL);
        }
Exemplo n.º 6
0
        public void SpeedTestSimpleStringX100()
        {
            //Arrange
            Stopwatch st = new Stopwatch();

            st.Start();
            string s0 = "ABCDEFGHIJ";

            // Act
            for (int i = 0; i < 100; i++)
            {
                PayLoad pl = new PayLoad("SpeedTestSimpleStringX100");
                pl.AddValue(s0);
                pl.ClosePackage();

                byte[] b = pl.GetPackage();

                PayLoad pl2 = new PayLoad(b);
                string  s1  = pl2.GetValueString();
            }

            st.Stop();

            //Assert
            Assert.IsTrue(st.ElapsedMilliseconds < 30);
        }
Exemplo n.º 7
0
        public void VeryLongString500000()
        {
            //Arrange

            string s0 = "Hello World";

            while (s0.Length < 500000)
            {
                s0 += s0;
            }

            PayLoad pl = new PayLoad("VeryLongString500000");

            pl.AddValue(s0);
            pl.ClosePackage();

            // Act
            byte[] b = pl.GetPackage();;


            PayLoad pl2 = new PayLoad(b);
            string  s1  = pl2.GetValueString();

            //Assert
            Assert.AreEqual(s0, s1);
        }
Exemplo n.º 8
0
        private PayLoad getChilderns()
        {
            //TODO: J.G: Move this to Java Driver. why here ?

            JavaDriver d       = (JavaDriver)JavaElementInfo.WindowExplorer;
            PayLoad    Request = null;

            if (JavaElementInfo.ElementTypeEnum == eElementType.Browser)
            {
                d.InitializeBrowser(JavaElementInfo);
                Request = new PayLoad("GetElementChildren");
                Request.AddValue("");
                Request.AddValue("/");
                Request.ClosePackage();
            }
            else if (JavaElementInfo.ElementTypeEnum == eElementType.EditorPane)
            {
                d.InitializeJEditorPane(JavaElementInfo);
                Request = new PayLoad(JavaDriver.CommandType.WindowExplorerOperation.ToString());
                Request.AddEnumValue(JavaDriver.WindowExplorerOperationType.GetEditorChildrens);
                Request.AddValue(JavaElementInfo.XPath);
                Request.ClosePackage();
            }
            else
            {
                Request = new PayLoad(JavaDriver.CommandType.WindowExplorerOperation.ToString());
                Request.AddEnumValue(JavaDriver.WindowExplorerOperationType.GetContainerControls);
                Request.AddValue(JavaElementInfo.XPath);
                Request.ClosePackage();
            }
            PayLoad Response = d.Send(Request);

            if (Response.Name == "ERROR")
            {
                string ErrMsg = Response.GetValueString();
                throw new Exception(ErrMsg);
            }
            else
            {
                return(Response);
            }
        }
Exemplo n.º 9
0
        public void PayLoadList()
        {
            //Arrange
            PayLoad pl = new PayLoad("Package wth list of Payloads");

            List <PayLoad> list = new List <PayLoad>();

            PayLoad pl1 = new PayLoad("PL1");

            pl1.AddValue("ABC");
            pl1.AddValue("DEF");
            pl1.ClosePackage();
            list.Add(pl1);

            PayLoad pl2 = new PayLoad("PL2");

            pl2.AddValue("GHI");
            pl2.AddValue("JKL");
            pl2.ClosePackage();
            list.Add(pl2);

            pl.AddListPayLoad(list);
            pl.ClosePackage();


            // Act
            byte[]         b     = pl.GetPackage();
            PayLoad        plc   = new PayLoad(b);
            List <PayLoad> list2 = plc.GetListPayLoad();

            //Assert
            Assert.AreEqual(2, list2.Count, "list2.Count=2");

            Assert.AreEqual("PL1", list2[0].Name, "list2[0].Name =PL1");
            Assert.AreEqual("PL2", list2[1].Name, "list2[1].Name =PL2");

            //Assert.AreEqual(pl1.Name, pl2.Name);
        }
Exemplo n.º 10
0
        internal Drivers.CommunicationProtocol.PayLoad GetPayLoad()
        {
            PayLoad PL = new PayLoad("UIElementAction");

            PL.AddValue(this.ElementLocateBy.ToString());
            PL.AddValue(GetOrCreateInputParam(Fields.ElementLocateValue).ValueForDriver); // Need Value for driver
            PL.AddValue(this.ElementType.ToString());
            PL.AddValue(this.ElementAction.ToString());
            // Make it generic function in Act.cs to be used by other actions
            List <PayLoad> PLParams = new List <PayLoad>();

            foreach (ActInputValue AIV in this.InputValues)
            {
                if (!string.IsNullOrEmpty(AIV.Value))
                {
                    PayLoad AIVPL = new PayLoad("AIV", AIV.Param, AIV.ValueForDriver);
                    PLParams.Add(AIVPL);
                }
            }
            PL.AddListPayLoad(PLParams);
            PL.ClosePackage();

            return(PL);
        }
Exemplo n.º 11
0
        public void EchoSringwithSymbols()
        {
            // Arrange
            string  txt       = "ABC } $- = 123 !@#$%(^&'~*)_+{";
            PayLoad PLRequest = new PayLoad("Echo");

            PLRequest.AddValue(txt);
            PLRequest.ClosePackage();

            //Act
            PayLoad PLRC  = mDriver.ExceuteJavaScriptPayLoad(PLRequest);
            string  txtRC = PLRC.GetValueString();

            //Assert
            Assert.AreEqual(PLRC.Name, "Echo Response");
            Assert.AreEqual(txt, txtRC, "txt=txtRC");
        }
Exemplo n.º 12
0
        public void PayloadOnSameSide()
        {
            //Arrange
            string s0 = "Hello World";

            PayLoad pl = new PayLoad("SimpleString");

            pl.AddValue(s0);
            pl.ClosePackage();


            PayLoad pl2 = pl;
            string  s1  = pl2.GetValueString();

            //Assert
            Assert.AreEqual(s0, s1);
            Assert.AreEqual(pl.Name, pl2.Name);
        }
Exemplo n.º 13
0
        public void IntMaxValue()
        {
            //Arrange
            int val = Int16.MaxValue;

            PayLoad pl = new PayLoad("IntMaxValue");

            pl.AddValue(val);
            pl.ClosePackage();

            // Act
            byte[] b = pl.GetPackage();

            PayLoad pl2  = new PayLoad(b);
            int     val2 = pl2.GetValueInt();

            //Assert
            Assert.AreEqual(val, val2);
        }
Exemplo n.º 14
0
        public void NegativeInt()
        {
            //Arrange
            int val = -123;

            PayLoad pl = new PayLoad("NegativeInt");

            pl.AddValue(val);
            pl.ClosePackage();

            // Act
            byte[] b = pl.GetPackage();

            PayLoad pl2  = new PayLoad(b);
            int     val2 = pl2.GetValueInt();

            //Assert
            Assert.AreEqual(val, val2);
        }
Exemplo n.º 15
0
        public void StringWithSpecialCharsUTF8()
        {
            //Arrange
            string s0 = @"ABC!@#$%^&*(){}[]~|\/<>,.~`XYZ";

            PayLoad pl = new PayLoad("StringWithSpecialChars");

            pl.AddValue(s0);
            pl.ClosePackage();

            // Act
            byte[] b = pl.GetPackage();


            PayLoad pl2 = new PayLoad(b);
            string  s1  = pl2.GetValueString();

            //Assert
            Assert.AreEqual(s0, s1);
        }
Exemplo n.º 16
0
        public void NullTest()
        {
            //Arrange
            string s0 = null;

            PayLoad pl = new PayLoad("NullString");

            pl.AddValue(s0);
            pl.ClosePackage();

            // Act
            byte[] b = pl.GetPackage();

            PayLoad pl2 = new PayLoad(b);
            string  s1  = pl2.GetValueString();

            //Assert
            Assert.AreEqual(s0, s1);
            Assert.AreEqual(pl.Name, pl2.Name);
        }
Exemplo n.º 17
0
        public void EchoLongSring()
        {
            // Arrange
            string txt = "AAAAAAAA";

            while (txt.Length < 5000)
            {
                txt += txt;
            }
            PayLoad PLRequest = new PayLoad("Echo");

            PLRequest.AddValue(txt);
            PLRequest.ClosePackage();

            //Act
            PayLoad PLRC  = mDriver.ExceuteJavaScriptPayLoad(PLRequest);
            string  txtRC = PLRC.GetValueString();

            //Assert
            Assert.AreEqual(PLRC.Name, "Echo Response");
            Assert.AreEqual(txt, txtRC, "txt=txtRC");
        }