public void ChangeProperty_SendsPropertyChangedEvent( TestCaseFactory.PropertyChangeTestCase testCase) { testCase.SetupAction(_PomoViewModel); var mockPropertyChangedDelegate = new Mock<PropertyChangedEventHandler>(); _PomoViewModel.PropertyChanged += mockPropertyChangedDelegate.Object; testCase.ChangeAction(_PomoViewModel); mockPropertyChangedDelegate.Verify( m => m(_PomoViewModel, It.Is<PropertyChangedEventArgs>(x => x.PropertyName == testCase.PropertyName)), Times.Once); }
public void Instantiate_QueryEqualTo_TestCase() { var sutXml = new ExecutionXml(); var ctrXml = new EqualToXml(); var builderMockFactory = new Mock <ITestCaseBuilder>(); builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml, TestConfiguration.Default)); builderMockFactory.Setup(b => b.Build()); builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new SqlCommand()); builderMockFactory.Setup(b => b.GetConstraint()).Returns(new EqualToConstraint("value")); var builder = builderMockFactory.Object; var testCaseFactory = new TestCaseFactory(); testCaseFactory.Register(typeof(ExecutionXml), typeof(EqualToXml), builder); var tc = testCaseFactory.Instantiate(sutXml, ctrXml); Assert.That(tc, Is.Not.Null); builderMockFactory.VerifyAll(); }
private static void DiscoverTests(string executable, ITestFrameworkReporter reporter, SettingsWrapper settings, ILogger logger, IDiaResolverFactory diaResolverFactory, IProcessExecutorFactory processExecutorFactory) { settings.ExecuteWithSettingsForExecutable(executable, logger, () => { if (!VerifyExecutableTrust(executable, settings, logger) || !IsGoogleTestExecutable(executable, settings.TestDiscoveryRegex, logger)) { return; } int nrOfTestCases = 0; void ReportTestCases(TestCase testCase) { reporter.ReportTestsFound(testCase.Yield()); logger.DebugInfo(String.Format(Resources.AddedTestCase, testCase.DisplayName)); nrOfTestCases++; } var factory = new TestCaseFactory(executable, logger, settings, diaResolverFactory, processExecutorFactory); factory.CreateTestCases(ReportTestCases); logger.LogInfo(String.Format(Resources.NumberOfTestsMessage, nrOfTestCases, executable)); }); }
public void TestFixtureSetUp() { Console.WriteLine("TestFixtureSetUp Started"); if (_robocode == null) { Console.WriteLine("TestFixtureSetUp Creating Robocode Instance"); _robocode = new RobocodeEngine(@"C:\robocode"); Assert.IsNotNull(_robocode); #if DEBUG var mn = Environment.MachineName.ToUpper(); var visibility = new Dictionary <string, bool> { { "ANDREWDESKTOP", true }, { "ANDREWLAPTOP", true }, { "LDSWKS0920", false } }; _robocode.Visible = visibility[mn]; #else _robocode.Visible = false; #endif Console.WriteLine("TestFixtureSetUp Subscribing"); _robocode.BattleCompleted += _robocode_BattleCompleted; _robocode.BattleError += _robocode_BattleError; _robocode.BattleMessage += _robocode_BattleMessage; } bool x = TestCaseFactory.CheckForUnfinishedBusiness(); if (x) { // ???? } Console.WriteLine("TestFixtureSetUp Done"); }
private static (string EventsJson, string ResultsJson) ExecuteWorkload(string connectionString, BsonDocument driverWorkload, bool async, CancellationToken astrolabeCancellationToken) { Environment.SetEnvironmentVariable("MONGODB_URI", connectionString); // force using atlas connection string in our internal test connection strings var additionalArgs = new Dictionary <string, object>() { { "UnifiedLoopOperationCancellationToken", astrolabeCancellationToken } }; var eventFormatters = new Dictionary <string, IEventFormatter>() { { "events", new AstrolabeEventFormatter() } // "events" matches to the "storeEventsAsEntities.id" in the driverWorkload document }; using (var runner = new UnifiedTestRunner( additionalArgs: additionalArgs, eventFormatters: eventFormatters)) { var factory = new TestCaseFactory(); var testCase = factory.CreateTestCase(driverWorkload, async); runner.Run(testCase); Console.WriteLine("dotnet ExecuteWorkload> Returning..."); return(CreateWorkloadResult(entityMap: runner.EntityMap)); } }
public static void Refresh() { //Administration AreaManagerFactory.Reset(); GlobalListFactory.Reset(); IterationManagerFactory.Reset(); ProcessTemplateFactory.Reset(); TeamManagerFactory.Reset(); TeamProjectFactory.Reset(); TfsTeamProjectCollectionFactory.Reset(); TeamProjectCollectionFactory.Reset(); //Queries QueryRunnerFactory.Reset(); //TestManagement TestCaseFactory.Reset(); TestCaseStepFactory.Reset(); TestSuiteFactory.Reset(); TestSuiteManagerFactory.Reset(); //WorkItemTracking WorkItemStoreFactory.Reset(); }
public void Should_ThrowErrorWhenTryingToCreateUndefinedTestCase() { Assert.Throws <ArgumentOutOfRangeException>(() => TestCaseFactory.Create(0, null)); }
public void Should_CreateTestsCaseOfTypeWebShop() { var testCase = TestCaseFactory.Create(TestCaseType.WebShop, null); Assert.IsType <WebshopTestCase>(testCase); }
public void Should_CreateTestsCaseOfTypeConsumeConsumer() { var testCase = TestCaseFactory.Create(TestCaseType.ConsumeConsumer, null); Assert.IsType <ConsumeConsumerTestCase>(testCase); }
public void Should_CreateTestsCaseOfTypeRequestResponse() { var testCase = TestCaseFactory.Create(TestCaseType.RequestResponse, null); Assert.IsType <RequestResponseTestCase>(testCase); }
public virtual void ExecuteTestCases(TestXml test) { Trace.WriteLineIf(NBiTraceSwitch.TraceVerbose, string.Format("Test loaded by {0}", GetOwnFilename())); Trace.WriteLineIf(NBiTraceSwitch.TraceInfo, string.Format("Test defined in {0}", TestSuiteFinder.Find())); //check if ignore is set to true if (test.Ignore) Assert.Ignore(test.IgnoreReason); else { ExecuteChecks(test.Condition); ExecuteSetup(test.Setup); foreach (var tc in test.Systems) { foreach (var ctr in test.Constraints) { var factory = new TestCaseFactory(Configuration); var testCase = factory.Instantiate(tc, ctr); AssertTestCase(testCase.SystemUnderTest, testCase.Constraint, test.Content); } } ExecuteCleanup(test.Cleanup); } }
public void TestModuleBatchedRuns() { this.RunContext.RegisterSettingProvider(BoostTestAdapterSettings.XmlRootName, new BoostTestAdapterSettingsProvider()); this.RunContext.LoadSettings("<RunSettings><BoostTest><TestBatchStrategy>Source</TestBatchStrategy></BoostTest></RunSettings>"); string OtherSource = "OtherSource"; string YetAnotherSource = "YetAnotherSource"; List <string> sources = new List <string> { DefaultSource, OtherSource, YetAnotherSource }; this.TestCaseProvider = (string source) => { IEnumerable <VSTestCase> tests = GetTests(source); if (!tests.Any()) { if (source == OtherSource) { // 10 tests in 2 suites List <string> fullyQualifiedNames = new List <string> { "Suite1/Test1", "Suite1/Test2", "Suite1/Test3", "Suite1/Test4", "Suite1/Test5" , "Suite2/Test1", "Suite2/Test2", "Suite2/Test3", "Suite2/Test4", "Suite2/Test5" }; return(GenerateTestCases(fullyQualifiedNames, OtherSource)); } if (source == YetAnotherSource) { // 5 tests in 2 suites List <string> fullyQualifiedNames = new List <string> { "Suite1/Test1", "Suite1/Test2", "Suite1/Test3", "Suite2/Test1", "Suite2/Test2" }; return(GenerateTestCases(fullyQualifiedNames, YetAnotherSource)); } } return(tests); }; this.Executor.RunTests( sources, this.RunContext, this.FrameworkHandle ); // One runner per source be provisioned for the available source foreach (IBoostTestRunner runner in this.RunnerFactory.ProvisionedRunners) { Assert.That(runner, Is.TypeOf <MockBoostTestRunner>()); MockBoostTestRunner testRunner = (MockBoostTestRunner)runner; // 1 Module/Source -> 1 Execution for all contained tests within Assert.That(testRunner.RunCount, Is.EqualTo(1)); Assert.That(sources.Remove(runner.Source), Is.True); // No tests should be specified on the command line implying all tests are to be executed Assert.That(testRunner.Args.First().Tests.Count, Is.EqualTo(0)); } Assert.That(sources, Is.Empty); }
public void UnchangedProperty_DoesNotSendPropertyChangedEvent( TestCaseFactory.PropertyChangeTestCase testCase) { testCase.SetupAction(_PomoViewModel); var mockPropertyChangedDelegate = new Mock<PropertyChangedEventHandler>(); _PomoViewModel.PropertyChanged += mockPropertyChangedDelegate.Object; // "Change" to same value as setup testCase.SetupAction(_PomoViewModel); mockPropertyChangedDelegate.Verify( m => m(_PomoViewModel, It.Is<PropertyChangedEventArgs>(x => x.PropertyName == testCase.PropertyName)), Times.Never); }
public virtual void ExecuteTestCases(TestXml test, string testName, IDictionary <string, ITestVariable> localVariables) { if (ConfigurationProvider != null) { Trace.WriteLineIf(NBiTraceSwitch.TraceError, string.Format("Loading configuration")); var config = ConfigurationProvider.GetSection(); ApplyConfig(config); } else { Trace.WriteLineIf(NBiTraceSwitch.TraceError, $"No configuration-finder found."); } Trace.WriteLineIf(NBiTraceSwitch.TraceVerbose, $"Test loaded by {GetOwnFilename()}"); Trace.WriteLineIf(NBiTraceSwitch.TraceInfo, $"{Variables.Count()} variables defined, {Variables.Count(x => x.Value.IsEvaluated())} already evaluated."); if (serviceLocator == null) { Initialize(); } //check if ignore is set to true if (test.IsNotImplemented) { Trace.WriteLineIf(NBiTraceSwitch.TraceInfo, $"Test not-implemented, will be ignored. Reason is '{test.NotImplemented.Reason}'"); Assert.Ignore(test.IgnoreReason); } else if (test.Ignore) { Trace.WriteLineIf(NBiTraceSwitch.TraceInfo, $"Test ignored. Reason is '{test.IgnoreReason}'"); Assert.Ignore(test.IgnoreReason); } else { Trace.WriteLineIf(NBiTraceSwitch.TraceInfo, $"Running test '{testName}' #{test.UniqueIdentifier}"); var allVariables = Variables.Union(localVariables).ToDictionary(x => x.Key, x => x.Value); ValidateConditions(test.Condition, allVariables); ExecuteSetup(test.Setup, allVariables); foreach (var sut in test.Systems) { if ((test?.Constraints.Count ?? 0) == 0) { Trace.WriteLineIf(NBiTraceSwitch.TraceWarning, $"Test '{testName}' has no constraint. It will always result in a success."); } foreach (var ctr in test.Constraints) { var factory = new TestCaseFactory(Configuration, allVariables, serviceLocator); var testCase = factory.Instantiate(sut, ctr); try { AssertTestCase(testCase.SystemUnderTest, testCase.Constraint, test.Content); } catch { ExecuteCleanup(test.Cleanup, allVariables); throw; } } } ExecuteCleanup(test.Cleanup, allVariables); } }