Exemple #1
1
        public static void Main(string[] args)
        {
            // Datos de conexión
            String Url = "http://localhost:8069";
            String Dbname = "test_db";
            String Login = "******";
            String Password = "******";

            // Login
            OpenERPConnect connection = new OpenERPConnect(Url, Dbname, Login, Password);
            connection.Login();
            Console.WriteLine(connection.UserId);

            Object[] domain = new Object[3]; // Albaranes de salida ya asignados y sin incidencias
            domain[0] = new Object[3] {"picking_type_id.code", "=", "outgoing"};
            domain[1] = new Object[3] {"state", "=", "assigned"};
            domain[2] = new Object[3] {"with_incidences", "=", false};
            long[] picking_ids = connection.Search("stock.picking", domain);
            Console.WriteLine("Albaranes encontrados: {0}", picking_ids.Length);

            //Los recorremos y les escribimos a todos la misma incidencia
            foreach(long picking_id in picking_ids)
            {
                XmlRpcStruct vals = new XmlRpcStruct();
                vals.Add("with_incidences", true); //Lo marcamos como bajo incidencia
                connection.Write("stock.picking", new long[] {picking_id}, vals);

                //Escribimos el motivo de la incidencia
                connection.MessagePost("stock.picking", new long[] {picking_id}, "Stock Incorrecto");
            }

            Console.ReadLine();
        }
Exemple #2
0
        public void OrderingEnumerator()
        {
            var xps = new XmlRpcStruct();

            xps.Add("1", "a");
            xps.Add("3", "c");
            xps.Add("2", "b");
            IDictionaryEnumerator enumerator = xps.GetEnumerator();

            enumerator.MoveNext();
            Assert.AreEqual("1", enumerator.Key);
            Assert.AreEqual("a", enumerator.Value);
            Assert.IsInstanceOfType(typeof(DictionaryEntry), enumerator.Current);
            DictionaryEntry de = (DictionaryEntry)enumerator.Current;

            Assert.AreEqual("1", de.Key);
            Assert.AreEqual("a", de.Value);
            enumerator.MoveNext();
            Assert.AreEqual("3", enumerator.Key);
            Assert.AreEqual("c", enumerator.Value);
            Assert.IsInstanceOfType(typeof(DictionaryEntry), enumerator.Current);
            de = (DictionaryEntry)enumerator.Current;
            Assert.AreEqual("3", de.Key);
            Assert.AreEqual("c", de.Value);
            enumerator.MoveNext();
            Assert.AreEqual("2", enumerator.Key);
            Assert.AreEqual("b", enumerator.Value);
            Assert.IsInstanceOfType(typeof(DictionaryEntry), enumerator.Current);
            de = (DictionaryEntry)enumerator.Current;
            Assert.AreEqual("2", de.Key);
            Assert.AreEqual("b", de.Value);
        }
        public Subtitle GetSubtitleByHash(string fileName, string languageCode)
        {
            Subtitle retValue = new Subtitle();
            XmlRpcStruct searchParams = new XmlRpcStruct();
            List<SubtitleSearchItem> subtitles = null;
            var fileInfo = new FileInfo(fileName);
            searchParams.Add(SEARCH_PARAM_LANGUAGE_ID, languageCode);
            searchParams.Add(SEARCH_PARAM_MOVIE_HASH, GetMovieHash(fileName));
            searchParams.Add(SEARCH_PARAM_MOVIE_SIZE, fileInfo.Length);

            XmlRpcStruct response = RpcProxy.SearchSubtitles(AuthToken, new object[1] { new XmlRpcStruct[1] { searchParams } });
            if ((string)response[RESPONSE_STATUS_FIELD] == RESPONSE_RESULT_OK)
            {
                subtitles = SearchReponse2List(response);
            }
            //Take one with best rating
            if (subtitles.Count > 0)
            {
                var subtitle = subtitles.OrderByDescending(item => item.SubRating).FirstOrDefault();
                var subtitleStream = DownloadSubtitles(subtitle.IDSubtitleFile);

                retValue = new Subtitle(subtitleStream, subtitle.SubFormat);
            }
            return retValue;
        }
