Exemple #1
0
 public static void RunFixture(IFixtureData fd)
 {
     foreach (var td in fd.Tests)
     {
         RunTest(td);
     }
 }
        public static bool ReadTest(MethodInfo test, IFixtureData data, string workingDirectory)
        {
            //set the default modelPath to the empty.rfa file that will live in the build directory
            string modelPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "empty.rfa");

            var testModelAttribs = test.GetCustomAttributes(typeof(TestModelAttribute), false);

            if (testModelAttribs.Any())
            {
                //overwrite the model path with the one
                //specified in the test model attribute
                modelPath = Path.GetFullPath(Path.Combine(workingDirectory, ((TestModelAttribute)testModelAttribs[0]).Path));
            }

            var runDynamoAttribs = test.GetCustomAttributes(typeof(RunDynamoAttribute), false);
            var runDynamo        = false;

            if (runDynamoAttribs.Any())
            {
                runDynamo = ((RunDynamoAttribute)runDynamoAttribs[0]).RunDynamo;
            }

            var testData = new TestData(data, test.Name, modelPath, runDynamo);

            data.Tests.Add(testData);

            return(true);
        }
Exemple #3
0
 public void LoadData(IFixtureData ifixtureData, string[] fixture)
 {
     foreach (string st in fixture)
     {
         ifixtureData.Add(GetColumns(st));
     }
 }
Exemple #4
0
        private static bool ReadTest(MethodInfo test, IFixtureData data)
        {
            var testModelAttribs = test.GetCustomAttributes(typeof(TestModelAttribute), false);

            if (!testModelAttribs.Any())
            {
                //Console.WriteLine("The specified test does not have the required TestModelAttribute.");
                return(false);
            }

            var modelPath = Path.GetFullPath(Path.Combine(_workingDirectory, ((TestModelAttribute)testModelAttribs[0]).Path));

            var runDynamoAttribs = test.GetCustomAttributes(typeof(RunDynamoAttribute), false);
            var runDynamo        = false;

            if (runDynamoAttribs.Any())
            {
                runDynamo = ((RunDynamoAttribute)runDynamoAttribs[0]).RunDynamo;
            }

            var testData = new TestData(data, test.Name, modelPath, runDynamo);

            data.Tests.Add(testData);

            return(true);
        }
        public TestData(IFixtureData fixture, string name, string modelPath, bool runDynamo)
        {
            Fixture     = fixture;
            Name        = name;
            ModelPath   = modelPath;
            RunDynamo   = runDynamo;
            _testStatus = TestStatus.None;
            ResultData  = new ObservableCollection <IResultData>();

            ResultData.CollectionChanged += ResultDataOnCollectionChanged;
        }
        public static bool ReadTest(MethodInfo test, IFixtureData data, string workingDirectory)
        {
            //set the default modelPath to the empty.rfa file that will live in the build directory
            string modelPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "empty.rfa");

            var testAttribs = CustomAttributeData.GetCustomAttributes(test);

            var testModelAttrib =
                testAttribs.FirstOrDefault(x => x.Constructor.DeclaringType.Name == "TestModelAttribute");

            if (testModelAttrib != null)
            {
                //overwrite the model path with the one
                //specified in the test model attribute
                var relModelPath = testModelAttrib.ConstructorArguments.FirstOrDefault().Value.ToString();
                modelPath = Path.GetFullPath(Path.Combine(workingDirectory, relModelPath));
            }

            var runDynamoAttrib =
                testAttribs.FirstOrDefault(x => x.Constructor.DeclaringType.Name == "RunDynamoAttribute");

            var runDynamo = false;
            if (runDynamoAttrib != null)
            {
                runDynamo = Boolean.Parse(runDynamoAttrib.ConstructorArguments.FirstOrDefault().Value.ToString());
            }

            var testData = new TestData(data, test.Name, modelPath, runDynamo);
            data.Tests.Add(testData);

            var category = string.Empty;
            var categoryAttribs =
                testAttribs.Where(x => x.Constructor.DeclaringType.Name == "CategoryAttribute");
            foreach (var categoryAttrib in categoryAttribs)
            {
                category = categoryAttrib.ConstructorArguments.FirstOrDefault().Value.ToString();
                if (!String.IsNullOrEmpty(category))
                {
                    var cat = data.Assembly.Categories.FirstOrDefault(x => x.Name == category);
                    if (cat != null)
                    {
                        cat.Tests.Add(testData);
                    }
                    else
                    {
                        var catData = new CategoryData(data.Assembly, category);
                        catData.Tests.Add(testData);
                        data.Assembly.Categories.Add(catData);
                    }
                }
            }

            return true;
        }
        public void RunFixture(IFixtureData fd)
        {
            if (!File.Exists(AddinPath))
            {
                CreateAddin(AddinPath, AssemblyPath);
            }

            foreach (var td in fd.Tests)
            {
                RunTest(td);
            }
        }
        private static void AddWithCategory(IFixtureData data, string category, TestData testData)
        {
            var cat = data.Assembly.Categories.FirstOrDefault(x => x.Name == category);

            if (cat != null)
            {
                cat.Tests.Add(testData);
            }
            else
            {
                var catData = new CategoryData(data.Assembly, category);
                catData.Tests.Add(testData);
                data.Assembly.Categories.Add(catData);
            }
        }
