private ITestComponent FindNextTestGroup(ITestComponent testGroup) { if (testGroup != null) { if (testCollection[testGroup].Any()) { testGroup.EnableTest(true); return(FindInnerTestGroup(testGroup)); } testCollection.Remove(testGroup); testGroup.EnableTest(false); var parentTestGroup = testGroup.GetTestGroup(); if (parentTestGroup == null) { return(null); } testCollection[parentTestGroup].Remove(testGroup); return(FindNextTestGroup(parentTestGroup)); } throw new Exception("No test left"); }
public void GetRequiredServiceTest() { ServiceCollection serviceCollection = new ServiceCollection(); serviceCollection.AddAssemblyByConvention(this.GetType().Assembly); serviceCollection.AddDependencyInjectionExtensions(); IServiceProvider serviceProvider = serviceCollection.BuildServiceProvider(); IComponentFactory <string, ITestComponent> componentFactory = serviceProvider.GetRequiredService <IComponentFactory <string, ITestComponent> >(); ITestComponent testComponent = componentFactory.GetRequiredService("A"); testComponent.ShouldBeOfType(typeof(TestComponentA), "<steing,ITestComponent> 解析:A"); testComponent = componentFactory.GetRequiredService("B"); testComponent.ShouldBeOfType(typeof(TestComponentB), "<steing,ITestComponent> 解析:B"); testComponent = componentFactory.GetRequiredService("C"); testComponent.ShouldBeOfType(typeof(TestComponentC), "<steing,ITestComponent> 解析:C"); testComponent = componentFactory.GetRequiredService("D"); testComponent.ShouldBeOfType(typeof(TestComponentD), "<steing,ITestComponent> 解析:D"); IComponentFactory <int, ITestComponent> componentFactory0 = serviceProvider.GetRequiredService <IComponentFactory <int, ITestComponent> >(); testComponent = componentFactory0.GetRequiredService(0); testComponent.ShouldBeOfType(typeof(TestComponent0), "<int,ITestComponent> 解析:0"); testComponent = componentFactory0.GetRequiredService(1); testComponent.ShouldBeOfType(typeof(TestComponent1), "<int,ITestComponent> 解析:1"); testComponent = componentFactory0.GetRequiredService(2); testComponent.ShouldBeOfType(typeof(TestComponent2), "<int,ITestComponent> 解析:2"); testComponent = componentFactory0.GetRequiredService(3); testComponent.ShouldBeOfType(typeof(TestComponent3), "<int,ITestComponent> 解析:3"); }
static void Main(string[] args) { var ext = new NLogExtension() { GetName = (t, n) => t.FullName }; _container = new UnityContainer(); _container.AddExtension(ext). RegisterType <ITestComponent, Baranina>("baranina"). RegisterType <ITestComponent, Cielecina>("cielecina"). RegisterType <ITestConstructorInjection, TestConstructorInjection>(); var _instance = _container.Resolve <Class1>(); _instance.GetName += GetName; _instance.GetName += GetName2; _instance.GetName += GetName3; _instance.GetName += GetName4; _instance.TestLogging(); ITestComponent baranina = _container.Resolve <Baranina>(); baranina.GetName(); var bar2 = _container.Resolve <ITestComponent>("baranina"); ITestComponent cielecina = _container.Resolve <Cielecina>(); cielecina.GetName(); Console.ReadLine(); }
public int CompareTo(ITestComponent other) { if (other == this) { return(0); } return(-1); }
public ITestComponent GetNextTest() { ITestComponent testComponent = testCollection[currentTestGroup].First(); testCollection[currentTestGroup].Remove(testComponent); testComponent.EnableTest(enable: true); return(testComponent); }
private void AddTestToList(ITestComponent test) { var group = test.GetTestGroup(); if (!testCollection.ContainsKey(group)) testCollection.Add(group, new HashSet<ITestComponent>()); testCollection[group].Add(test); if (group == TestComponent.NullTestComponent) return; AddTestToList(group); }
private ITestComponent FindInnerTestGroup(ITestComponent group) { var innerGroups = testCollection[group]; foreach(var innerGroup in innerGroups) { if (!innerGroup.IsTestGroup()) { continue; } innerGroup.EnableTest(true); return FindInnerTestGroup(innerGroup); } return group; }
public void FinishTest(ITestComponent test) { try { test.EnableTest(false); currentTestGroup = FindNextTestGroup(currentTestGroup); } catch (MissingReferenceException e) { Debug.LogException(e); return; } }
public void FinishTest(ITestComponent test) { try { test.EnableTest(false); currentTestGroup = FindNextTestGroup(currentTestGroup); } catch (MissingReferenceException e) { Debug.LogException(e); return; } }
public IntegrationTestsProvider(IEnumerable<ITestComponent> tests) { testToRun = tests; foreach(var test in tests.OrderBy(component => component)) { if (test.IsTestGroup()) { throw new Exception(test.Name + " is test a group"); } AddTestToList(test); } if (currentTestGroup == null) { currentTestGroup = FindInnerTestGroup(TestComponent.NullTestComponent); } }
public void SetUp() { var factory = new ConventionObjectFactory( module: base.Module, transientConventionsFactory: context => new IObjectFactoryConvention[] { new ApiContractWrapperConvention() }); m_Component = new TestComponent(); m_ApiContractWrapper = factory.CreateInstanceOf <ITestComponent>().UsingConstructor <ITestComponent>(m_Component); m_ExpectedExceptionParamName = null; m_ExpectedExceptionLog = null; }
private void AddTestToList(ITestComponent test) { ITestComponent testGroup = test.GetTestGroup(); if (!testCollection.ContainsKey(testGroup)) { testCollection.Add(testGroup, new HashSet <ITestComponent>()); } testCollection[testGroup].Add(test); if (testGroup != TestComponent.NullTestComponent) { AddTestToList(testGroup); } }
public int CompareTo(ITestComponent obj) { if (obj == NullTestComponent) { return(1); } var result = gameObject.name.CompareTo(obj.gameObject.name); if (result == 0) { result = gameObject.GetInstanceID().CompareTo(obj.gameObject.GetInstanceID()); } return(result); }
private void AddTestToList(ITestComponent test) { var group = test.GetTestGroup(); if (!testCollection.ContainsKey(group)) { testCollection.Add(group, new HashSet <ITestComponent>()); } testCollection[group].Add(test); if (group == TestComponent.NullTestComponent) { return; } AddTestToList(group); }
private ITestComponent FindInnerTestGroup(ITestComponent group) { var innerGroups = testCollection[group]; foreach (var innerGroup in innerGroups) { if (!innerGroup.IsTestGroup()) { continue; } innerGroup.EnableTest(true); return(FindInnerTestGroup(innerGroup)); } return(group); }
private ITestComponent FindInnerTestGroup(ITestComponent group) { HashSet <ITestComponent> hashSet = testCollection[group]; foreach (ITestComponent item in hashSet) { if (!item.IsTestGroup()) { continue; } item.EnableTest(enable: true); return(FindInnerTestGroup(item)); } return(group); }
public IntegrationTestsProvider(IEnumerable <ITestComponent> tests) { testToRun = tests; foreach (var test in tests.OrderBy(component => component)) { if (test.IsTestGroup()) { throw new Exception(test.Name + " is test a group"); } AddTestToList(test); } if (currentTestGroup == null) { currentTestGroup = FindInnerTestGroup(TestComponent.NullTestComponent); } }
private ITestComponent FindNextTestGroup(ITestComponent testGroup) { if (testGroup == null) throw new Exception ("No test left"); if (testCollection[testGroup].Any()) { testGroup.EnableTest(true); return FindInnerTestGroup(testGroup); } testCollection.Remove(testGroup); testGroup.EnableTest(false); var parentTestGroup = testGroup.GetTestGroup(); if (parentTestGroup == null) return null; testCollection[parentTestGroup].Remove(testGroup); return FindNextTestGroup(parentTestGroup); }
private void FinishTest(TestResult.ResultType result) { testsProvider.FinishTest(currentTest); var testResult = testToRun.Single(t => t.isRunning); testResult.resultType = result; testResult.isRunning = false; testResult.duration = Time.time - startTime; testResult.messages = testMessages; testResult.stacktrace = stacktrace; TestRunnerCallback.TestFinished(testResult); currentTest = null; if (!testResult.IsSuccess && testResult.Executed && !testResult.IsIgnored) { resultRenderer.AddResults(Application.loadedLevelName, testResult); } }
private ITestComponent FindNextTestGroup(ITestComponent testGroup) { if (testGroup == null) { throw new Exception("No test left"); } if (testCollection[testGroup].Any()) { testGroup.EnableTest(enable: true); return(FindInnerTestGroup(testGroup)); } testCollection.Remove(testGroup); testGroup.EnableTest(enable: false); ITestComponent testGroup2 = testGroup.GetTestGroup(); if (testGroup2 == null) { return(null); } testCollection[testGroup2].Remove(testGroup); return(FindNextTestGroup(testGroup2)); }
private void StartNewTest() { this.testMessages = ""; this.stacktrace = ""; testState = TestState.Running; assertionsToCheck = null; startTime = Time.time; currentTest = testsProvider.GetNextTest(); var testResult = testToRun.Single(result => result.TestComponent == currentTest); testResult.isRunning = true; if (currentTest.ShouldSucceedOnAssertions()) { var assertionList = currentTest.gameObject.GetComponentsInChildren <AssertionComponent> ().Where(a => a.enabled); if (assertionList.Any()) { assertionsToCheck = assertionList.ToArray(); } } if (currentTest.IsExludedOnThisPlatform()) { testState = TestState.Ignored; Debug.Log(currentTest.gameObject.name + " is excluded on this platform"); } //do not run ignored tests only when it's batch mode //test runner in the editor will not pass ignored tests to run, unless is expected to if (!isInitializedByRunner && currentTest.IsIgnored()) { testState = TestState.Ignored; } LogMessage(startedMessage); TestRunnerCallback.TestStarted(testResult); }
private void StartNewTest () { this.testMessages = ""; this.stacktrace = ""; testState = TestState.Running; assertionsToCheck = null; startTime = Time.time; currentTest = testsProvider.GetNextTest (); var testResult = testToRun.Single (result => result.TestComponent == currentTest); testResult.isRunning = true; if (currentTest.ShouldSucceedOnAssertions ()) { var assertionList = currentTest.gameObject.GetComponentsInChildren<AssertionComponent> ().Where (a => a.enabled); if(assertionList.Any()) assertionsToCheck = assertionList.ToArray(); } if (currentTest.IsExludedOnThisPlatform ()) { testState = TestState.Ignored; Debug.Log(currentTest.gameObject.name + " is excluded on this platform"); } //do not run ignored tests only when it's batch mode //test runner in the editor will not pass ignored tests to run, unless is expected to if (!isInitializedByRunner && currentTest.IsIgnored()) testState = TestState.Ignored; LogMessage(startedMessage); TestRunnerCallback.TestStarted (testResult); }
public TestComponentHandler(string key, ITestComponent testable) { _key = key; _testable = testable; }
public TestComponentDecorator(ITestComponent decoratedComponent) { this.decoratedComponent = decoratedComponent; }
public ConstructorSelectionTestComponent(ITestComponent z) { }
public override void Reflect(RunInvokerTree tree, RunInvokerVertex parent, Type t) { if (!typeof(IComponent).IsAssignableFrom(t)) { throw new ArgumentException("Fixture type implement IComponent", t.FullName); } // get set up or tearown // look MethodInfo setUp = TypeHelper.GetAttributedMethod(t, typeof(SetUpAttribute)); MethodInfo tearDown = TypeHelper.GetAttributedMethod(t, typeof(TearDownAttribute)); using (IComponent fixture = (IComponent)TypeHelper.CreateInstance(t)) { // get components field FieldInfo componentsField = t.GetField("components", BindingFlags.Instance | BindingFlags.NonPublic); if (componentsField == null) { return; } // call InitializeMethod MethodInfo initialzeComponent = t.GetMethod("InitializeComponent", BindingFlags.Instance | BindingFlags.NonPublic); if (initialzeComponent != null) { initialzeComponent.Invoke(fixture, null); } IContainer components = componentsField.GetValue(fixture) as IContainer; if (components == null) { return; } ArrayList suites = new ArrayList(); // get suites foreach (IComponent component in components.Components) { // get component ITestComponent testComponent = component as ITestComponent; if (testComponent == null) { continue; } // get test suite ITestSuite testSuite = testComponent.GetTests(); if (testSuite == null) { continue; } suites.Add(testSuite); } // decorate foreach (IComponent component in components.Components) { ITestDecoratorComponent decorator = component as ITestDecoratorComponent; if (decorator == null) { continue; } for (int i = 0; i < suites.Count; ++i) { suites[i] = decorator.Decorate((ITestSuite)suites[i]); } } // add suites foreach (ITestSuite testSuite in suites) { foreach (ITestCase testCase in testSuite.TestCases) { TestCaseRunInvoker invoker = new TestCaseRunInvoker( this, testSuite, testCase, setUp, tearDown); tree.AddChild(parent, invoker); } } } }
public TestComponentWithTwoDependencies(ITestComponent a, ITestComponent b) { this.A = a; this.B = b; }
public TestComponentWithParameters(ITestComponent firstParameter, IAnotherTestComponent secondParameter) { this.FirstParameter = firstParameter; this.SecondParameter = secondParameter; }
public OptionalParams(ITestComponent dependency, string message = Expected) { Dependency = dependency; Message = message; }
public MultiConstructor(ITestComponent dependency, int number) { }
public ConstructorSelectionTestComponent(string x, string y, ITestComponent z) { }
private void FinishTest(TestResult.ResultType result) { testsProvider.FinishTest (currentTest); var testResult = testToRun.Single (t => t.isRunning); testResult.resultType = result; testResult.isRunning = false; testResult.duration = Time.time - startTime; testResult.messages = testMessages; testResult.stacktrace = stacktrace; TestRunnerCallback.TestFinished (testResult); currentTest = null; if (!testResult.IsSuccess && testResult.Executed && !testResult.IsIgnored) resultRenderer.AddResults (Application.loadedLevelName, testResult); }
public MultiConstructor(ITestComponent dependency) { Dependency = dependency; }
public TestComponentWithADependancy(ITestComponent a) { this.A = a; }