public void RunTestsWithTestAdapterPath(RunnerInfo runnerInfo) { AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); this.ExecuteNotSupportedRunnerFrameworkTests(runnerInfo.RunnerFramework, Netcoreapp, Message); var testAdapterPath = Directory.EnumerateFiles(this.GetTestAdapterPath(), "*.TestAdapter.dll").ToList(); this.vstestConsoleWrapper.InitializeExtensions(new List <string>() { testAdapterPath.FirstOrDefault() }); this.vstestConsoleWrapper.RunTests( this.GetTestAssemblies(), this.GetDefaultRunSettings(), this.runEventHandler); // Assert Assert.AreEqual(6, this.runEventHandler.TestResults.Count); Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed)); Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Skipped)); }
public void RunTestsWithTestCaseFilter(RunnerInfo runnerInfo) { AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); this.ExecuteNotSupportedRunnerFrameworkTests(runnerInfo.RunnerFramework, Netcoreapp, Message); var sources = new List <string> { this.GetAssetFullPath("SimpleTestProject.dll") }; this.vstestConsoleWrapper.RunTests( sources, this.GetDefaultRunSettings(), new TestPlatformOptions() { TestCaseFilter = "FullyQualifiedName=SampleUnitTestProject.UnitTest1.PassingTest" }, this.runEventHandler); // Assert Assert.AreEqual(1, this.runEventHandler.TestResults.Count); Assert.AreEqual(TestOutcome.Passed, this.runEventHandler.TestResults.FirstOrDefault().Outcome); }
public void DiscoverTestsUsingEventHandler1AndBatchSize(RunnerInfo runnerInfo) { AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); this.Setup(); var discoveryEventHandlerForBatchSize = new DiscoveryEventHandlerForBatchSize(); string runSettingsXml = @"<?xml version=""1.0"" encoding=""utf-8""?> <RunSettings> <RunConfiguration> <BatchSize>3</BatchSize> </RunConfiguration> </RunSettings>"; this.vstestConsoleWrapper.DiscoverTests( this.GetTestAssemblies(), runSettingsXml, discoveryEventHandlerForBatchSize); // Assert. Assert.AreEqual(6, discoveryEventHandlerForBatchSize.DiscoveredTestCases.Count); Assert.AreEqual(3, discoveryEventHandlerForBatchSize.batchSize); }
public void RunTestsShouldThrowOnStackOverflowException(RunnerInfo runnerInfo) { AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); this.ExecuteNotSupportedRunnerFrameworkTests(runnerInfo.RunnerFramework, Netcoreapp, Message); if (IntegrationTestEnvironment.BuildConfiguration.Equals("release", StringComparison.OrdinalIgnoreCase)) { // On release, x64 builds, recursive calls may be replaced with loops (tail call optimization) Assert.Inconclusive("On StackOverflowException testhost not exited in release configuration."); return; } var source = new List <string>() { this.GetAssetFullPath("SimpleTestProject3.dll") }; this.vstestConsoleWrapper.RunTests( source, this.GetDefaultRunSettings(), new TestPlatformOptions() { TestCaseFilter = "ExitWithStackoverFlow" }, this.runEventHandler); var errorMessage = "The active test run was aborted. Reason: Process is terminated due to StackOverflowException.\r\n"; if (runnerInfo.TargetFramework.StartsWith("netcoreapp2.")) { errorMessage = "The active test run was aborted. Reason: Process is terminating due to StackOverflowException.\r\n"; } // Assert Assert.AreEqual(errorMessage, this.runEventHandler.LogMessage); }
public void RunTestsWithTelemetryOptedIn(RunnerInfo runnerInfo) { AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); this.ExecuteNotSupportedRunnerFrameworkTests(runnerInfo.RunnerFramework, Netcoreapp, Message); this.Setup(); this.vstestConsoleWrapper.RunTests( this.GetTestAssemblies(), this.GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true }, this.runEventHandler); // Assert Assert.AreEqual(6, this.runEventHandler.TestResults.Count); Assert.IsTrue(this.runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.TargetDevice)); Assert.IsTrue(this.runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.TargetFramework)); Assert.IsTrue(this.runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.TargetOS)); Assert.IsTrue(this.runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.TimeTakenInSecForRun)); Assert.IsTrue(this.runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.NumberOfAdapterDiscoveredDuringExecution)); Assert.IsTrue(this.runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.RunState)); }
public void DiscoverTestsUsingSourceNavigation(RunnerInfo runnerInfo) { AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); this.Setup(); this.vstestConsoleWrapper.DiscoverTests( this.GetTestAssemblies(), this.GetDefaultRunSettings(), this.discoveryEventHandler); // Assert. var testCase = this.discoveryEventHandler.DiscoveredTestCases.Where(dt => dt.FullyQualifiedName.Equals("SampleUnitTestProject.UnitTest1.PassingTest")); // Release builds optimize code, hence line numbers are different. if (IntegrationTestEnvironment.BuildConfiguration.StartsWith("release", StringComparison.OrdinalIgnoreCase)) { Assert.AreEqual(23, testCase.FirstOrDefault().LineNumber); } else { Assert.AreEqual(22, testCase.FirstOrDefault().LineNumber); } }
public void RunTestsWithFastFilter(RunnerInfo runnerInfo) { AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); this.Setup(); var sources = new List <string> { this.GetAssetFullPath("SimpleTestProject.dll") }; this.vstestConsoleWrapper.RunTests( sources, this.GetDefaultRunSettings(), new TestPlatformOptions() { TestCaseFilter = "FullyQualifiedName=SampleUnitTestProject.UnitTest1.PassingTest | FullyQualifiedName=SampleUnitTestProject.UnitTest1.FailingTest" }, this.runEventHandler); // Assert Assert.AreEqual(2, this.runEventHandler.TestResults.Count); Assert.AreEqual(1, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); Assert.AreEqual(1, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed)); }
public void RunTestsWithLiveUnitTesting(RunnerInfo runnerInfo) { AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); this.ExecuteNotSupportedRunnerFrameworkTests(runnerInfo.RunnerFramework, Netcoreapp, Message); string runSettingsXml = @"<?xml version=""1.0"" encoding=""utf-8""?> <RunSettings> <RunConfiguration> <DisableAppDomain>true</DisableAppDomain> <DisableParallelization>true</DisableParallelization> </RunConfiguration> </RunSettings>"; this.vstestConsoleWrapper.RunTests( this.GetTestAssemblies(), runSettingsXml, this.runEventHandler); // Assert Assert.AreEqual(6, this.runEventHandler.TestResults.Count); Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed)); Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Skipped)); }
public async Task TestRunWithCodeCoverageAndAttachmentsProcessingCancelled(RunnerInfo runnerInfo) { // arrange AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); this.Setup(); if (!testEnvironment.RunnerFramework.Equals(IntegrationTestBase.DesktopRunnerFramework)) { return; } this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies().Take(1), this.GetCodeCoverageRunSettings(1), this.runEventHandler); Assert.AreEqual(3, this.runEventHandler.TestResults.Count); Assert.AreEqual(1, this.runEventHandler.Attachments.Count); List <AttachmentSet> attachments = Enumerable.Range(0, 1000).Select(i => this.runEventHandler.Attachments.First()).ToList(); CancellationTokenSource cts = new CancellationTokenSource(); Task attachmentsProcessing = this.vstestConsoleWrapper.ProcessTestRunAttachmentsAsync(attachments, null, true, true, testRunAttachmentsProcessingEventHandler, cts.Token); while (true) { try { if (testRunAttachmentsProcessingEventHandler.ProgressArgs.Count >= 3) { break; } } catch { // ignore } await Task.Delay(100); } // act cts.Cancel(); // Assert await attachmentsProcessing; testRunAttachmentsProcessingEventHandler.EnsureSuccess(); Assert.AreEqual(1000, this.testRunAttachmentsProcessingEventHandler.Attachments.Count); Assert.IsTrue(testRunAttachmentsProcessingEventHandler.CompleteArgs.IsCanceled); Assert.IsNull(testRunAttachmentsProcessingEventHandler.CompleteArgs.Error); Assert.IsTrue(3 <= testRunAttachmentsProcessingEventHandler.ProgressArgs.Count); for (int i = 0; i < testRunAttachmentsProcessingEventHandler.ProgressArgs.Count; i++) { VisualStudio.TestPlatform.ObjectModel.Client.TestRunAttachmentsProcessingProgressEventArgs progressArgs = testRunAttachmentsProcessingEventHandler.ProgressArgs[i]; Assert.AreEqual(1, progressArgs.CurrentAttachmentProcessorIndex); Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", progressArgs.CurrentAttachmentProcessorUris.First().AbsoluteUri); Assert.AreEqual(1, progressArgs.AttachmentProcessorsCount); if (i == 0) { Assert.AreEqual(0, progressArgs.CurrentAttachmentProcessorProgress); } } Assert.AreEqual("Canceled", testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.AttachmentsProcessingState]); Assert.AreEqual(1000L, testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.NumberOfAttachmentsSentForProcessing]); Assert.AreEqual(1000L, testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.NumberOfAttachmentsAfterProcessing]); Assert.IsTrue(testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics.ContainsKey(TelemetryDataConstants.TimeTakenInSecForAttachmentsProcessing)); Assert.IsTrue(File.Exists(runEventHandler.Attachments.First().Attachments.First().Uri.LocalPath)); }
public async Task TestRunWithCodeCoverageAndAttachmentsProcessingModuleDuplicated(RunnerInfo runnerInfo) { // arrange AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); this.Setup(); this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies().Take(1), this.GetCodeCoverageRunSettings(1), this.runEventHandler); this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies().Skip(1), this.GetCodeCoverageRunSettings(1), this.runEventHandler); this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies().Skip(1), this.GetCodeCoverageRunSettings(1), this.runEventHandler); Assert.AreEqual(9, this.runEventHandler.TestResults.Count); Assert.AreEqual(3, this.runEventHandler.Attachments.Count); // act await this.vstestConsoleWrapper.ProcessTestRunAttachmentsAsync(runEventHandler.Attachments, null, true, true, testRunAttachmentsProcessingEventHandler, CancellationToken.None); // Assert testRunAttachmentsProcessingEventHandler.EnsureSuccess(); Assert.AreEqual(1, this.testRunAttachmentsProcessingEventHandler.Attachments.Count); AssertCoverageResults(this.testRunAttachmentsProcessingEventHandler.Attachments); Assert.IsFalse(testRunAttachmentsProcessingEventHandler.CompleteArgs.IsCanceled); Assert.IsNull(testRunAttachmentsProcessingEventHandler.CompleteArgs.Error); for (int i = 0; i < testRunAttachmentsProcessingEventHandler.ProgressArgs.Count; i++) { VisualStudio.TestPlatform.ObjectModel.Client.TestRunAttachmentsProcessingProgressEventArgs progressArgs = testRunAttachmentsProcessingEventHandler.ProgressArgs[i]; Assert.AreEqual(1, progressArgs.CurrentAttachmentProcessorIndex); Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", progressArgs.CurrentAttachmentProcessorUris.First().AbsoluteUri); Assert.AreEqual(1, progressArgs.AttachmentProcessorsCount); if (testRunAttachmentsProcessingEventHandler.ProgressArgs.Count == 3) { Assert.AreEqual(i == 0 ? 33 : i == 1 ? 66 : 100, progressArgs.CurrentAttachmentProcessorProgress); } } Assert.AreEqual("Completed", testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.AttachmentsProcessingState]); Assert.AreEqual(3L, testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.NumberOfAttachmentsSentForProcessing]); Assert.AreEqual(1L, testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.NumberOfAttachmentsAfterProcessing]); Assert.IsTrue(testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics.ContainsKey(TelemetryDataConstants.TimeTakenInSecForAttachmentsProcessing)); Assert.IsTrue(File.Exists(runEventHandler.Attachments.First().Attachments.First().Uri.LocalPath)); Assert.IsTrue(File.Exists(runEventHandler.Attachments.Last().Attachments.First().Uri.LocalPath) != testEnvironment.RunnerFramework.Equals(IntegrationTestBase.DesktopRunnerFramework)); }
public void doWork() { if (string.IsNullOrEmpty(sessionToken) && !doLogin()) { onWriteStatus(getLogTitle() + "Login failed!"); return; } initApi(); List <MatchInfo> eventList = new List <MatchInfo>(); try { MarketFilter marketFilter = new MarketFilter(); ISet <string> eventTypeIds = new HashSet <string>(); eventTypeIds.Add("7"); eventTypeIds.Add("4339"); marketFilter.EventTypeIds = eventTypeIds; marketFilter.MarketStartTime = new TimeRange(); marketFilter.MarketStartTime.From = DateTime.Now; marketFilter.MarketStartTime.To = DateTime.Now.AddHours(1); // 한시간후의 경주들을 얻는다. ISet <MarketProjection> marketProjects = new HashSet <MarketProjection>(); marketProjects.Add(MarketProjection.RUNNER_DESCRIPTION); marketProjects.Add(MarketProjection.EVENT); IList <MarketCatalogue> marketCatalogueList = clientDelay.ListMarketCatalogue(marketFilter, marketProjects, null, 100).Result.Response; if (marketCatalogueList == null || marketCatalogueList.Count < 1) { return; } ISet <string> marketIds = new HashSet <string>(); foreach (MarketCatalogue marketCatalogue in marketCatalogueList) { if (marketCatalogue == null || marketCatalogue.Runners == null || marketCatalogue.Runners.Count < 1) { continue; } marketIds.Add(marketCatalogue.MarketId); addMarketEvent(marketCatalogue.MarketId, marketCatalogue.Event); if (marketCatalogue.Runners == null) { continue; } foreach (RunnerCatalog runner in marketCatalogue.Runners) { addSelectionRunner(runner.SelectionId, runner.RunnerName); } } if (marketIds.Count < 1) { return; } // get listmarketbook PriceProjection priceProjection = new PriceProjection(); priceProjection.PriceData = new HashSet <PriceData>(); priceProjection.PriceData.Add(PriceData.EX_ALL_OFFERS); priceProjection.PriceData.Add(PriceData.EX_BEST_OFFERS); priceProjection.PriceData.Add(PriceData.EX_TRADED); priceProjection.PriceData.Add(PriceData.SP_AVAILABLE); priceProjection.PriceData.Add(PriceData.SP_TRADED); int nCnt = 0; ISet <string> tempMarketIds = new HashSet <string>(); List <MarketBook> marketBookList = new List <MarketBook>(); foreach (string marketId in marketIds) { tempMarketIds.Add(marketId); nCnt++; if (nCnt >= 5) { List <MarketBook> tempMarketBookList = clientDelay.ListMarketBook(tempMarketIds, priceProjection).Result.Response; if (tempMarketBookList != null) { marketBookList.AddRange(tempMarketBookList); } nCnt = 0; tempMarketIds.Clear(); } } if (tempMarketIds.Count > 0) { List <MarketBook> tempMarketBookList = clientDelay.ListMarketBook(tempMarketIds, priceProjection).Result.Response; if (tempMarketBookList != null) { marketBookList.AddRange(tempMarketBookList); } } if (marketBookList == null || marketBookList.Count < 1) { return; } foreach (MarketBook marketBook in marketBookList) { if (!Constants.bRun) { break; } if (marketBook.Runners == null) { continue; } MatchInfo matchInfo = new MatchInfo(); matchInfo.id = marketBook.MarketId; string eveName = getEventFromMarketId(marketBook.MarketId); if (string.IsNullOrEmpty(eveName)) { continue; } matchInfo.name = eveName; foreach (Runner runner in marketBook.Runners) { if (runner == null || runner.ExchangePrices == null) { continue; } RunnerInfo runnerInfo = new RunnerInfo(); runnerInfo.id = runner.SelectionId; string runnerName = getRunnerFromSelectionId(runner.SelectionId); if (string.IsNullOrEmpty(runnerName)) { continue; } runnerInfo.name = runnerName; if (runner.ExchangePrices.AvailableToBack != null && runner.ExchangePrices.AvailableToBack.Count > 0) { foreach (PriceSize priceSize in runner.ExchangePrices.AvailableToBack) { PriceInfo priceInfo = new PriceInfo(); priceInfo.odds = priceSize.Price; priceInfo.side = SIDE.Back; priceInfo.stake = priceSize.Size; runnerInfo.prices.Add(priceInfo); } } if (runner.ExchangePrices.AvailableToLay != null && runner.ExchangePrices.AvailableToLay.Count > 0) { foreach (PriceSize priceSize in runner.ExchangePrices.AvailableToLay) { PriceInfo priceInfo = new PriceInfo(); priceInfo.odds = priceSize.Price; priceInfo.side = SIDE.Lay; priceInfo.stake = priceSize.Size; runnerInfo.prices.Add(priceInfo); } } if (runnerInfo.prices.Count > 0) { matchInfo.runners.Add(runnerInfo); } } if (matchInfo.runners.Count > 0) { eventList.Add(matchInfo); } } } catch (Exception e) { } if (eventList.Count > 0) { onSendMatchBetfair(eventList); } }