public TestRunner(IRunnerSetupData setupData) : base(setupData)
 {
 }
Example #2
0
        public Runner(IRunnerSetupData setupData)
        {
            if (!String.IsNullOrEmpty(setupData.TestAssembly) && !File.Exists(setupData.TestAssembly))
            {
                throw new ArgumentException("The specified test assembly does not exist.");
            }

            if (String.IsNullOrEmpty(setupData.TestAssembly))
            {
                setupData.TestAssembly = Assembly.GetExecutingAssembly().Location;
            }

            if (String.IsNullOrEmpty(setupData.AssemblyPath) || !File.Exists(setupData.AssemblyPath))
            {
                setupData.AssemblyPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                    "RTFRevit.dll");
            }

            if (!String.IsNullOrEmpty(setupData.WorkingDirectory) && !Directory.Exists(setupData.WorkingDirectory))
            {
                throw new ArgumentException("The specified working directory does not exist.");
            }

            if (String.IsNullOrEmpty(setupData.WorkingDirectory) || !Directory.Exists(setupData.WorkingDirectory))
            {
                setupData.WorkingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            }

            if (!String.IsNullOrEmpty(setupData.Category))
            {
                setupData.GroupingType = GroupingType.Category;
            }

            if (setupData.Products == null || !setupData.Products.Any())
            {
                throw new ArgumentException("No appropriate Revit versions found on this machine for testing.");
            }

            if (String.IsNullOrEmpty(setupData.RevitPath))
            {
                setupData.RevitPath = Path.Combine(setupData.Products.First().InstallLocation, "revit.exe");
            }

            AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += CurrentDomain_ReflectionOnlyAssemblyResolve;

            WorkingDirectory = setupData.WorkingDirectory;
            AssemblyPath = setupData.AssemblyPath;
            TestAssembly = setupData.TestAssembly;
            Results = setupData.Results;
            Fixture = setupData.Fixture;
            Category = setupData.Category;
            Test = setupData.Test;
            Concat = setupData.Concat;
            DryRun = setupData.DryRun;
            RevitPath = setupData.RevitPath;
            CleanUp = setupData.CleanUp;
            Continuous = setupData.Continuous;
            IsDebug = setupData.IsDebug;
            GroupingType = setupData.GroupingType;
            Timeout = setupData.Timeout;
            Products.Clear();
            Products.AddRange(setupData.Products);
            IsTesting = setupData.IsTesting;
            ExcludedCategory = setupData.ExcludedCategory;

            Products.Clear();
            Products.AddRange(setupData.Products);
            int count = Products.Count;
            SelectedProduct = -1;
            for (int i = 0; i < count; ++i)
            {
                var location = Path.GetDirectoryName(RevitPath);
                var locationFromProduct = Path.GetDirectoryName(Products[i].InstallLocation);
                if (String.Compare(locationFromProduct, location, true) == 0)
                    SelectedProduct = i;
            }

            if (SelectedProduct == -1)
            {
                throw new Exception("Can not find a proper application to start!");
            }

            Refresh();

            if (File.Exists(Results) && !Concat)
            {
                File.Delete(Results);
            }
        }
 public TestRunner(IRunnerSetupData setupData)
     : base(setupData)
 {
 }