Beispiel #1
0
        public void AddAssembly(string name, Assembly assembly)
        {
            const string dynamic_assembly_identifier = "dynamic";

            assemblyDropdown.RemoveDropdownItem(assemblyDropdown.Items.LastOrDefault(i => i.Key.Contains(dynamic_assembly_identifier)).Value);
            assemblyDropdown.AddDropdownItem(name, assembly);
        }
Beispiel #2
0
        public void LoadTest(Type testType = null, Action onCompletion = null)
        {
            runAllComplete();

            if (testType == null && TestTypes.Count > 0)
            {
                testType = TestTypes[0];
            }

            config.Set(TestBrowserSetting.LastTest, testType?.Name);

            if (CurrentTest != null)
            {
                testContentContainer.Remove(CurrentTest);
                CurrentTest.Clear();
                CurrentTest = null;
            }

            if (testType != null)
            {
                assemblyDropdown.RemoveDropdownItem(assemblyDropdown.Items.LastOrDefault(i => i.Value.FullName.Contains("DotNetCompiler")).Value);

                // if we are a dynamically compiled type (via DynamicClassCompiler) we should update the dropdown accordingly.
                if (testType.Assembly.FullName.Contains("DotNetCompiler"))
                {
                    assemblyDropdown.AddDropdownItem($"dynamic ({testType.Name})", testType.Assembly);
                }

                assemblyDropdown.Current.Value = testType.Assembly;

                testContentContainer.Add(CurrentTest = (TestCase)Activator.CreateInstance(testType));
                if (!interactive)
                {
                    CurrentTest.OnLoadComplete = d => ((TestCase)d).RunAllSteps(onCompletion);
                }

                var methods = testType.GetMethods();

                var setUpMethod = methods.FirstOrDefault(m => m.GetCustomAttributes(typeof(SetUpAttribute), false).Length > 0);

                foreach (var m in methods.Where(m => m.Name != "TestConstructor" && m.GetCustomAttributes(typeof(TestAttribute), false).Length > 0))
                {
                    var step = CurrentTest.AddStep(m.Name, () => { setUpMethod?.Invoke(CurrentTest, null); });
                    step.BackgroundColour = Color4.Teal;
                    m.Invoke(CurrentTest, null);
                }

                backgroundCompiler.Checkpoint(CurrentTest);

                CurrentTest.RunFirstStep();
            }

            updateButtons();
        }