public TestCaseButton(CategoryTestCase test) { Masking = true; TestCase = test; CornerRadius = 5; RelativeSizeAxes = Axes.X; Size = new Vector2(1, 60); Add(new Drawable[] { box = new Box { RelativeSizeAxes = Axes.Both, Colour = new Color4(140, 140, 140, 255), Alpha = 0.7f }, text = new Container { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Left = 4, Right = 4, Bottom = 2, }, Children = new[] { new SpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Text = TestCase.Name, }, new SpriteText { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, Text = TestCase.Description, TextSize = 15, AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, } } } }); }
public RpTestBrowser() { //we want to build the lists here because we're interested in the assembly we were *created* on. Assembly asm = Assembly.GetCallingAssembly(); //get all class that is inherit from CategoryTestCase foreach (Type type in asm.GetLoadableTypes().Where(t => t.IsSubclassOf(typeof(CategoryTestCase)) && !t.IsAbstract)) { CategoryTestCase singleTestCase = (CategoryTestCase)Activator.CreateInstance(type); //if this class is need to test if (singleTestCase.AddToTest) { //Category it Tests.Add(singleTestCase); } } //Tests.Sort((a, b) => string.Compare(a.Name, b.Name, StringComparison.Ordinal)); }
//compile the whole step of single test private void compileFinished(CategoryTestCase newVersion) { Schedule(() => { compilingNotice.FadeOut(800, EasingTypes.InQuint); compilingNotice.FadeColour(newVersion == null ? Color4.Red : Color4.YellowGreen, 100); if (newVersion == null) { return; } //TODO : finish it //get the test that has //int i = Tests(t => t.GetType().Name == newVersion.GetType().Name); //Tests[i] = newVersion; //LoadTest(i); }); }
//load single test public void LoadTest(CategoryTestCase testCase = null, Action onCompletion = null) { //get first value if (testCase == null && Tests.Count > 0) { testCase = Tests.First(); } config.Set(TestBrowserSetting.LastTest, testCase?.Name); if (CurrentTest != null) { testContentContainer.Remove(CurrentTest); CurrentTest.Clear(); var button = getButtonFor(CurrentTest); if (button != null) { button.Current = false; } CurrentTest = null; } if (testCase != null) { testContentContainer.Add(CurrentTest = testCase); testCase.Reset(); testCase.RunAllSteps(onCompletion); var button = getButtonFor(CurrentTest); if (button != null) { button.Current = true; } } }
private TestCaseButton getButtonFor(CategoryTestCase currentTest) => secondaryFlowContainer.Children.FirstOrDefault(b => b.TestCase.Name == currentTest.Name);