public void RunTestsForTestShouldPreferParallelSettingsFromRunSettingsOverAssemblyLevelAttributes() { var testCase1 = this.GetTestCase(typeof(DummyTestClassForParallelize), "TestMethod1"); var testCase2 = this.GetTestCase(typeof(DummyTestClassForParallelize), "TestMethod2"); TestCase[] tests = new[] { testCase1, testCase2 }; this.runContext.MockRunSettings.Setup(rs => rs.SettingsXml).Returns( @"<RunSettings> <MSTest> <Parallelize> <Workers>2</Workers> <Scope>MethodLevel</Scope> </Parallelize> </MSTest> </RunSettings>"); try { MSTestSettings.PopulateSettings(this.runContext); var testablePlatformService = this.SetupTestablePlatformService(); testablePlatformService.SetupMockReflectionOperations(); var originalReflectionOperation = new ReflectionOperations(); testablePlatformService.MockReflectionOperations.Setup( ro => ro.GetCustomAttributes(It.IsAny <Assembly>(), It.IsAny <Type>())). Returns((Assembly asm, Type type) => { if (type.FullName.Equals(typeof(UTF.ParallelizeAttribute).FullName)) { return(new object[] { new UTF.ParallelizeAttribute { Workers = 1 } }); } return(originalReflectionOperation.GetCustomAttributes(asm, type)); }); testablePlatformService.MockReflectionOperations.Setup( ro => ro.GetCustomAttributes(It.IsAny <MemberInfo>(), It.IsAny <bool>())). Returns((MemberInfo memberInfo, bool inherit) => { return(originalReflectionOperation.GetCustomAttributes(memberInfo, inherit)); }); this.TestExecutionManager.RunTests(tests, this.runContext, this.frameworkHandle, new TestRunCancellationToken()); Assert.AreEqual(2, DummyTestClassForParallelize.ThreadIds.Count); } finally { DummyTestClassForParallelize.Cleanup(); } }
public DesktopReflectionOperationsTests() { this.reflectionOperations = new ReflectionOperations(); }
public CoreReflectionOperationsTests() { this.reflectionOperations = new ReflectionOperations(); }