コード例 #1
0
                public TestVariation CreateNewVariation(string descPrefix, string uri)
                {
                    TestVariation variation = new TestVariation(CompareReaders, descPrefix);

                    variation.Attribute = new VariationAttribute(descPrefix + " :: " + uri, new object[] { uri });
                    return(variation);
                }
コード例 #2
0
                public void AddChild(TestFunc myFunction, int priority, string description, params object[] paramList)
                {
                    TestVariation      myVariation = new TestVariation(myFunction);
                    VariationAttribute myAttribute = new VariationAttribute(description, paramList);

                    myAttribute.Priority  = priority;
                    myVariation.Attribute = myAttribute;
                    this.AddChild(myVariation);
                }
コード例 #3
0
    private void InitTest(Test test)
    {
        QuestGraphics.Init(test);
        StartCoroutine(TestTimer(test.timeForQuestionsInSec));

        _currentVariation = Variations.First(x => x.Type == test.typeOfTest);
        _currentVariation.Init();
        _currentVariation.InitAnswers(GetRandomizedList(test.answers));
    }
コード例 #4
0
        internal static ContentPropertyBag ToDriverParameters(Assembly testAssembly, TestVariation variation)
        {
            ContentPropertyBag driverParams = new ContentPropertyBag();

            // Use assembly partial name because we will be loading assembly from the
            // local directory, not the GAC.
            driverParams[targetAssemblyKey] = testAssembly.GetName().Name;
            driverParams[suiteKey]          = variation.TestCase.Suite.GetType().FullName;
            driverParams[testIdKey]         = variation.TestCase.Id;
            driverParams[commandLineKey]    = string.Join(" ", variation.Parameters);
            return(driverParams);
        }
コード例 #5
0
ファイル: AstoriaTestCase.cs プロジェクト: zhonli/odata.net
        public TestVariation GenerateVariation(TestCase testcase, MethodInfo method)
        {
            TestVariation rcTestVariation;
            TestFunc      testMethodAction = delegate()
            {
                method.Invoke(testcase, null);
            };

            rcTestVariation = new TestVariation(testMethodAction);

            rcTestVariation.Params   = this.Params;
            rcTestVariation.Param    = this.Param;
            rcTestVariation.Desc     = this.Desc;
            rcTestVariation.Id       = this.Id;
            rcTestVariation.Priority = this.Priority;

            return(rcTestVariation);
        }
コード例 #6
0
    public async Task Variations_objects()
    {
        var featureDatabase = this.sp.GetRequiredService <InMemoryFeatureDefinitionProvider>();

        var offVariation = new TestVariation {
            Color = Color.Black
        };
        var defaultOnVariation = new TestVariation {
            Color = Color.White
        };
        var halfWayVariation = new TestVariation {
            Color = Color.Gray
        };

        featureDatabase.SetFeature("FeatureA", offValue: offVariation, onValue: defaultOnVariation);

        featureDatabase.SetFeatureGroup("FeatureA", "GroupA", onValue: halfWayVariation);
        featureDatabase.SetFeatureFilter("FeatureA", "Customer", "{ \"Customers\": [\"A\"] }", "GroupA");

        featureDatabase.SetFeatureGroup("FeatureA", "GroupB", onValue: defaultOnVariation);
        featureDatabase.SetFeatureFilter("FeatureA", "Customer", "{ \"Customers\": [\"B\"] }", "GroupB");

        var featureService = this.sp.GetRequiredService <FeatureService>();

        SetCurrentCustomer("A");
        var variation = await featureService.GetValue <TestVariation>("FeatureA");

        Assert.AreEqual(Color.Gray, variation?.Color);
        SetCurrentCustomer("B");
        variation = await featureService.GetValue <TestVariation>("FeatureA");

        Assert.AreEqual(Color.White, variation?.Color);
        SetCurrentCustomer("C");
        variation = await featureService.GetValue <TestVariation>("FeatureA");

        Assert.AreEqual(Color.Black, variation?.Color);
    }