Exemple #4
0
        public XmlRpcStruct RunKeyword(string keywordName, string[] arguments)
        {
            var result = new XmlRpcStruct();

            Keyword keyword;
            if(!keywordManager.TryGetKeyword(keywordName, out keyword))
            {
                throw new XmlRpcFaultException(1, string.Format("Keyword \"{0}\" not found", keywordName));
            }

            try
            {
                var keywordResult = keyword.Execute(arguments);
                if(keywordResult != null)
                {
                    result.Add(KeywordResultValue, keywordResult.ToString());
                }
                result.Add(KeywordResultStatus, KeywordResultPass);
            }
            catch(Exception e)
            {
                result.Clear();

                result.Add(KeywordResultStatus, KeywordResultFail);
                result.Add(KeywordResultError, BuildRecursiveErrorMessage(e));
                result.Add(KeywordResultTraceback, e.StackTrace);
            }

            return result;
        }
 public void OrderingEnumerator()
 {
   var xps = new XmlRpcStruct();
   xps.Add("1", "a");
   xps.Add("3", "c");
   xps.Add("2", "b");
   IDictionaryEnumerator enumerator = xps.GetEnumerator();
   enumerator.MoveNext();
   Assert.AreEqual("1", enumerator.Key);
   Assert.AreEqual("a", enumerator.Value);
   Assert.IsInstanceOfType(typeof(DictionaryEntry), enumerator.Current);
   DictionaryEntry de = (DictionaryEntry)enumerator.Current;
   Assert.AreEqual("1", de.Key);
   Assert.AreEqual("a", de.Value);
   enumerator.MoveNext();
   Assert.AreEqual("3", enumerator.Key);
   Assert.AreEqual("c", enumerator.Value);
   Assert.IsInstanceOfType(typeof(DictionaryEntry), enumerator.Current);
   de = (DictionaryEntry)enumerator.Current;
   Assert.AreEqual("3", de.Key);
   Assert.AreEqual("c", de.Value);
   enumerator.MoveNext();
   Assert.AreEqual("2", enumerator.Key);
   Assert.AreEqual("b", enumerator.Value);
   Assert.IsInstanceOfType(typeof(DictionaryEntry), enumerator.Current);
   de = (DictionaryEntry)enumerator.Current;
   Assert.AreEqual("2", de.Key);
   Assert.AreEqual("b", de.Value);
 }
 public void DoubleAdd()
 {
     XmlRpcStruct xps = new XmlRpcStruct();
       xps.Add("foo", "123456");
       xps.Add("foo", "abcdef");
       Assert.Fail("Test should throw ArgumentException");
 }
	    /// <summary>
	    /// Run specified Robot Framework keyword from remote server.
	    /// </summary>
	    public XmlRpcStruct run_keyword(string keyword, object[] args)
	    {
			log.Debug(String.Format("XmlRpc Method call - run_keyword {0}",keyword));
			XmlRpcStruct kr = new XmlRpcStruct();
			//check for stop remote server
			if (String.Equals(keyword,CStopRemoteServer,StringComparison.CurrentCultureIgnoreCase))
			{
				//start background thread to raise event
				Thread stopthread = new Thread(delayed_stop_remote_server);
				stopthread.IsBackground = true;
				stopthread.Start();
				log.Debug("Stop remote server thread started");
				//return success
				kr.Add("return",String.Empty);
				kr.Add("status","PASS");
				kr.Add("error",String.Empty);
				kr.Add("traceback",String.Empty);
				kr.Add("output",String.Empty);
			}
			else
			{
				try
				{
					var result = _map.ExecuteKeyword(keyword,args);
					log.Debug(result.ToString());
					kr = XmlRpcResultBuilder.ToXmlRpcResult(result);
				}
				catch (Exception e)
				{
					log.Error(String.Format("Exception in method - run_keyword : {0}",e.Message));
					throw new XmlRpcFaultException(1,e.Message);
				}
			}
			return kr;
		}
Exemple #8
0
        public void DoubleAdd()
        {
            XmlRpcStruct xps = new XmlRpcStruct();

            xps.Add("foo", "123456");
            xps.Add("foo", "abcdef");
        }
Exemple #9
0
        public XmlRpcStruct toStruct()
        {
            XmlRpcStruct exchange = new XmlRpcStruct();
            exchange.Add("SYMBOl", symbol);
            exchange.Add("NAME", name);
            exchange.Add("LOCATION", location);

            return exchange;
        }
Exemple #10
0
        public XmlRpcStruct toStruct()
        {
            XmlRpcStruct security = new XmlRpcStruct();
            security.Add("ISIN", isin);
            security.Add("SYMBOL", symbol);
            security.Add("NAME", name);
            security.Add("EXCHANGE", exchange.Name);

            return security;
        }
 private XmlRpcStruct CreateSearchStructure(List<string> languages, string hashString, long videoSize)
 {
     var searchStructure = new XmlRpcStruct();
     var preferredLanguages = this.GetSubtitleString(languages);
     searchStructure.Add("sublanguageid", preferredLanguages);
     searchStructure.Add("moviehash", hashString);
     searchStructure.Add("moviebytesize", videoSize.ToString());
     searchStructure.Add("imdbid", "");
     return searchStructure;
 }
        public XmlRpcStruct toStruct()
        {
            XmlRpcStruct pointsTransaction = new XmlRpcStruct();
            pointsTransaction.Add("USER", userId);
            pointsTransaction.Add("TIMESTAMP", timestamp);
            pointsTransaction.Add("TYPE", type.ToString());
            pointsTransaction.Add("DELTA", delta);
            pointsTransaction.Add("COMMENTS", comments);

            return pointsTransaction;
        }
 /// <summary>
 /// Converts keyword result to RF XmlRpc Structure
 /// </summary>
 public static XmlRpcStruct ToXmlRpcResult(KeywordResult kwresult)
 {
     var result = new XmlRpcStruct();
     //add status
     result.Add("status",kwresult.status.ToString());
     //add error, traceback, output
     result.Add("error",kwresult.error);
     result.Add("traceback",kwresult.traceback);
     result.Add("output",kwresult.output);
     //add return
     if ([email protected]().Equals(typeof(System.Int64)))
     {
         //64bit int has to be returned as string
         result.Add("return",[email protected]());
     }
     else
     {
         result.Add("return",kwresult.@return);
     }
     //check error type
     if (kwresult.status==KeywordStatus.FAIL)
     {
         if (kwresult.errortype==KeywordErrorTypes.Continuable)
         {
             //continuable error
             result.Add("continuable",true);
         }
         if (kwresult.errortype==KeywordErrorTypes.Fatal)
         {
             //fatal error
             result.Add("fatal",true);
         }
     }
     return result;
 }