Exemple #9
0
        public void GetAsHtmlTable(IFixtureData list, ref StringBuilder result)
        {
            int maxCol = list.MaxColumn;

            for (int rowIdx = 0; rowIdx < list.Count; rowIdx++)
            {
                string[] cols = list[rowIdx];

                var sb = new StringBuilder();
                for (int colIdx = 0; colIdx < cols.GetLength(0); colIdx++)
                {
                    string col = cols[colIdx];
                    if (colIdx == cols.GetLength(0) - 1)
                    {
                        int elapsedCnt = maxCol - cols.GetLength(0) + 1;
                        if (cols.GetLength(0) == 1)
                        {
                            elapsedCnt = maxCol;
                        }
                        sb.Append(GetColumnTag(col, elapsedCnt));
                    }
                    else
                    {
                        sb.Append(GetColumnTag(col, 0));
                    }
                }


                if (rowIdx == 0)
                {
                    result.Append(GetTableStartTag() + GetRowTag(sb.ToString()));
                }
                else if (rowIdx == list.Count - 1)
                {
                    result.Append(GetRowTag(sb.ToString()) + GetTableEndTag());
                }
                else
                {
                    result.Append(GetRowTag(sb.ToString()));
                }
            }
            if (list.Count == 1)
            {
                result.Append(GetTableEndTag());
            }
        }
Exemple #10
0
        /// <summary>
        /// Setup all tests in a selected fixture.
        /// </summary>
        /// <param name="fd"></param>
        /// <param name="continuous"></param>
        private void SetupFixtureTests(IFixtureData fd, bool continuous = false)
        {
            if (fd.ShouldRun == false)
                return;

            SetupIndividualTests(fd.Tests.ToList(), continuous);
        }
        public void RunFixture(IFixtureData fd)
        {
            if (!File.Exists(AddinPath))
            {
                CreateAddin(AddinPath, AssemblyPath);
            }

            foreach (var td in fd.Tests)
            {
                RunTest(td);
            }
        }
Exemple #12
0
        private static bool ReadTest(MethodInfo test, IFixtureData data)
        {
            var testModelAttribs =  test.GetCustomAttributes(typeof(TestModelAttribute), false);
            if (!testModelAttribs.Any())
            {
                Console.WriteLine("The specified test does not have the required TestModelAttribute.");
                return false;
            }

            var modelPath = Path.GetFullPath(Path.Combine(_workingDirectory, ((TestModelAttribute)testModelAttribs[0]).Path));

            var runDynamoAttribs = test.GetCustomAttributes(typeof(RunDynamoAttribute),false);
            var runDynamo = false;
            if (runDynamoAttribs.Any())
            {
                runDynamo = ((RunDynamoAttribute)runDynamoAttribs[0]).RunDynamo;
            }

            var testData = new TestData(data, test.Name, modelPath, runDynamo);
            data.Tests.Add(testData);

            return true;
        }