コード例 #7
0
ファイル: AstoriaTestCase.cs プロジェクト: zhonli/odata.net
        protected override void DetermineChildren()
        {
            #region Friendlyfeeds test injection
            bool generateVariation = false;

            foreach (MethodInfo method in this.GetType().GetMethods())
            {
                foreach (VariationAttribute testVarAttrib in
                         method.GetCustomAttributes(typeof(VariationAttribute), false /*inhert*/))
                {
                    if (ShowFFAttributedTests)
                    {
                        //Loop through the Attributes for method
                        foreach (FriendlyFeedsTestVariationAttribute attr in
                                 method.GetCustomAttributes(typeof(FriendlyFeedsTestVariationAttribute), false /*inhert*/))
                        {
                            if (testVarAttrib.Implemented)
                            {
                                //no support for inherited types FF tests in NonClr scenarios
                                generateVariation = (AstoriaTestProperties.DataLayerProviderKinds.Contains(DataLayerProviderKind.NonClr)) &&
                                                    attr.InheritanceFilter == InerhitedTypes.Both || !AstoriaTestProperties.DataLayerProviderKinds.Contains(DataLayerProviderKind.NonClr);


                                generateVariation = AstoriaTestProperties.MaxPriority == 0 ? testVarAttrib.Desc == "Query top level navigation collection sync" : true;
                                //If the DataLayer is NonCLR and we have types which are Open Types,
                                //Any mappings with KeepInContent=False cannot succeed in Queries.
                                if (AstoriaTestProperties.DataLayerProviderKinds.Contains(DataLayerProviderKind.NonClr) &&
                                    AstoriaTestProperties.UseOpenTypes &&
                                    attr.GenerateClientTypes &&
                                    !attr.KeepInContent)
                                {
                                    generateVariation = false;
                                }
                                //if (attr.InheritanceFilter == InerhitedTypes.Both)
                                //{
                                if (generateVariation)
                                {
                                    TestVariation testVariation = attr.GenerateVariation(this, method, testVarAttrib);
                                    if (testVariation != null)
                                    {
                                        this.AddChild(testVariation);
                                    }
                                }
                                //}
                            }
                        }
                    }
                    if (ShowRowCountTests)
                    {
                        //Loop through the Attributes for method
                        foreach (RowCountTestVariationAttribute attr in
                                 method.GetCustomAttributes(typeof(RowCountTestVariationAttribute), false /*inhert*/))
                        {
                            if (attr.Implemented)
                            {
                                TestVariation testVariation = attr.GenerateVariation(this, method);
                                this.AddChild(testVariation);

                                //}
                            }
                        }
                    }
                }
            }
            #endregion
            if (ShowNonFFAttributedTests && !ShowFFAttributedTests)
            {
                //if (!ShowRowCountTests)
                //{
                //    List<RowCountTestVariation> rowCountVariations = this.Children.OfType<RowCountTestVariation>().ToList();
                //    rowCountVariations.ForEach(
                //        rcv =>
                //        {
                //            this.Children.Remove(rcv as VariationAttribute );
                //        }
                //        );
                //}
                base.DetermineChildren();
                //Now determine matrix children
                foreach (MethodInfo method in this.GetType().GetMethods())
                {
                    //Loop through the Attributes for method
                    foreach (MatrixVariationAttribute attr in method.GetCustomAttributes(typeof(MatrixVariationAttribute), false /*inhert*/))
                    {
                        List <TestVariation> variations = attr.EnumerateVariations(this, method);
                        foreach (TestVariation v in variations)
                        {
                            this.AddChild(v);
                        }
                    }
                }
            }

            int index = 0;
            while (index < this.Children.Count)
            {
                TestItem item = (TestItem)this.Children[index];
                //If it's a test case or a variation that is between min and max priority we want to keep it, else remove it from the list
                if (!(item is TestVariation) || item.Children.Count > 0 || (AstoriaTestProperties.MinPriority <= item.Priority && item.Priority <= AstoriaTestProperties.MaxPriority))
                {
                    index++;
                }
                else
                {
                    this.Children.RemoveAt(index);
                }
            }

            if (this.Children.Count <= 0)
            {
                this.Parent.Children.Remove(this);
            }
            else
            {
                this.Children.Sort();
            }
        }
