Exemplo n.º 1
0
        public void PrintSchema_DoesntPrintSchemaOfCommonNames()
        {
            this.schema = new GraphQLSchema();

            var query = new TestObjectType("Query", this.schema);

            query.Field("foo", () => default(string));
            this.schema.Query(query);

            var mutation = new TestMutationType("Mutation", this.schema);

            mutation.Field("foo", () => default(int));
            this.schema.Mutation(mutation);

            var subscription = new TestSubscriptionType("Subscription", this.schema);

            subscription.Field("foo", () => default(ID));
            this.schema.Subscription(subscription);

            var result = SchemaUtils.PrintSchema(this.schema);

            this.AreEqual(@"
            type Mutation {
              foo: Int!
            }

            type Query {
              foo: String
            }

            type Subscription {
              foo: ID!
            }", result);
        }
        private async Task ExecuteAttachmentCleanup(IEnumerable <ITestRunBase> runs, TestObjectType type)
        {
            int count = runs.Count <ITestRunBase>();

            ProgressText       = string.Format("Found {0} items of type {1}", count, type);
            ProgressTotalItems = count;
            ProgressValue      = 0;

            foreach (ITestRunBase run in runs)
            {
                if (IsCancelPending())
                {
                    break;
                }

                ProgressValue++;
                if (!this.MatchesDateRange(run))
                {
                    continue;
                }

                List <ITestAttachment> runAttachments = await GetRunAddtionalData(run, type);

                if (runAttachments == null || runAttachments.Count == 0)
                {
                    continue;
                }

                List <WorkItem> relatedWorkitems = await GetRelatedWorkItems(run, runAttachments);

                TestRunAttachmentsInfo.Add(new TestRunAttachmentInfo(run, type, runAttachments, relatedWorkitems));

                SetTotalSize();
            }
        }
        public TestRunAttachmentInfo(ITestRunBase run, TestObjectType type, List<ITestAttachment> attachments, List<WorkItem> relatedWorkitems)
        {
            Run = run;
            Type = type;
            MatchedAttachments = attachments;
            RelatedWorkitems = relatedWorkitems;

            Title = Run.Title;
            Owner = run.OwnerName;
            DateStarted = Run.DateStarted;

            FormatLength = string.Format(new FileSizeFormatProvider(), "{0:fs}", attachments.Sum(attachment => attachment.Length));
        }
        public TestRunAttachmentInfo(ITestRunBase run, TestObjectType type, List <ITestAttachment> attachments, List <WorkItem> relatedWorkitems)
        {
            Run  = run;
            Type = type;
            MatchedAttachments = attachments;
            RelatedWorkitems   = relatedWorkitems;

            Title       = Run.Title;
            Owner       = run.OwnerName;
            DateStarted = Run.DateStarted;

            FormatLength = string.Format(new FileSizeFormatProvider(), "{0:fs}", attachments.Sum(attachment => attachment.Length));
        }
Exemplo n.º 5
0
        public void PrintSchema_PrintsOperationDefinitions()
        {
            this.schema = new GraphQLSchema();

            var query = new TestObjectType("QueryRoot", this.schema);

            query.Field("foo", () => default(string));
            this.schema.Query(query);

            var mutation = new TestMutationType("MutationRoot", this.schema);

            mutation.Field("foo", () => default(int));
            this.schema.Mutation(mutation);

            var subscription = new TestSubscriptionType("SubscriptionRoot", this.schema);

            subscription.Field("foo", () => default(ID));
            this.schema.Subscription(subscription);

            var result = SchemaUtils.PrintSchema(this.schema);

            this.AreEqual(@"
            schema {
              query: QueryRoot
              mutation: MutationRoot
              subscription: SubscriptionRoot
            }

            type MutationRoot {
              foo: Int!
            }

            type QueryRoot {
              foo: String
            }

            type SubscriptionRoot {
              foo: ID!
            }", result);
        }
Exemplo n.º 6
0
        public void PrintSchema_PrintsMultipleInterfaces()
        {
            new TestInterfaceType <IFoo>("Foo", this.schema)
            .Field("str", e => default(string));
            new TestInterfaceType <IBaaz>("Baaz", this.schema)
            .Field("int", e => default(int?));
            var bar = new TestObjectType <BarIFooIBaaz>("Bar", this.schema);

            bar.Field("str", () => default(string));
            bar.Field("int", () => default(int?));
            this.root.Field("bar", () => default(BarIFooIBaaz));

            var result = SchemaUtils.PrintSchema(this.schema);

            this.AreEqual(@"
            schema {
              query: Root
            }

            interface Baaz {
              int: Int
            }

            type Bar implements Foo, Baaz {
              str: String
              int: Int
            }

            interface Foo {
              str: String
            }

            type Root {
              bar: Bar
            }
            ", result);
        }
Exemplo n.º 7
0
 public static IEnumerable<ITestAttachment> CreateAttachmentsQuery(int runId, TestObjectType type)
 {
     string str = (type == TestObjectType.TestRun) ? "TestRunId" : "SessionId";
     StringBuilder sb = new StringBuilder(string.Format(CultureInfo.InvariantCulture, "SELECT * FROM Attachment WHERE {0} = {1} ", str, runId));
     return TfsShared.Instance.TestProject.QueryAttachments(sb.ToString());
 }
        private async Task <List <ITestAttachment> > GetRunAddtionalData(ITestRunBase run, TestObjectType type)
        {
            try
            {
                ProgressText = string.Format("Collecting attachments for Test Run: {0}", run.Title);
                List <ITestAttachment> runAttachments = new List <ITestAttachment>();
                //IEnumerable<ITestAttachment> attachments = null;
                await Task.Run(() =>
                {
                    //attachments = TestQueryHelper.CreateAttachmentsQuery(run.Id, type);

                    foreach (ITestAttachment attachment in run.Attachments)
                    {
                        if (IsCancelPending())
                        {
                            break;
                        }

                        if ((attachment.Length / 1024f) / 1024f >= MinimumSize && Extensions.Where(s => s.IsSelected).
                            Any(e => e.Title.Equals(Any) ||
                                (e.IsSelected && attachment.Name.EndsWith("." + e.Title))))
                        {
                            runAttachments.Add(attachment);
                        }
                    }
                });

                return(runAttachments);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
        private async Task<List<ITestAttachment>> GetRunAddtionalData(ITestRunBase run, TestObjectType type)
        {
            try
            {
                ProgressText = string.Format("Collecting attachments for Test Run: {0}", run.Title);
                List<ITestAttachment> runAttachments = new List<ITestAttachment>();
                //IEnumerable<ITestAttachment> attachments = null;
                await Task.Run(() =>
                {
                    //attachments = TestQueryHelper.CreateAttachmentsQuery(run.Id, type);

                    foreach (ITestAttachment attachment in run.Attachments)
                    {
                        if (IsCancelPending()) break;

                        if ((attachment.Length / 1024f) / 1024f >= MinimumSize && Extensions.Where(s=>s.IsSelected).
                                                                                  Any(e => e.Title.Equals(Any) || 
                                                                                  (e.IsSelected && attachment.Name.EndsWith("." + e.Title))))
                            runAttachments.Add(attachment);
                    }
                });

                return runAttachments;
            }
            catch (Exception ex)
            {
                return null;
            }
        }
Exemplo n.º 10
0
        private async Task ExecuteAttachmentCleanup(IEnumerable<ITestRunBase> runs, TestObjectType type)
        {
            int count = runs.Count<ITestRunBase>();
            ProgressText = string.Format("Found {0} items of type {1}", count, type);
            ProgressTotalItems = count;
            ProgressValue = 0;

            foreach (ITestRunBase run in runs)
            {
                if (IsCancelPending()) break;

                ProgressValue++;
                if (!this.MatchesDateRange(run)) continue;

                List<ITestAttachment> runAttachments = await GetRunAddtionalData(run, type);
                if (runAttachments == null || runAttachments.Count == 0) continue;

                List<WorkItem> relatedWorkitems = await GetRelatedWorkItems(run, runAttachments);

                TestRunAttachmentsInfo.Add(new TestRunAttachmentInfo(run, type, runAttachments, relatedWorkitems));

                SetTotalSize();
            }
        }
Exemplo n.º 11
0
 public TestObject(string name, int id, TestObjectType type)
 {
     this.Name = name;
     this.ID = id;
     this.Type = type;
 }
Exemplo n.º 12
0
        public static IEnumerable <ITestAttachment> CreateAttachmentsQuery(int runId, TestObjectType type)
        {
            string        str = (type == TestObjectType.TestRun) ? "TestRunId" : "SessionId";
            StringBuilder sb  = new StringBuilder(string.Format(CultureInfo.InvariantCulture, "SELECT * FROM Attachment WHERE {0} = {1} ", str, runId));

            return(TfsShared.Instance.TestProject.QueryAttachments(sb.ToString()));
        }
Exemplo n.º 13
0
 public TestObject(string name, int id, TestObjectType type)
 {
     this.Name = name;
     this.ID   = id;
     this.Type = type;
 }
Exemplo n.º 14
0
        /// <summary>
        /// Add the parameter assignments to the specified constructor expression.
        /// </summary>
        /// <param name="visibility">A bit mask comprised of one or more <see cref="BindingFlags"/>
        /// that specify how the search of member types is conducted.  -or- Zero, to return <c>null</c>.</param>
        /// <returns>
        /// A structure with data about parameter initialization for the type of test object of this instance.
        /// </returns>
        /// <exception cref="InvalidOperationException">No preferred constructor found, but there should one.</exception>
        private ConstructorAssignmentCollection AddParametersToConstructor(MemberVisibility visibility)
        {
            var bindingAttr = BindingFlags.Instance;
            var noPrivate   = true;

            switch (visibility)
            {
            case MemberVisibility.Public:
                bindingAttr |= BindingFlags.Public;
                break;

            case MemberVisibility.Internal:
                bindingAttr |= BindingFlags.Public | BindingFlags.NonPublic;
                break;

            case MemberVisibility.Private:
                bindingAttr |= BindingFlags.Public | BindingFlags.NonPublic;
                noPrivate    = false;
                break;

            default:
                break;
            }

            /*if ((visibility & MemberVisibility.Public) == MemberVisibility.Public)
             * {
             *  bindingAttr |= BindingFlags.Public;
             * }
             * if ((visibility & MemberVisibility.Internal) == MemberVisibility.Internal)
             * {
             *  bindingAttr |= BindingFlags.NonPublic;
             * }
             * if ((visibility & MemberVisibility.Private) == MemberVisibility.Private)
             * {
             *  bindingAttr |= BindingFlags.NonPublic;
             *  noPrivate = false;
             * }*/

            var testObjectConstructors = TestObjectType.GetConstructors(bindingAttr);

            // var ctorParameterTypes = new List<ParameterInfo>();
            if (testObjectConstructors.Length < 1)
            {
                return(null);
            }

            // for now, use to ctor with the most parameters.
            // foreach testObjectConstructors
            // var most = testObjectConstructors.Max(e => e.GetParameters().Length);
            // var constructor = testObjectConstructors.Where(e => e.GetParameters().Length == most).First();
            var tempAssignments = new List <AssignmentInfoCollection>();
            int most            = -1;
            AssignmentInfoCollection mostAssignmentInfoCollection = null;

            foreach (var constructor in testObjectConstructors)
            {
                if (noPrivate && constructor.IsPrivate)
                {
                    continue;
                }

                var assignmentInfoCollection = this.BuildAssignmentInfoForConstructor(bindingAttr, constructor);
                int parameterAmount          = constructor.GetParameters().Length;
                if (parameterAmount > most)
                {
                    if (mostAssignmentInfoCollection != null)
                    {
                        // here comes a new bigger one. put the old to the temp list.
                        tempAssignments.Add(mostAssignmentInfoCollection);
                    }
                    most = parameterAmount;
                    mostAssignmentInfoCollection = assignmentInfoCollection;
                    // tempAssignments.Add(assignmentInfoCollection);
                }
                else
                {
                    tempAssignments.Add(assignmentInfoCollection);
                }
            }

            if (mostAssignmentInfoCollection == null)
            {
                throw new InvalidOperationException("No preferred constructor found, but there should one.");
            }

            var result = new ConstructorAssignmentCollection(mostAssignmentInfoCollection);

            result.AddConstructorAssignment(tempAssignments);

            return(result);
        }