Exemple #14
0
        public void OrderingKeys2()
        {
            var xps = new XmlRpcStruct();

            xps.Add("member_1", "a");
            xps.Add("member_4", "c");

            IEnumerator enumerator = xps.Keys.GetEnumerator();

            enumerator.MoveNext();
            Assert.AreEqual("member_1", enumerator.Current);
            enumerator.MoveNext();
            Assert.AreEqual("member_4", enumerator.Current);
        }
Exemple #15
0
        public void DeletePost_ExistingEntry()
        {
            // Create entry
            var entryContent = new XmlRpcStruct();
            entryContent.Add("title", "the title");
            entryContent.Add("description", "the description");

            var newId = m_api.newPost(m_blog1.ID.ToString(), m_userAuthor.Name, PASSWORD, entryContent, false);

            Assert.IsNotNullOrEmpty(newId);

            // Delete the entry
            var result = m_api.deletePost("test", newId, m_userAuthor.Name, PASSWORD, false);
            Assert.IsTrue(result);
        }
Exemple #16
0
        public void Add()
        {
            XmlRpcStruct xps = new XmlRpcStruct();

            xps.Add("foo", "abcdef");
            Assert.AreEqual("abcdef", xps["foo"]);
        }
        public void CreateTicket(TicketInfo ticket)
        {
            if (string.IsNullOrEmpty(ticket.Summary)) throw new ArgumentNullException("ticket.Summary");

            if (string.IsNullOrEmpty(ticket.Description)) throw new ArgumentNullException("ticket.Description");

            if (string.IsNullOrEmpty(ticket.Type)) throw new ArgumentNullException("ticket.Type");

            if (string.IsNullOrEmpty(ticket.Priority)) throw new ArgumentNullException("ticket.Priority");

            if (string.IsNullOrEmpty(ticket.Component)) throw new ArgumentNullException("ticket.Component");

            XmlRpcStruct tempAttributes = new XmlRpcStruct();

            foreach (object key in ticket.Attributes.Keys)
            {

                if ((((string)key) != TicketAttributes.Description) && (((string)key) != TicketAttributes.Summary))
                {

                    tempAttributes.Add(key, ticket.Attributes[key]);

                }

            }

            int id = _ticket.Create(ticket.Summary, ticket.Description, ticket.Attributes);

            ticket.TicketId = id;
        }