コード例 #8
0
ファイル: AstoriaTestCase.cs プロジェクト: zhonli/odata.net
        public TestVariation GenerateVariation(TestCase testcase, MethodInfo method, VariationAttribute testVarAttrib)
        {
            //do not generate variations for tests which have KeepInContent set to false and the version is not V2
            if (!this.KeepInContent && !Versioning.Server.SupportsV2Features)
            {
                return(null);
            }

            TestVariation ffTestVariation;
            MethodInfo    generateEpmMappingsMethod = testcase.GetType().GetMethod("GenerateEpmMappings");

            FilterResourcesLambda = GenerateLambda();

            TestFunc testMethodAction = delegate()
            {
                bool thisTestFailed = true;

                SkipInvalidRuns();

                try
                {
                    generateEpmMappingsMethod.Invoke(testcase, new object[] {
                        KeepInContent,             //bool pKeepInContent,
                        RemoveUnEligibleTypes,     //bool pRemoveUnEligibleTypes,
                        GenerateClientTypes,       //bool pGenerateClientTypes,
                        MapToAtomElements,         //bool pMapPropertiesToAtomElements,
                        MapToNonAtomElements,      //bool pMapPropertiesToNonAtomElements,
                        GenerateServerEPMMappings, //bool GenerateServerEPMMappings,
                        KeepSameNamespace,         //bool KeepSameNamespace,
                        IncludeComplexTypes,       //bool  IncludeComplexTypes
                        PreDefinedPaths,           //string[] PreDefinedPaths
                        FilterResourcesLambda      //Func<ResourceType, bool> pFilterResourcesLambda
                    });
                    method.Invoke(testcase, null);


                    thisTestFailed = AstoriaTestLog.FailureFound;
                }
                catch (Microsoft.OData.Client.DataServiceClientException dsException)
                {
                    if (dsException.InnerException != null)
                    {
                        AstoriaTestLog.WriteLine(dsException.InnerException.Message);
                    }
                }
                catch (TestFailedException testException)
                {
                    AstoriaTestLog.WriteLine("Test failed  with :{0}", testException.Message);
                    AstoriaTestLog.WriteLine("Repro Details\r\nClient Code");
                }
                finally
                {
                    //Disabling this as OOM errors prevent file copying
                    thisTestFailed = false;
                    #region //Clean out all the facets after the test , so that the next test is clear
                    object       workspacePointer       = null;
                    PropertyInfo testWorkspacesProperty = testcase.Parent.GetType().GetProperty("Workspaces");
                    workspacePointer = testcase.Parent;
                    if (testWorkspacesProperty == null)
                    {
                        testWorkspacesProperty = testcase.GetType().GetProperty("Workspaces");
                        workspacePointer       = testcase;
                    }
                    Workspaces testWorkspaces = (Workspaces)testWorkspacesProperty.GetValue(workspacePointer, null);
                    foreach (Workspace workspace in testWorkspaces)
                    {
                        if (thisTestFailed)
                        {
                            string testFailureReproPath = String.Format("FF_Failure_{0}", System.Guid.NewGuid().ToString());
                            testFailureReproPath = System.IO.Path.Combine(Environment.CurrentDirectory, testFailureReproPath);
                            IOUtil.CopyFolder(workspace.DataService.DestinationFolder, testFailureReproPath, true);
                            AstoriaTestLog.WriteLine("Test failed , Repro available at : {0} ", testFailureReproPath);
                        }

                        if (!(workspace is EdmWorkspace))
                        {
                            workspace.GenerateClientTypes    = true;
                            workspace.GenerateServerMappings = false;
                            workspace.ApplyFriendlyFeeds();
                        }
                    }
                    #endregion
                }
            };

            ffTestVariation = new TestVariation(testMethodAction);
            if (testVarAttrib != null)
            {
                ffTestVariation.Params = testVarAttrib.Params;
                ffTestVariation.Param  = testVarAttrib.Param;
                ffTestVariation.Desc   = String.Format(
                    "{3} , {0},{1},{2},{4}{5}{6}{7}",
                    GenerateClientTypes ? "Client Mapped" : "",
                    GenerateServerEPMMappings ? "Server Mapped" : "",
                    MapToAtomElements ? "Mapped to Atom" : "Mapped to Non-Atom Elements",
                    testVarAttrib.Desc, InheritanceFilter.ToString(),
                    KeepSameNamespace ? "Same Namespace" : "Different NameSpaces",
                    PreDefinedPaths != null ? ",PredefinedPaths" : "", KeepInContent.ToString());
                if (AstoriaTestProperties.MaxPriority == 0)
                {
                    ffTestVariation.Id = 1;
                }
                else
                {
                    ffTestVariation.Id = idCounter++;
                }
                ffTestVariation.Priority = this.Priority;
            }
            return(ffTestVariation);
        }
