public static void AssemblyInitialize(TestContext context)
        {
            CredentialsStore credentials = CredentialsProvider.Read(@"..\..\..\RestCredentials.xml");

            RestClientManager.BasicAuthorizationUsername = credentials.BasicAuthorizationUsername;
            RestClientManager.BasicAuthorizationPassword = credentials.BasicAuthorizationPassword;
        }
예제 #2
0
        public void GetWorkItem_UnitTest2()
        {
            IWorkItemStore   instance    = GetTestInstance();
            CredentialsStore credentials = CredentialsProvider.Read(@"..\..\..\RestCredentials.xml");
            IWorkItem        actual      = instance.GetWorkItem(new Uri(credentials.VsoCollection));

            Assert.IsNotNull(actual);
        }
예제 #3
0
        internal static WorkItemStore GetRealInstance()
        {
            CredentialsStore credentials = CredentialsProvider.Read(@"..\..\..\RestCredentials.xml");
            var uri  = new Uri(credentials.VsoCollection);
            var tpc  = new TfsTeamProjectCollection(uri);
            var real = tpc.GetService <WorkItemStore>();

            return(real);
        }
        public void Read_UnitTest()
        {
            String           filePath = default(String);
            CredentialsStore _retVal  = default(CredentialsStore);

            ExecuteMethod(
                () =>
            {
                filePath = default(String);     //No Constructor
                Read_PreCondition(ref filePath);
            },
                () => { _retVal = CredentialsProvider.Read(filePath); },
                () => { Read_PostValidate(filePath, _retVal); });
        }
예제 #5
0
        public void ReadAllProperties_UnitTest()
        {
            CredentialsStore credentials = CredentialsProvider.Read(@"..\..\..\RestCredentials.xml");
            var uri = new Uri(credentials.VsoCollection);
            var tpc = new TfsTeamProjectCollection(uri);

            tpc.EnsureAuthenticated();
            var                 workItemStore = tpc.GetService <WorkItemStore>();
            const string        wiql          = "SELECT [System.Id], [System.WorkItemType], [System.Title], [System.AssignedTo], [System.State], [System.Tags] FROM WorkItems";
            WorkItemCollection  real          = workItemStore.Query(wiql);
            IWorkItemCollection instance      = WorkItemCollectionWrapper.GetWrapper(real);

            ReadAllProperties(typeof(IWorkItemCollection), instance);
        }
예제 #6
0
        /// <summary>
        ///     Finds the type of the work item.
        /// </summary>
        /// <param name="workItemTypeName">Name of the work item type.</param>
        /// <returns>WorkItemType.</returns>
        internal static WorkItemType FindWorkItemType(string workItemTypeName)
        {
            CredentialsStore credentials = CredentialsProvider.Read(@"..\..\..\RestCredentials.xml");
            var uri = new Uri(credentials.VsoCollection);
            var tpc = new TfsTeamProjectCollection(uri);

            tpc.EnsureAuthenticated();
            var                    workItemStore = tpc.GetService <WorkItemStore>();
            const string           projectName   = "RestPlaypen";
            Project                item          = workItemStore.Projects[projectName];
            WorkItemTypeCollection workItemTypes = item.WorkItemTypes;
            WorkItemType           workItemType  = workItemTypes.Cast <WorkItemType>().First(entry => entry.Name == workItemTypeName);

            return(workItemType);
        }