Exemple #13
0
 public FixtureTable(string name)
     : base(name)
 {
     _fixtureData = new FixtureData(name);
 }
        public static bool ReadTest(MethodInfo test, IFixtureData data, string workingDirectory)
        {
            List <string> modelPaths = new List <string>();

            var testAttribs = CustomAttributeData.GetCustomAttributes(test);

            if (testAttribs.Any(x => x.Constructor.DeclaringType.Name == nameof(IgnoreAttribute)))
            {
                return(false);
            }

            var testModelAttrib = testAttribs.FirstOrDefault(x => x.Constructor.DeclaringType.Name == nameof(TestModelAttribute));

            if (testModelAttrib != null)
            {
                string absolutePath;

                // We can't get the instantiated attribute from the assembly because we performed a ReflectionOnly load
                TestModelAttribute testModelAttribute = new TestModelAttribute((string)testModelAttrib.ConstructorArguments.First().Value);

                if (Path.IsPathRooted(testModelAttribute.Path))
                {
                    absolutePath = testModelAttribute.Path;
                }
                else
                {
                    if (workingDirectory == null)
                    {
                        // If the working directory is not specified.
                        // Add the relative path to the assembly's path.
                        absolutePath = Path.GetFullPath(
                            Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), testModelAttribute.Path));
                    }
                    else
                    {
                        absolutePath = Path.GetFullPath(Path.Combine(workingDirectory, testModelAttribute.Path));
                    }
                }

                if (testModelAttribute.IsWildcard)
                {
                    string[] modelFiles = null;
                    try
                    {
                        modelFiles = Directory.GetFiles(Path.GetDirectoryName(absolutePath), Path.GetFileName(absolutePath), SearchOption.AllDirectories);
                    }
                    catch
                    {
                        // Means folder doesn't exist
                    }

                    if (modelFiles == null || modelFiles.Length == 0)
                    {
                        modelFiles = new string[] { absolutePath };
                    }

                    modelPaths.AddRange(modelFiles);
                }
                else
                {
                    modelPaths.Add(absolutePath);
                }
            }
            else
            {
                //set the default modelPath to the empty.rfa file that will live in the build directory
                modelPaths.Add(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "empty.rfa"));
            }

            var runDynamoAttrib = testAttribs.FirstOrDefault(x => x.Constructor.DeclaringType.Name == nameof(RunDynamoAttribute));
            var runDynamo       = false;

            if (runDynamoAttrib != null)
            {
                runDynamo = (bool)runDynamoAttrib.ConstructorArguments.FirstOrDefault().Value;
            }

            foreach (string modelPath in modelPaths)
            {
                var testData = new TestData(data, test.Name, modelPath, runDynamo);
                data.Tests.Add(testData);

                const string EmptyCategory = "[NO CATEGORY]";

                var category        = string.Empty;
                var categoryAttribs =
                    testAttribs.Where(x => x.Constructor.DeclaringType.Name == nameof(CategoryAttribute));

                if (categoryAttribs.Any())
                {
                    foreach (var categoryAttrib in categoryAttribs)
                    {
                        category = categoryAttrib.ConstructorArguments.FirstOrDefault().Value.ToString();
                        if (String.IsNullOrEmpty(category))
                        {
                            category = EmptyCategory;
                        }

                        AddWithCategory(data, category, testData);
                    }
                }
                else
                {
                    AddWithCategory(data, EmptyCategory, testData);
                }

                Console.WriteLine($"Loaded test: {testData} ({modelPath})");
            }

            return(true);
        }