コード例 #9
0
 public void testNotAvailable(TestVariation variation)
 {
     (Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri("/HomePage.xaml", UriKind.Relative));
 }
コード例 #10
0
 public void testLoaded(String testName, TestVariation variation)
 {
     (Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri("/HomePage.xaml", UriKind.Relative));
 }
コード例 #11
0
ファイル: AstoriaTestModule.cs プロジェクト: zhonli/odata.net
        protected override void DetermineChildren()
        {
            // Use previous settings if  client partial trust level is not medium
            // We only perform client partial-trust test here
            if (AstoriaTestProperties.ServiceTrustLevel != TrustLevel.Medium || (!this.Name.Contains("Client")))
            {
                base.DetermineChildren();
            }

            else
            {
                AppDomain myDomain = this.GetCustomizedAppDomain();
                ArrayList types    = this.GetNestedTypes(this.GetType());
                foreach (Type type in types)
                {
                    //Were only interested in objects that inherit from TestCase.
                    //NOTE: We need to filter other objects, since some internal VB classes throw trying
                    //to get Attributes
                    if (!type.IsSubclassOf(typeof(TestCase)))
                    {
                        continue;
                    }

                    //Every class that has a TestCase attribute, IS a TestCase
                    foreach (TestCaseAttribute attr in type.GetCustomAttributes(typeof(TestCaseAttribute), false /*inhert*/))
                    {
                        //Create this class (call the constructor with no arguments)
                        // Create testcase instance in another app domain with desired permission set.
                        TestCase testcase = (TestCase)myDomain.CreateInstanceAndUnwrap(type.Assembly.FullName, type.FullName);

                        if (attr.Name == null)
                        {
                            attr.Name = type.Name;
                        }
                        testcase.Attribute = attr;
                        this.AddChild(testcase);
                    }
                }

                //Sort
                //Default sort is based upon IComparable of each item
                Children.Sort();
            }


            if (AstoriaTestProperties.RuntimeEnvironment != TestRuntimeEnvironment.CheckinSuites)
            {
                // ensure that we don't get 0/0 = 0% results due to empty test cases
                foreach (TestItem child in this.Children.Cast <TestItem>().Where(c => !Descendents(c).OfType <TestVariation>().Any()))
                {
                    child.Children.Clear();

                    TestFunc      func      = new TestFunc(delegate() { throw new TestSkippedException("Placeholder"); });
                    TestVariation variation = new TestVariation("Placeholder for module with no tests", func);
                    variation.Attribute = new VariationAttribute("Placeholder for module with no tests")
                    {
                        Id          = 1,
                        Implemented = true,
                        Priority    = AstoriaTestProperties.MinPriority
                    };

                    variation.Parent = child;
                    child.AddChild(variation);
                }
            }
        }