예제 #7
0
        public static void AssemblyInitialize(TestContext context)
        {
            //CredentialsStore credentials = new CredentialsStore();
            //credentials.BasicAuthorizationUsername = "******";
            //credentials.BasicAuthorizationPassword = "******";
            //credentials.VsoCollection = "https://*****.visualstudio.com/defaultcollection";
            //CredentialsProvider.Write(@"..\..\RestCredentials.xml", credentials);
            CredentialsStore credentials = CredentialsProvider.Read(@"..\..\..\RestCredentials.xml");

            RestClientManager.BasicAuthorizationUsername = credentials.BasicAuthorizationUsername;
            RestClientManager.BasicAuthorizationPassword = credentials.BasicAuthorizationPassword;
            VSOClientManager.VsoCollection = credentials.VsoCollection;

            StructuredExchangeLogger.Install();
        }
        public void ReadWrite_UnitTest()
        {
            const string fileName   = "ReST_Credentiials.xml";
            var          sourceData = new CredentialsStore();

            sourceData.BasicAuthorizationUsername = "******";
            sourceData.BasicAuthorizationPassword = "******";
            sourceData.VsoCollection = "MyVsoCollection";
            Assert.AreEqual(3, sourceData.Values.Count);
            CredentialsProvider.Write(fileName, sourceData);
            CredentialsStore resultData = CredentialsProvider.Read(fileName);

            Assert.AreEqual(sourceData.BasicAuthorizationUsername, resultData.BasicAuthorizationUsername);
            Assert.AreEqual(sourceData.BasicAuthorizationPassword, resultData.BasicAuthorizationPassword);
            Assert.AreEqual(sourceData.VsoCollection, resultData.VsoCollection);
        }
예제 #9
0
        static partial void RealInstanceFactory(ref IMetadataRowSets real, string callerName)
        {
            CredentialsStore credentials = CredentialsProvider.Read(@"..\..\..\RestCredentials.xml");
            var uri = new Uri(credentials.VsoCollection);
            var tpc = new TfsTeamProjectCollection(uri);

            var workitemserver = tpc.GetService <WorkItemServer>();
            var workitemstore  = tpc.GetService <WorkItemStore>();
            var id             = 1;
            var workitem       = workitemstore.GetWorkItem(id);


            // When you call update you need to pass the revision number that you want to update.
            // Most of the time ist t makes sense to use the latest revision, which is stored in the Rev property
            var revision = workitem.Rev.ToString();
            var date     = DateTime.Today;

            // Create the xml package that is needed when calling the server to update a readonly field.
            // Make sure you pass in the date using XmlConvert.ToString(date, XmlDateTimeSerializationMode.Local)
            // You won't get the correct date if you just call date.ToString()
            var sb = new StringBuilder();

            sb.Append("<Package>");
            sb.AppendFormat("<UpdateWorkItem ObjectType='WorkItem' BypassRules='1' WorkItemID='{0}' Revision='{1}'>", id, revision);
            sb.Append("<Columns>");
            sb.AppendFormat("<Column Column='System.CreatedDate' Type='DateTime'><Value>{0}</Value></Column>",
                            XmlConvert.ToString(date, XmlDateTimeSerializationMode.Local));
            sb.Append("</Columns></UpdateWorkItem></Package>");

            /* This is what the XML looks like
             *  <Package>
             *    <UpdateWorkItem ObjectType='WorkItem' BypassRules='1' WorkItemID='1279424' Revision='11'>
             *      <Columns>
             *         <Column Column='System.CreatedDate' Type='DateTime'><Value>1/1/2012 1:01:01 AM</Value></Column>
             *      </Columns>
             *    </UpdateWorkItem>
             *  </Package>
             */


            // Initialize the params that are needed for the service call
            var mthe = new MetadataTableHaveEntry[0];

            // Load the xml string into an XmlDocument so you can pull the document Element that
            // the service call needs
            var x = new XmlDocument();

            x.LoadXml(sb.ToString());


            IMetadataRowSets metadata;
            string           dbStamp;
            int        count;
            DateTime   asOfDate;
            string     requestId = "";
            XmlElement psQuery   = (XmlElement)x.FirstChild;
            bool       useMaster = true;

            workitemserver.QueryWorkitemCount(requestId, psQuery, useMaster, out count, out asOfDate, new MetadataTableHaveEntry[] {}, out dbStamp, out metadata);

            real = metadata;
        }
        partial void VsoCollection_SetCondition(ref String setValue)
        {
            CredentialsStore credentials = CredentialsProvider.Read(@"..\..\..\RestCredentials.xml");

            setValue = credentials.VsoCollection;
        }