Exemple #15
0
        public TestData(IFixtureData fixture, string name, string modelPath, bool runDynamo)
        {
            Fixture = fixture;
            Name = name;
            ModelPath = modelPath;
            RunDynamo = runDynamo;
            _testStatus = TestStatus.None;
            ResultData = new ObservableCollection<IResultData>();

            ResultData.CollectionChanged += ResultDataOnCollectionChanged;
        }
Exemple #16
0
 public static void RunFixture(IFixtureData fd)
 {
     foreach (var td in fd.Tests)
     {
         RunTest(td);
     }
 }
Exemple #17
0
        public static bool ReadTest(MethodInfo test, IFixtureData data, string workingDirectory)
        {
            //set the default modelPath to the empty.rfa file that will live in the build directory
            string modelPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "empty.rfa");

            var testAttribs = CustomAttributeData.GetCustomAttributes(test);

            var testModelAttrib =
                testAttribs.FirstOrDefault(x => x.Constructor.DeclaringType.Name == "TestModelAttribute");

            if (testModelAttrib != null)
            {
                //overwrite the model path with the one
                //specified in the test model attribute
                var relModelPath = testModelAttrib.ConstructorArguments.FirstOrDefault().Value.ToString();
                if (workingDirectory == null)
                {
                    // If the working directory is not specified.
                    // Add the relative path to the assembly's path.
                    modelPath =
                        Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                                                      relModelPath));
                }
                else
                {
                    modelPath = Path.GetFullPath(Path.Combine(workingDirectory, relModelPath));
                }
            }

            var runDynamoAttrib =
                testAttribs.FirstOrDefault(x => x.Constructor.DeclaringType.Name == "RunDynamoAttribute");

            var runDynamo = false;

            if (runDynamoAttrib != null)
            {
                runDynamo = Boolean.Parse(runDynamoAttrib.ConstructorArguments.FirstOrDefault().Value.ToString());
            }

            var testData = new TestData(data, test.Name, modelPath, runDynamo);

            data.Tests.Add(testData);

            var category        = string.Empty;
            var categoryAttribs =
                testAttribs.Where(x => x.Constructor.DeclaringType.Name == "CategoryAttribute");

            foreach (var categoryAttrib in categoryAttribs)
            {
                category = categoryAttrib.ConstructorArguments.FirstOrDefault().Value.ToString();
                if (!String.IsNullOrEmpty(category))
                {
                    var cat = data.Assembly.Categories.FirstOrDefault(x => x.Name == category);
                    if (cat != null)
                    {
                        cat.Tests.Add(testData);
                    }
                    else
                    {
                        var catData = new CategoryData(data.Assembly, category);
                        catData.Tests.Add(testData);
                        data.Assembly.Categories.Add(catData);
                    }
                }
            }

            Console.WriteLine("Loaded test: {0}", testData);

            return(true);
        }
Exemple #18
0
 public TestData(IFixtureData fixture, string name, string modelPath, bool runDynamo)
 {
     Fixture = fixture;
     Name = name;
     ModelPath = modelPath;
     RunDynamo = runDynamo;
 }
        public static bool ReadTest(MethodInfo test, IFixtureData data, string workingDirectory)
        {
            //set the default modelPath to the empty.rfa file that will live in the build directory
            string modelPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "empty.rfa");

            var testModelAttribs = test.GetCustomAttributes(typeof(TestModelAttribute), false);
            if (testModelAttribs.Any())
            {
                //overwrite the model path with the one
                //specified in the test model attribute
                modelPath = Path.GetFullPath(Path.Combine(workingDirectory, ((TestModelAttribute)testModelAttribs[0]).Path));
            }

            var runDynamoAttribs = test.GetCustomAttributes(typeof(RunDynamoAttribute), false);
            var runDynamo = false;
            if (runDynamoAttribs.Any())
            {
                runDynamo = ((RunDynamoAttribute)runDynamoAttribs[0]).RunDynamo;
            }

            var testData = new TestData(data, test.Name, modelPath, runDynamo);
            data.Tests.Add(testData);

            return true;
        }