Пример #1
0
        private IEnumerable <ApiTestData> GetResults()
        {
            using (AssemblyLoader assemblyLoader = new AssemblyLoader())
            {
                object[] customAttributes = GetType().GetCustomAttributes(typeof(ApiTestAttribute), true);
                if (customAttributes.Length == 0)
                {
                    throw new Exception(string.Format("The test class should define the {0} at least once", typeof(ApiTestAttribute)));
                }
                foreach (object customAttribute in customAttributes)
                {
                    ApiTestAttribute apiTestAttribute = (ApiTestAttribute)customAttribute;

                    Stream comparerConfigurationStream          = GetReadStream(apiTestAttribute.ComparerConfigurationPath);
                    ComparerConfiguration comparerConfiguration = ConfigurationLoader.LoadComparerConfiguration(comparerConfigurationStream);

                    ApiComparer apiComparer = ApiComparer.CreateInstance(assemblyLoader.ReflectionOnlyLoad(apiTestAttribute.ReferenceVersionPath),
                                                                         assemblyLoader.ReflectionOnlyLoad(apiTestAttribute.NewVersionPath))
                                              .WithComparerConfiguration(comparerConfiguration)
                                              .Build();
                    apiComparer.CheckApi();
                    yield return(new ApiTestData(apiComparer.ComparerResult, apiTestAttribute.Category, apiTestAttribute.Explicit, apiTestAttribute.HandleWarningsAsErrors));
                }
            }
        }
Пример #2
0
 private IEnumerable <ApiTestData> GetResults()
 {
     using (AssemblyLoader assemblyLoader = new AssemblyLoader())
     {
         object[] customAttributes = GetType().GetCustomAttributes(typeof(ApiTestAttribute), true);
         if (customAttributes.Length == 0)
         {
             throw new Exception(string.Format("The test class should define the {0} at least once", typeof(ApiTestAttribute)));
         }
         foreach (object customAttribute in customAttributes)
         {
             ApiTestAttribute apiTestAttribute = (ApiTestAttribute)customAttribute;
             ApiComparer      apiComparer      = ApiComparer.CreateInstance(assemblyLoader.ReflectionOnlyLoad(apiTestAttribute.ReferenceVersionPath),
                                                                            assemblyLoader.ReflectionOnlyLoad(apiTestAttribute.NewVersionPath))
                                                 .Build();
             apiComparer.CheckApi();
             IList <string> ignoreList = IgnoreListLoader.LoadIgnoreList(GetReadStream(apiTestAttribute.IgnoreListPath));
             yield return(new ApiTestData(apiComparer.ComparerResult, apiTestAttribute.Category, ignoreList, apiTestAttribute.Explicit));
         }
     }
 }