Esempio n. 1
0
 public void AcceptSegmentInheritanceFilter(InheritanceFilter inheritanceFilter, PrintContext parameter)
 {
     parameter.WriteLine("Inheritance Filter: {0} entries", inheritanceFilter.Items.Length);
     parameter.BeginLevel();
     foreach (var item in inheritanceFilter.Items)
     {
         parameter.WriteLine("{0}: {1}", item.Designator, item.Setting);
     }
     parameter.EndLevel();
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 public virtual void AcceptSegmentInheritanceFilter(InheritanceFilter inheritanceFilter, T parameter)
 {
     // intentionally left blank
 }