Exemple #18
0
        public void OrderingValues()
        {
            var xps = new XmlRpcStruct();

            xps.Add("1", "a");
            xps.Add("3", "c");
            xps.Add("2", "b");

            IEnumerator enumerator = xps.Values.GetEnumerator();

            enumerator.MoveNext();
            Assert.AreEqual("a", enumerator.Current);
            enumerator.MoveNext();
            Assert.AreEqual("c", enumerator.Current);
            enumerator.MoveNext();
            Assert.AreEqual("b", enumerator.Current);
        }
 public static XmlRpcStruct dictionaryToXmlRpcStruct(IDictionary<string, object> idic)
 {
     XmlRpcStruct s = new XmlRpcStruct();
     foreach (string key in idic.Keys) {
         s.Add(key, idic[key]);
     }
     return s;
 }
        public static bool admin_restore_oar(string password, string nomeRegiao, string oarfile)
        {
            XmlRpcStruct saveAccept = new XmlRpcStruct();
            XmlRpcStruct saveParms = new XmlRpcStruct();

            saveParms.Add("password", password);
            saveParms.Add("region_name", nomeRegiao);
            saveParms.Add("filename", oarfile);

            RemoteOpensim admin = XmlRpcProxyGen.Create<RemoteOpensim>();

            try
            {
                saveAccept = admin.admin_load_oar(saveParms);
            }
            catch
            {
                return false;
            }

            return true;
        }
 public DataTable CancellationConfirmation(string ticketNo)
 {
     try
     {
         object[] response = null;
         XmlRpcStruct data = new XmlRpcStruct();
         data.Add("ticketno", ticketNo);
         IAbhiBusCancellationConfirmation gd = XmlRpcProxyGen.Create<IAbhiBusCancellationConfirmation>();
         response = gd.CancellationConfirmation(data);
         DataTable dt = new DataTable();
         dt.Columns.Add("ticket_number"); dt.Columns.Add("message"); dt.Columns.Add("status");
         dt.Columns.Add("total_ticket_fare"); dt.Columns.Add("total_refund_amount"); dt.Columns.Add("cancellation_parcentage");
         foreach (XmlRpcStruct item in response)
         {
             DataRow dr = dt.NewRow();
             foreach (var item1 in item.Keys)
             {
                 if (item1.ToString() == "ticket_number")
                 {
                     dr["ticket_number"] = item[item1].ToString();
                 }
                 if (item1.ToString() == "message")
                 {
                     dr["message"] = item[item1].ToString();
                 }
                 if (item1.ToString() == "status")
                 {
                     dr["status"] = item[item1].ToString();
                 }
                 if (item1.ToString() == "total_ticket_fare")
                 {
                     dr["total_ticket_fare"] = item[item1].ToString();
                 }
                 if (item1.ToString() == "total_refund_amount")
                 {
                     dr["total_refund_amount"] = item[item1].ToString();
                 }
                 if (item1.ToString() == "cancellation_parcentage")
                 {
                     dr["cancellation_parcentage"] = item[item1].ToString();
                 }
             }
             dt.Rows.Add(dr);
         }
         return dt;
     }
     catch (Exception)
     {
         throw;
     }
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="ImdbId"></param>
 /// <param name="query"></param>
 /// <param name="languages"></param>
 /// <returns></returns>
 public List<SearchSubtitleResult> SearchByImdbIdThenQuery(string ImdbId, string query, OSLanguage languages)
 {
     XmlRpcStruct SearchParamsStruct = new XmlRpcStruct();
     if (languages != null)
     {
         SearchParamsStruct.Add("sublanguageid", languages.IdSubLanguage);
     }
     else
     {
         SearchParamsStruct.Add("sublanguageid", "all");
     }
     if (!String.IsNullOrEmpty(ImdbId))
     {
         SearchParamsStruct.Add("imdbid", ImdbId);
     }
     if (!String.IsNullOrEmpty(query))
     {
         SearchParamsStruct.Add("query", query);
     }
     XmlRpcStruct ResponseStruct = proxy.SearchSubtitles(Token, new object[1] { new XmlRpcStruct[1] { SearchParamsStruct } });
     List<SearchSubtitleResult> SearchResultList = DoSearchRequest(ResponseStruct);
     return SearchResultList;
 }
        public void OrderingKeys()
        {
            var xps = new XmlRpcStruct();
              xps.Add("1", "a");
              xps.Add("3", "c");
              xps.Add("2", "b");

              IEnumerator enumerator = xps.Keys.GetEnumerator();
              enumerator.MoveNext();
              Assert.AreEqual("1", enumerator.Current);
              enumerator.MoveNext();
              Assert.AreEqual("3", enumerator.Current);
              enumerator.MoveNext();
              Assert.AreEqual("2", enumerator.Current);
        }
Exemple #24
0
        public void EditPost_ExistingEntry()
        {
            // Create entry
            var entryContent = new XmlRpcStruct();
            entryContent.Add("title", "the title");
            entryContent.Add("description", "the description");

            var newId = m_api.newPost(m_blog1.ID.ToString(), m_userAuthor.Name, PASSWORD, entryContent, false);

            Assert.IsNotNullOrEmpty(newId);

            // Edit the entry
            var publishDate = new DateTime(2020, 3, 6);
            var updatedContent = new XmlRpcStruct();
            updatedContent.Add("description", "updated");
            updatedContent.Add("dateCreated", publishDate);

            var result = m_api.editPost(newId, m_userAuthor.Name, PASSWORD, updatedContent, false);
            Assert.IsTrue(result);

            var newItem = m_blog1.Database.GetItem(newId);

            try
            {
                Assert.AreEqual("the title", newItem["title"]);
                Assert.AreEqual("updated", newItem["content"]);
                Assert.AreEqual(publishDate, newItem.Publishing.PublishDate);
            }
            finally
            {
                using (new SecurityDisabler())
                {
                    newItem.Delete();
                }
            }
        }
        /// <summary>
        /// Sets the "ExpectAndReturn" for "GetObject" method.
        /// The returned SSX object has: name='XOfficeStyle', use='onDemand', parse='0' and the 'code' is
        /// some CSS for '.xoffice0' class and '#id1" id.
        /// </summary>
        /// <param name="xWikiClientMock">A reference to a <code>DynamicMock</code>.</param>
        private static void SetObjForGetObject(ref DynamicMock xWikiClientMock)
        {
            XmlRpcStruct dictionary = new XmlRpcStruct();
            dictionary.Add("code", CSS_CONTENT_XOFFICE0 + CSS_CONTENT_ID1);
            dictionary.Add("name", "XOfficeStyle");
            dictionary.Add("use", "onDemand");
            dictionary.Add("parse", "0");

            XWikiObject xWikiObject = new XWikiObject();
            xWikiObject.className = SSX_CLASS_NAME;
            xWikiObject.id = 1;
            xWikiObject.pageId = PAGE_FULL_NAME;
            xWikiObject.prettyName = "XOfficeStyle";
            xWikiObject.objectDictionary = dictionary;

            xWikiClientMock.ExpectAndReturn("GetObject", xWikiObject, new object[3] { PAGE_FULL_NAME, SSX_CLASS_NAME, 1 });
        }
        public int AddContact(Contact contact, IEnumerable<int> tags = null)
        {
            var proxy = XmlRpcProxyGen.Create<IContactService>();
            proxy.Url = BaseUrl;

            var data = new XmlRpcStruct();

            foreach (var propertyInfo in contact.GetType().GetProperties().Where(propertyInfo => propertyInfo.CanRead))
            {
                var value = propertyInfo.GetValue(contact, null);
                if (value != null)
                    data.Add(propertyInfo.Name, value);
            }

            int contactId = proxy.Add(PrivateKey, data);

            if (tags != null)
                foreach (var tagId in tags)
                    proxy.AddTag(PrivateKey, contactId, tagId);

            return contactId;
        }
Exemple #27
0
        /// <summary>
        /// Create a drupal file structure
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        private XmlRpcStruct buildFileStruct(string filePath, string serverPath)
        {
            // Encode file to base64
            FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);

            byte[] filebytes = new byte[fs.Length];
            fs.Read(filebytes, 0, Convert.ToInt32(fs.Length));
            string encodedFile = Convert.ToBase64String(filebytes, Base64FormattingOptions.InsertLineBreaks);

            System.IO.FileInfo fi = new System.IO.FileInfo(filePath);

            CookComputing.XmlRpc.XmlRpcStruct fileStruct = new CookComputing.XmlRpc.XmlRpcStruct();
            fileStruct.Add("file", encodedFile);
            fileStruct.Add("filename", fi.Name);
            fileStruct.Add("filepath", serverPath + fi.Name);
            fileStruct.Add("filesize", fi.Length.ToString());
            fileStruct.Add("timestamp", GetUnixTimestamp());
            fileStruct.Add("uid", this.UserID);//Form Login

            return(fileStruct);
        }
        public static TestProject GetTestProject(
            string name,
            string prefix,
            string notes,
            string color,
            int tc_counter,
            bool active,
            bool option_automation,
            bool option_inventory,
            bool option_priority,
            bool option_reqs)
        {
            int id = generator.Next(1000000);

            XmlRpcStruct data = new XmlRpcStruct();
            data.Add("id", id.ToString());
            data.Add("name", name);
            data.Add("prefix", prefix);
            data.Add("notes", notes);
            data.Add("color", color);
            data.Add("active", 1);
            data.Add("tc_counter", tc_counter);

            XmlRpcStruct optStruct = new XmlRpcStruct();
            optStruct.Add("requirementsEnabled", 1);
            optStruct.Add("testPriorityEnabled", 1);
            optStruct.Add("automationEnabled", 1);
            optStruct.Add("inventoryEnabled", 1);
            data.Add("opt", optStruct);

            var testProject = new Mock<Meyn.TestLink.TestProject>(data);
            return testProject.Object;
        }
        public static Meyn.TestLink.TestPlatform GetTestPlatform(
           string name,
           string notes)
        {
            int id = generator.Next(1000000);

            XmlRpcStruct data = new XmlRpcStruct();
            data.Add("name", name);
            data.Add("id", id);
            data.Add("notes", notes);

            var testPlatform = new Mock<Meyn.TestLink.TestPlatform>(data);
            return testPlatform.Object;
        }
        public static Meyn.TestLink.TestPlanTotal GetTestPlanTotal(
           string name,
           string type,
           int total_tc)
        {
            //        /// <summary>
            //        /// category name
            //        /// </summary>
            //        public readonly string Type = "";
            //        /// <summary>
            //        /// category value
            //        /// </summary>
            //        public readonly string Name = "";
            //        /// <summary>
            //        /// total test cases that are covered in this test plan
            //        /// </summary>
            //        public readonly int Total_tc;
            //        /// <summary>
            //        /// Dictionary with execution totals
            //        /// </summary>
            //        public readonly Dictionary<string, int> Details = new Dictionary<string, int>();
            //
            ////        internal TestPlanTotal(XmlRpcStruct data)
            ////        {
            //            Total_tc = toInt(data, "total_tc");
            //            if (data.ContainsKey("type"))
            //                Type = (string)data["type"];
            //            if (data.ContainsKey("name"))
            //                Name = (string)data["name"];
            //
            //            XmlRpcStruct xdetails = data["details"] as XmlRpcStruct;
            //
            //            foreach (string key in xdetails.Keys)
            //            {
            //                XmlRpcStruct val = xdetails[key] as XmlRpcStruct;
            //                int qty = toInt(val,"qty");
            //                Details.Add(key, qty);
            //            }
            ////        }

            int id = generator.Next(1000000);

            XmlRpcStruct data = new XmlRpcStruct();
            data.Add("name", name);
            data.Add("type", type);
            data.Add("total_tc", total_tc);

            XmlRpcStruct details = new XmlRpcStruct();

            data.Add("details", details);

            var testPlanTotal = new Mock<Meyn.TestLink.TestPlanTotal>(data);
            return testPlanTotal.Object;
        }
        public static TestPlan GetTestPlan(
            string name,
            string notes,
            bool active,
            bool is_public,
            bool open,
            int testproject_id)
        {
            int id = generator.Next(1000000);

            XmlRpcStruct data = new XmlRpcStruct();
            data.Add("active", active);
            data.Add("id", id);
            data.Add("name", name);
            data.Add("notes", notes);
            data.Add("testproject_id", testproject_id);
            data.Add("is_open", open);
            data.Add("is_public", is_public);

            var testPlan = new Mock<TestPlan>(data);
            return testPlan.Object;
        }
        //    /// <summary>
        //    /// test cases as they are returned from a test plan
        //    /// </summary>
        //    /// <remarks>This is different from TestCase as it returns additional info from the testplan.
        //    /// Maybe this should be refactored with a testplandetails subclass</remarks>
        //    public class TestCaseFromTestPlan : TL_Data
        //    {
        //        /// <summary>
        //        /// marks the test case as active
        //        /// </summary>
        //        public readonly  bool active;
        //        /// <summary>
        //        /// the build id the test case is assigned to
        //        /// </summary>
        //        public readonly int assigned_build_id;
        //
        //        public readonly int assigner_id;
        //        /// <summary>
        //        ///
        //        /// </summary>
        //        public readonly int executed;
        //        public readonly string execution_notes;
        //        public readonly int execution_order;
        //        /// <summary>
        //        /// timestamp when it was executed. blank if not yet executeed
        //        /// </summary>
        //        public readonly string execution_ts;
        //        /// <summary>
        //        /// actual execution type on last run 1=manual, 2 = automatic
        //        /// </summary>
        //        public string execution_run_type;
        //        /// <summary>
        //        /// the execution type set in the test case  1=manual, 2 = automatic
        //        /// </summary>
        //        public readonly int execution_type;
        //        public readonly int exec_id;
        //        /// <summary>
        //        /// build id where it was last executed on
        //        /// </summary>
        //        public readonly int exec_on_build;
        //        /// <summary>
        //        /// test plan id where it was last executed
        //        /// </summary>
        //        public readonly int exec_on_tplan;
        //        /// <summary>
        //        /// the last execution status
        //        /// </summary>
        //        public readonly TestCaseResultStatus exec_status;
        //        /// <summary>
        //        /// the id displayed on the UI, but without hte prefix
        //        /// </summary>
        //        public readonly string external_id;
        //        public readonly int importance;
        //        public readonly int feature_id;
        //        public readonly DateTime linked_ts;
        //        public readonly int linked_by;
        //        public readonly string name;
        //        public readonly int platform_id;
        //        public string platform_name;
        //        /// <summary>
        //        /// //the priority assigned in the test case(?)
        //        /// </summary>
        //        public int priority;
        //        /// <summary>
        //        /// not clear what this is. It is NOT the same as the status in the other test case classes
        //        /// </summary>
        //        public string status;
        //    
        //        public string summary;
        //        /// <summary>
        //        ///
        //        /// </summary>
        //        public int tcversion_number;
        //        public int tcversion_id;
        //        public int tc_id;
        //        public int tester_id;
        //        public int testsuite_id;
        //        public string tsuite_name;
        //        public string type;
        //        public int user_id;
        //        /// <summary>
        //        /// urgency set in test plan
        //        /// </summary>
        //        public int urgency;
        //        public int version;
        //        public int z;
        //
        //        internal TestCaseFromTestPlan(XmlRpcStruct data)
        //        {
        //            active = int.Parse((string)data["active"]) == 1;
        //            name = (string)data["name"];
        //            tsuite_name = (string)data["tsuite_name"];
        //            z = toInt(data, "z");
        //            type = (string)data["type"];
        //            execution_order = toInt(data, "execution_order");
        //            exec_id = toInt(data, "exec_id");
        //            tc_id = toInt(data, "tc_id");
        //            tcversion_number = toInt(data, "tcversion_number");
        //            status = (string)data["status"];
        //            external_id = (string)data["external_id"];
        //            exec_status = toExecStatus(data, "exec_status");
        //            exec_on_tplan = toInt(data, "exec_on_tplan");
        //            executed = toInt(data, "executed");
        //            feature_id = toInt(data, "feature_id");
        //            assigner_id = toInt(data, "assigner_id");
        //            user_id = toInt(data, "user_id");
        //            active = toInt(data, "active") == 1;
        //            version = toInt(data, "version");
        //            testsuite_id = toInt(data, "testsuite_id");
        //            tcversion_id = toInt(data, "tcversion_id");
        //            //steps = (string)data["steps"];
        //            //expected_results = (string)data["expected_results"];
        //            summary = (string)data["summary"];
        //            execution_type = toInt(data, "execution_type");
        //            platform_id = toInt(data, "platform_id");
        //            platform_name = (string)data["platform_name"];
        //            linked_ts = toDate(data, "linked_ts");
        //            linked_by = toInt(data, "linked_by");
        //            importance = toInt(data, "importance");
        //            execution_run_type = (string)data["execution_run_type"];
        //            execution_ts = (string)data["execution_ts"];
        //            tester_id = toInt(data, "tester_id");
        //            execution_notes = (string)data["execution_notes"];
        //            exec_on_build = toInt(data, "exec_on_build");
        //            assigned_build_id = toInt(data,"assigned_build_id");
        //            urgency = toInt(data, "urgency");
        //            priority = toInt(data, "priority");
        //        }
        //        /// <summary>
        //        /// This is used for the call GetTestCasesForTestPlan
        //        /// using the returned list from TestLink, generate a list of data
        //        /// </summary>
        //        /// <param name="list"></param>
        //        /// <returns></returns>
        //        public static List<TestCaseFromTestPlan> GenerateFromResponse(XmlRpcStruct list)
        //        {
        //            List<TestCaseFromTestPlan> result = new List<TestCaseFromTestPlan>();
        //            if (list != null)
        //            {
        //                foreach (object o in list.Values)
        //                {
        //                     TestCaseFromTestPlan tc = null;
        //                     if (o is XmlRpcStruct)
        //                     {
        //                         XmlRpcStruct list2 = o as XmlRpcStruct;
        //                         foreach (object o2 in list2.Values)
        //                         {
        //                             tc = new TestCaseFromTestPlan(o2 as XmlRpcStruct);
        //                             result.Add(tc);
        //                         }
        //                     }
        //                     else
        //                     {
        //                         object[] olist = o as object[];
        //                         tc = new TestCaseFromTestPlan(olist[0] as XmlRpcStruct);
        //                         result.Add(tc);
        //                     }
        //                }
        //            }
        //            return result;
        //        }
        //    }
        //    /// <summary>
        //    /// test case as it is retrieved from testsuite
        //    /// </summary>
        //    public class TestCaseFromTestSuite : TL_Data
        //    {
        //        /// <summary>
        //        /// test case id
        //        /// </summary>
        //        public readonly int id;
        //
        //        public readonly int parent_id;
        //        public readonly int node_type_id;
        //        public readonly int node_order;
        //        public readonly string node_table;
        //        public readonly string name;
        //        public readonly bool active;
        //        /// <summary>
        //        /// the version of the test case, starts with 1
        //        /// </summary>
        //        public readonly int version;
        //        /// <summary>
        //        /// the internal id of this testcase version
        //        /// </summary>
        //        public readonly int tcversion_id;
        //        /// <summary>
        //        /// not clear what this represents
        //        /// </summary>
        //        public readonly string layout;
        //        /// <summary>
        //        /// not clear in its meaning
        //        /// </summary>
        //        public readonly int status;
        //        public readonly string summary;
        //        public readonly string preconditions;
        //    
        //        /// <summary>
        //        /// the id that is displayed on the UI, sans the prefix
        //        /// </summary>
        //        public readonly string external_id;
        //        /// <summary>
        //        /// the id of the owning testsuite
        //        /// </summary>
        //        public readonly int testSuite_id;
        //        /// <summary>
        //        /// unknown purpose
        //        /// </summary>
        //        public readonly bool is_open;
        //        /// <summary>
        //        ///
        //        /// </summary>
        //        public readonly DateTime modification_ts;
        //        /// <summary>
        //        ///
        //        /// </summary>
        //        public readonly int updater_id;
        //        /// <summary>
        //        /// manual or automatic
        //        /// </summary>
        //        public readonly  int execution_type;
        //        public readonly string details;
        //        public readonly int author_id;
        //        public readonly DateTime creation_ts;
        //        public readonly int importance;
        //        internal TestCaseFromTestSuite(XmlRpcStruct data)
        //        {
        //            active = int.Parse((string)data["active"]) == 1;
        //            id = toInt(data, "id");
        //            name = (string)data["name"];
        //            version = toInt(data, "version");
        //            tcversion_id = toInt(data, "tcversion_id");
        //            //steps = (string)data["steps"];
        //            //expected_results = (string)data["expected_results"];
        //            external_id = (string)data["tc_external_id"];
        //            testSuite_id = toInt(data, "parent_id");
        //            is_open = int.Parse((string)data["is_open"]) == 1;
        //            modification_ts = base.toDate(data, "modification_ts");
        //            updater_id = toInt(data, "updater_id");
        //            execution_type = toInt(data, "execution_type");
        //            summary = (string)data["summary"];
        //            if (data.ContainsKey("details"))
        //                details = (string)data["details"];
        //            else
        //                details = "";
        //            author_id = toInt(data, "author_id");
        //            creation_ts = base.toDate(data, "creation_ts");
        //            importance = toInt(data, "importance");
        //            parent_id = toInt(data, "parent_id");
        //            node_type_id = toInt(data, "node_type_id");
        //            node_order = toInt(data, "node_order");
        //            node_table = (string)data["node_table"];
        //            layout = (string)data["layout"];
        //            status = toInt(data, "status");
        //            preconditions = (string)data["preconditions"];
        //        }
        //    }
        public static Meyn.TestLink.TestCase GetTestCase(
            //int id,
            string externalid,
            string updater_login,
            string author_login,
            string name,
            int node_order,
            int testsuite_id,
            int testcase_id,
            int version,
            string layout,
            int status,
            string summary,
            string preconditions,
            int importance,
            int author_id,
            int updater_id,
            DateTime creation_ts,
            DateTime modification_ts,
            bool active,
            bool is_open,
            int execution_type,
            string author_first_name,
            string author_last_name,
            string updater_first_name,
            string updater_last_name,
            System.Collections.Generic.List<TestStep> steps)
        {
            int id = generator.Next(1000000);

            XmlRpcStruct data = new XmlRpcStruct();
            data.Add("id", id);
            data.Add("active", 1);
            data.Add("tc_external_id", externalid);
            data.Add("updater_login", updater_login);
            data.Add("author_login", author_login);
            data.Add("name", name);
            data.Add("node_order", node_order);
            data.Add("testsuite_id", testsuite_id);
            data.Add("testcase_id", testcase_id);
            data.Add("version", version);
            data.Add("layout", layout);
            data.Add("status", status);
            data.Add("summary", summary);
            data.Add("preconditions", preconditions);
            data.Add("importance", importance);
            data.Add("author_id", author_id);
            data.Add("updater_id", updater_id);
            data.Add("modification_ts", modification_ts);
            data.Add("creation_ts", creation_ts);
            data.Add("is_open", is_open);
            data.Add("execution_type", execution_type);
            data.Add("author_first_name", author_first_name);
            data.Add("author_last_name", author_last_name);
            data.Add("updater_first_name", updater_first_name);
            data.Add("updater_last_name", updater_last_name);

            XmlRpcStruct[] structs = new XmlRpcStruct[]{};
            //add steps

            data.Add("steps", structs);

            var testCase = new Mock<Meyn.TestLink.TestCase>(data);
            return testCase.Object;

            #region commented
            //            active = int.Parse((string)data["active"]) == 1;
            //            externalid = (string)data["tc_external_id"];
            //            id = toInt(data, "id");
            //            updater_login = (string)data["updater_login"];
            //            author_login = (string)data["author_login"];
            //            name = (string)data["name"];
            //            node_order = toInt(data, "node_order");
            //            testsuite_id = toInt(data, "testsuite_id");
            //            testcase_id = toInt(data, "testcase_id");
            //            version = toInt(data, "version");
            //            layout = (string)data["layout"];
            //            status = toInt(data, "status");
            //            summary = (string)data["summary"];
            //            preconditions = (string)data["preconditions"];
            //            importance = toInt(data, "importance");
            //            author_id = toInt(data, "author_id");
            //            updater_id = toInt(data, "updater_id");
            //            modification_ts = base.toDate(data, "modification_ts");
            //            creation_ts = base.toDate(data, "creation_ts");
            //            is_open = int.Parse((string)data["is_open"]) == 1;
            //            execution_type = toInt(data, "execution_type");
            //            author_first_name = (string)data["author_first_name"];
            //            author_last_name = (string)data["author_last_name"];
            //            updater_first_name = (string)data["updater_first_name"];
            //            updater_last_name = (string)data["updater_last_name"];
            //            steps = new List<TestStep>();
            //            XmlRpcStruct[] stepData = data["steps"] as XmlRpcStruct[];
            //            if (stepData != null)
            //                foreach (XmlRpcStruct aStepDatum in stepData)
            //                    steps.Add(new TestStep(aStepDatum));
            #endregion commented
        }
 public void AddInvalidKey()
 {
     XmlRpcStruct xps = new XmlRpcStruct();
       xps.Add(1, "abcdef");
 }
 public void Add()
 {
     XmlRpcStruct xps = new XmlRpcStruct();
       xps.Add("foo", "abcdef");
       Assert.AreEqual("abcdef", xps["foo"]);
 }
        public static Meyn.TestLink.TestSuite GetTestSuite(
            string name,
            int nodeOrder,
            int nodeTypeId,
            int parentId)
        {
            int id = generator.Next(1000000);

            XmlRpcStruct data = new XmlRpcStruct();
            data.Add("name", name);
            data.Add("id", id);
            data.Add("parent_id", parentId);
            data.Add("node_type_id", nodeTypeId);
            data.Add("node_order", nodeOrder);

            var testSuite = new Mock<Meyn.TestLink.TestSuite>(data);
            return testSuite.Object;
        }
   Object ParseHashtable(
 XmlNode node,
 Type valueType,
 ParseStack parseStack,
 MappingAction mappingAction)
   {
       XmlRpcStruct retObj = new XmlRpcStruct();
         parseStack.Push("struct mapped to XmlRpcStruct");
         try
         {
       XmlNodeList members = node.SelectNodes("./member");
       foreach (XmlNode member in members)
       {
         if (member.Name != "member")
       continue;
         XmlNode nameNode;
         bool dupName;
         XmlNode valueNode;
         bool dupValue;
         SelectTwoNodes(member, "name", out nameNode, out dupName, "value",
       out valueNode, out dupValue);
         if (nameNode == null)
       throw new XmlRpcInvalidXmlRpcException(parseStack.ParseType
         + " contains a member with missing name element"
         + " " + StackDump(parseStack));
         if (dupName)
       throw new XmlRpcInvalidXmlRpcException(parseStack.ParseType
         + " contains member with more than one name element"
         + " " + StackDump(parseStack));
         string rpcName = nameNode.FirstChild.Value;
         if (valueNode == null)
       throw new XmlRpcInvalidXmlRpcException(parseStack.ParseType
         + " contains struct member " + rpcName + " with missing value "
         + " " + StackDump(parseStack));
         if (dupValue)
       throw new XmlRpcInvalidXmlRpcException(parseStack.ParseType
         + " contains member with more than one value element"
         + " " + StackDump(parseStack));
         if (retObj.Contains(rpcName))
         {
       if (!IgnoreDuplicateMembers)
         throw new XmlRpcInvalidXmlRpcException(parseStack.ParseType
           + " contains struct value with duplicate member "
           + nameNode.FirstChild.Value
           + " " + StackDump(parseStack));
       else
         continue;
         }
         object valObj;
         parseStack.Push(String.Format("member {0}", rpcName));
         try
         {
       XmlNode vvNode = valueNode.SelectSingleNode("./*");
       if (vvNode == null)
         vvNode = valueNode.FirstChild;
       valObj = ParseValue(vvNode, null, parseStack,
         mappingAction);
         }
         finally
         {
       parseStack.Pop();
         }
         retObj.Add(rpcName, valObj);
       }
         }
         finally
         {
       parseStack.Pop();
         }
         return retObj;
   }
Exemple #37
0
        public void AddInvalidKey()
        {
            XmlRpcStruct xps = new XmlRpcStruct();

            xps.Add(1, "abcdef");
        }