public TestName GetReservedTestName(string testShortName, TestName parentTestName) { var testName = GetChildTestName(testShortName, parentTestName); IncrementTestNameUntilItsNot(testName, name => _globallyAccumulatedTestNames.ContainsKey(name)); _globallyAccumulatedTestNames[testName.FullName] = NameIs.Reserved; return testName; }
static TestName GetChildTestName(string testShortName, TestName parentTestName) { var testName = new TestName(); testName.Shortname = testShortName; testName.FullName = parentTestName.FullName + ", " + testShortName; testName.MultilineName = parentTestName.MultilineName + ",\n" + testShortName; return testName; }
public TestName GetSharedTestName(string testShortName, TestName parentTestName) { var result = GetChildTestName(testShortName, parentTestName); IncrementTestNameUntilItsNot(result, IsReserved); _globallyAccumulatedTestNames[result.FullName] = NameIs.Available; return result; }
public TestName GetReservedNameLike(TestName testName) { var result = new TestName(); result.Shortname = testName.Shortname; result.FullName = testName.FullName; result.MultilineName = testName.MultilineName; IncrementTestNameUntilItsNot(result, name => _globallyAccumulatedTestNames.ContainsKey(name) && _globallyAccumulatedTestNames[name] == NameIs.Reserved); _globallyAccumulatedTestNames[result.FullName] = NameIs.Reserved; return result; }
public void CreateTestNames() { weakName1 = new TestName(); weakName2 = new TestName(); weakName1.FullName = weakName2.FullName = "Name.Of.This.Test"; strongName1 = new TestName(); strongName2 = new TestName(); strongName1.FullName = strongName2.FullName = "Name.Of.This.Test"; strongName1.TestID = new TestID(); strongName2.TestID = new TestID(); }
public void ConstructFromMultipleTests() { ITest[] tests = new ITest[testFixture.Tests.Count]; for( int index = 0; index < tests.Length; index++ ) tests[index] = (ITest)testFixture.Tests[index]; TestName testName = new TestName(); testName.FullName = testName.Name = "Combined"; testName.TestID = new TestID( 1000 ); TestNode test = new TestNode( testName, tests ); Assert.AreEqual( "Combined", test.TestName.Name ); Assert.AreEqual( "Combined", test.TestName.FullName ); Assert.AreEqual( RunState.Runnable, test.RunState ); Assert.IsTrue( test.IsSuite, "IsSuite" ); Assert.AreEqual( tests.Length, test.Tests.Count ); Assert.AreEqual( MockTestFixture.Tests, test.TestCount ); Assert.AreEqual( 0, test.Categories.Count, "Categories"); Assert.AreNotEqual( testFixture.TestName.Name, test.TestName.Name, "TestName" ); }
private void IncrementTestNameUntilItsNot(TestName testName, Func<string, bool> condition) { var name = testName.FullName; if (condition(name)) { var nextIndex = 1; string suffix; string nextName; do { suffix = "`" + ++nextIndex; nextName = name + suffix; } while (condition(nextName)); testName.Shortname = testName.Shortname + suffix; testName.FullName = testName.FullName + suffix; testName.MultilineName = testName.MultilineName + suffix; } }
public void SuiteStarted(TestName testName) { foreach( EventListener listener in extensions ) listener.SuiteStarted( testName ); }
public void TestStarted(TestName testName) { WriteTrace("TestStarted({0})", testName); }
public void TestAndroidStoreKey(bool useApkSigner, bool isRelease, string packageFormat, string androidKeyStore, string password, string expected, bool shouldInstall) { AssertHasDevices(); if (DeviceSdkVersion >= 30 && !useApkSigner && packageFormat == "apk") { Assert.Ignore($"Test Skipped. jarsigner and {packageFormat} does not work with API 30 and above"); return; } string path = Path.Combine("temp", TestName.Replace(expected, expected.Replace("-", "_"))); string storepassfile = Path.Combine(Root, path, "storepass.txt"); string keypassfile = Path.Combine(Root, path, "keypass.txt"); byte [] data = ResourceData.GetKeystore(); var proj = new XamarinAndroidApplicationProject() { IsRelease = isRelease, }; Dictionary <string, string> envVar = new Dictionary <string, string> (); if (password.StartsWith("env:", StringComparison.Ordinal)) { envVar.Add("_MYPASSWORD", password.Replace("env:", string.Empty)); proj.SetProperty("AndroidSigningStorePass", "env:_MYPASSWORD"); proj.SetProperty("AndroidSigningKeyPass", "env:_MYPASSWORD"); } else if (password.StartsWith("file:", StringComparison.Ordinal)) { proj.SetProperty("AndroidSigningStorePass", $"file:{storepassfile}"); proj.SetProperty("AndroidSigningKeyPass", $"file:{keypassfile}"); } else { proj.SetProperty("AndroidSigningStorePass", password); proj.SetProperty("AndroidSigningKeyPass", password); } proj.SetAndroidSupportedAbis("armeabi-v7a", "x86"); proj.SetProperty("AndroidKeyStore", androidKeyStore); proj.SetProperty("AndroidSigningKeyStore", "test.keystore"); proj.SetProperty("AndroidSigningKeyAlias", "mykey"); proj.SetProperty("AndroidPackageFormat", packageFormat); proj.SetProperty("AndroidUseApkSigner", useApkSigner.ToString()); proj.OtherBuildItems.Add(new BuildItem(BuildActions.None, "test.keystore") { BinaryContent = () => data }); proj.OtherBuildItems.Add(new BuildItem(BuildActions.None, "storepass.txt") { TextContent = () => password.Replace("file:", string.Empty), Encoding = Encoding.ASCII, }); proj.OtherBuildItems.Add(new BuildItem(BuildActions.None, "keypass.txt") { TextContent = () => password.Replace("file:", string.Empty), Encoding = Encoding.ASCII, }); using (var b = CreateApkBuilder(path, false, false)) { b.ThrowOnBuildFailure = false; Assert.IsTrue(b.Build(proj, environmentVariables: envVar), "Build should have succeeded."); if (packageFormat == "apk") { StringAssertEx.Contains(expected, b.LastBuildOutput, "The Wrong keystore was used to sign the apk"); } b.BuildLogFile = "install.log"; Assert.AreEqual(shouldInstall, b.Install(proj, doNotCleanupOnUpdate: true), $"Install should have {(shouldInstall ? "succeeded" : "failed")}."); if (packageFormat == "aab") { StringAssertEx.Contains(expected, b.LastBuildOutput, "The Wrong keystore was used to sign the apk"); } if (!shouldInstall) { return; } b.BuildLogFile = "uninstall.log"; Assert.IsTrue(b.Uninstall(proj, doNotCleanupOnUpdate: true), "Uninstall should have succeeded."); } }
/// <summary> /// Trigger event when each test starts /// </summary> /// <param name="testName">TestName of the Test that is starting</param> public void TestStarted(TestName testName) { this.currentTestName = testName.FullName; events.FireTestStarting(testName); }
public void SuiteStarted(TestName suiteName) { this.listener.SuiteStarted(suiteName); }
public void SuiteStarted(TestName testName) { }
/// <summary> /// Construct a NameFilter for a single TestName /// </summary> /// <param name="testName"></param> public NameFilter( TestName testName ) { testNames.Add( testName ); }
public void TestStarted(TestName testCase) { wrapped.TestStarted(GetTestName(testCase)); consoleOutput = new StringBuilder(); consoleError = new StringBuilder(); }
public void SuiteStarted(TestName suite) { wrapped.SuiteStarted(GetTestName(suite)); }
public void TestStarted(TestName testName) { //do something here. }
public void SuiteStarted(TestName test_name) { listener.SuiteStarted(test_name); }
public void TestStarted(TestName test_name) { listener.TestStarted(test_name); }
public void TestStarted(TestName testName) { }
public void TestStarted(TestName testName) { testCaseStart++; }
public void SuiteStarted(TestName suiteName) { suiteStarted.Add(suiteName.Name); }
public void CanParseSimpleTestNames() { TestName tn = TestName.Parse("Name.Of.This.Test"); Assert.AreEqual("Name.Of.This.Test", tn.FullName); }
/// <summary> /// Called when a test is started. /// </summary> /// <param name="testName"> /// The test name. /// </param> public void TestStarted(TestName testName) { }
void EventListener.SuiteStarted(TestName testName) { OnTestStarted(testName, true); }
public void TestStarted(TestName testName) { this.listener.TestStarted(testName); }
public void TestStarted(TestName testName) { throw new NotImplementedException(); }
public async Task <int> RunAsync() { // ----------------------------------------------------------------------------- // Do you want to proxy requests through Fiddler? Can be useful for debugging. var useFiddler = true; var fiddlerPort = 8866; // By default Fiddler4 uses port 8888 and Fiddler Everywhere uses port 8866 // Change the default values in the legacy client. var optionsToCorrectLegacyDefaultValues = new StrongGridClientOptions() { LogLevelFailedCalls = LogLevel.Error, LogLevelSuccessfulCalls = LogLevel.Debug }; // ----------------------------------------------------------------------------- // Configure StrongGrid client var apiKey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY"); var proxy = useFiddler ? new WebProxy($"http://localhost:{fiddlerPort}") : null; var legacyClient = new LegacyClient(apiKey, proxy, optionsToCorrectLegacyDefaultValues, _loggerFactory.CreateLogger <LegacyClient>()); var client = new Client(apiKey, proxy, null, _loggerFactory.CreateLogger <Client>()); // Configure Console var source = new CancellationTokenSource(); Console.CancelKeyPress += (s, e) => { e.Cancel = true; source.Cancel(); }; // Ensure the Console is tall enough and centered on the screen Console.WindowHeight = Math.Min(60, Console.LargestWindowHeight); Utils.CenterConsole(); // These are the integration tests that we will execute var integrationTests = new Type[] { typeof(AccessManagement), typeof(Alerts), typeof(ApiKeys), typeof(Batches), typeof(Blocks), typeof(Bounces), typeof(ContactsAndCustomFields), typeof(Designs), typeof(EmailActivities), typeof(EmailValidation), typeof(GlobalSuppressions), typeof(InvalidEmails), typeof(IpAddresses), typeof(IpPools), typeof(LegacyCampaignsAndSenderIdentities), typeof(LegacyCategories), typeof(LegacyContactsAndCustomFields), typeof(LegacyListsAndSegments), typeof(ListsAndSegments), typeof(Mail), typeof(SenderAuthentication), typeof(Settings), typeof(SingleSendsAndSenderIdentities), typeof(SpamReports), typeof(Statistics), typeof(Subusers), typeof(Teammates), typeof(Templates), typeof(UnsubscribeGroupsAndSuppressions), typeof(User), typeof(WebhookSettings), typeof(WebhookStats) }; // Execute the async tests in parallel (with max degree of parallelism) var results = await integrationTests.ForEachAsync( async testType => { var log = new StringWriter(); try { var integrationTest = (IIntegrationTest)Activator.CreateInstance(testType); if (testType.Name.StartsWith("Legacy")) { await integrationTest.RunAsync(legacyClient as IBaseClient, log, source.Token).ConfigureAwait(false); } else { await integrationTest.RunAsync(client as IBaseClient, log, source.Token).ConfigureAwait(false); } return(TestName : testType.Name, ResultCode : ResultCodes.Success, Message : SUCCESSFUL_TEST_MESSAGE); } catch (OperationCanceledException) { await log.WriteLineAsync($"-----> TASK CANCELLED").ConfigureAwait(false); return(TestName : testType.Name, ResultCode : ResultCodes.Cancelled, Message : "Task cancelled"); } catch (Exception e) { var exceptionMessage = e.GetBaseException().Message; await log.WriteLineAsync($"-----> AN EXCEPTION OCCURRED: {exceptionMessage}").ConfigureAwait(false); return(TestName : testType.Name, ResultCode : ResultCodes.Exception, Message : exceptionMessage); } finally { lock (Console.Out) { Console.Out.WriteLine(log.ToString()); } } }, MAX_SENDGRID_API_CONCURRENCY) .ConfigureAwait(false); // Display summary var summary = new StringWriter(); await summary.WriteLineAsync("\n\n**************************************************").ConfigureAwait(false); await summary.WriteLineAsync("******************** SUMMARY *********************").ConfigureAwait(false); await summary.WriteLineAsync("**************************************************").ConfigureAwait(false); foreach (var(TestName, ResultCode, Message) in results.OrderBy(r => r.TestName).ToArray()) { var name = TestName.Length <= TEST_NAME_MAX_LENGTH ? TestName : TestName.Substring(0, TEST_NAME_MAX_LENGTH - 3) + "..."; await summary.WriteLineAsync($"{name.PadRight(TEST_NAME_MAX_LENGTH, ' ')} : {Message}").ConfigureAwait(false); } await summary.WriteLineAsync("**************************************************").ConfigureAwait(false); await Console.Out.WriteLineAsync(summary.ToString()).ConfigureAwait(false); // Prompt user to press a key in order to allow reading the log in the console var promptLog = new StringWriter(); await promptLog.WriteLineAsync("\n\n**************************************************").ConfigureAwait(false); await promptLog.WriteLineAsync("Press any key to exit").ConfigureAwait(false); Utils.Prompt(promptLog.ToString()); // Return code indicating success/failure var resultCode = (int)ResultCodes.Success; if (results.Any(result => result.ResultCode != ResultCodes.Success)) { if (results.Any(result => result.ResultCode == ResultCodes.Exception)) { resultCode = (int)ResultCodes.Exception; } else if (results.Any(result => result.ResultCode == ResultCodes.Cancelled)) { resultCode = (int)ResultCodes.Cancelled; } else { resultCode = (int)results.First(result => result.ResultCode != ResultCodes.Success).ResultCode; } } return(await Task.FromResult(resultCode)); }
public virtual void SuiteStarted(TestName testName) { }
/// <summary> /// Trigger event when each suite starts /// </summary> /// <param name="suite">Suite that is starting</param> public void SuiteStarted(TestName suiteName) { events.FireSuiteStarting(suiteName); }
public void SuiteStarted(TestName suiteName) { suiteStarted++; }
void EventListener.TestStarted(TestName testName) { OnTestStarted(testName, false); }
public void TestStarted(TestName testName) { currentTest = testName; }
public virtual void TestStarted(TestName testName) { }
public void TestAndroidStoreKey(bool useApkSigner, bool isRelease, string packageFormat, string androidKeyStore, string password, string expected, bool shouldInstall) { string path = Path.Combine("temp", TestName.Replace(expected, expected.Replace("-", "_"))); string storepassfile = Path.Combine(Root, path, "storepass.txt"); string keypassfile = Path.Combine(Root, path, "keypass.txt"); byte [] data; using (var stream = typeof(XamarinAndroidCommonProject).Assembly.GetManifestResourceStream("Xamarin.ProjectTools.Resources.Base.test.keystore")) { data = new byte [stream.Length]; stream.Read(data, 0, (int)stream.Length); } var proj = new XamarinAndroidApplicationProject() { IsRelease = isRelease }; Dictionary <string, string> envVar = new Dictionary <string, string> (); if (password.StartsWith("env:", StringComparison.Ordinal)) { envVar.Add("_MYPASSWORD", password.Replace("env:", string.Empty)); proj.SetProperty("AndroidSigningStorePass", "env:_MYPASSWORD"); proj.SetProperty("AndroidSigningKeyPass", "env:_MYPASSWORD"); } else if (password.StartsWith("file:", StringComparison.Ordinal)) { proj.SetProperty("AndroidSigningStorePass", $"file:{storepassfile}"); proj.SetProperty("AndroidSigningKeyPass", $"file:{keypassfile}"); } else { proj.SetProperty("AndroidSigningStorePass", password); proj.SetProperty("AndroidSigningKeyPass", password); } var abis = new string [] { "armeabi-v7a", "x86" }; proj.SetProperty(KnownProperties.AndroidSupportedAbis, string.Join(";", abis)); proj.SetProperty("AndroidKeyStore", androidKeyStore); proj.SetProperty("AndroidSigningKeyStore", "test.keystore"); proj.SetProperty("AndroidSigningKeyAlias", "mykey"); proj.SetProperty("AndroidPackageFormat", packageFormat); proj.SetProperty("AndroidUseApkSigner", useApkSigner.ToString()); proj.OtherBuildItems.Add(new BuildItem(BuildActions.None, "test.keystore") { BinaryContent = () => data }); proj.OtherBuildItems.Add(new BuildItem(BuildActions.None, "storepass.txt") { TextContent = () => password.Replace("file:", string.Empty), Encoding = Encoding.ASCII, }); proj.OtherBuildItems.Add(new BuildItem(BuildActions.None, "keypass.txt") { TextContent = () => password.Replace("file:", string.Empty), Encoding = Encoding.ASCII, }); using (var b = CreateApkBuilder(path, false, false)) { b.Verbosity = LoggerVerbosity.Diagnostic; b.ThrowOnBuildFailure = false; Assert.IsTrue(b.Build(proj, environmentVariables: envVar), "Build should have succeeded."); if (packageFormat == "apk") { StringAssertEx.Contains(expected, b.LastBuildOutput, "The Wrong keystore was used to sign the apk"); } b.BuildLogFile = "install.log"; Assert.AreEqual(shouldInstall, b.Install(proj, doNotCleanupOnUpdate: true), $"Install should have {(shouldInstall ? "succeeded" : "failed")}."); if (packageFormat == "aab") { StringAssertEx.Contains(expected, b.LastBuildOutput, "The Wrong keystore was used to sign the apk"); } if (!shouldInstall) { return; } b.BuildLogFile = "uninstall.log"; Assert.IsTrue(b.Uninstall(proj, doNotCleanupOnUpdate: true), "Uninstall should have succeeded."); } }
/// <summary> /// Returns a <see cref="Tuple{T1, T2}"/> containing /// the name and average of the specific test under the /// <see langword="DISK component"/>. /// </summary> /// <param name="testCollection">The total collection of <see cref="TimeSpan"/>(s) /// for the component.</param> /// <param name="theTest">The test represented by <see cref="TestName"/>.</param> /// <returns></returns> protected override Tuple <string, TimeSpan> GenerateAverageTest(List <TimeSpan> testCollection, TestName theTest) { Tuple <string, TimeSpan> averageTest; switch (theTest) { case TestName.DISKFolderMatrix: { TimeSpan totalTime = new TimeSpan(); for (byte b = 0; b < this.rs.IterationsPerDiskTest; b++) { totalTime = totalTime.Add(this.TestCollection[b]); } TimeSpan average = AverageTimespan(ref totalTime, this.rs.IterationsPerDiskTest); averageTest = Tuple.Create(GetTestName(theTest), average); break; } case TestName.DISKBulkFile: { TimeSpan totalTime = new TimeSpan(); for (byte b = 0; b < this.rs.IterationsPerDiskTest; b++) { totalTime = totalTime.Add(this.TestCollection[b + (this.rs.IterationsPerDiskTest * 1)]); } TimeSpan average = AverageTimespan(ref totalTime, this.rs.IterationsPerDiskTest); averageTest = Tuple.Create(GetTestName(theTest), average); break; } case TestName.DISKReadWriteParse: { TimeSpan totalTime = new TimeSpan(); for (byte b = 0; b < this.rs.IterationsPerDiskTest; b++) { totalTime = totalTime.Add(this.TestCollection[b + (this.rs.IterationsPerDiskTest * 2)]); } TimeSpan average = AverageTimespan(ref totalTime, this.rs.IterationsPerDiskTest); averageTest = Tuple.Create(GetTestName(theTest), average); break; } case TestName.DISKRipper: { TimeSpan totalTime = new TimeSpan(); for (byte b = 0; b < this.rs.IterationsPerDiskTest; b++) { totalTime = totalTime.Add(this.TestCollection[b + (this.rs.IterationsPerDiskTest * 3)]); } TimeSpan average = AverageTimespan(ref totalTime, this.rs.IterationsPerDiskTest); averageTest = Tuple.Create(GetTestName(theTest), average); break; } default: { return(Tuple.Create("**UnknownTest**", new TimeSpan())); } } return(averageTest); }
public void SuiteStarted(TestName testName) { // Console.WriteLine("SuiteStarted"); }
public void TestStarted(TestName testName) { _stdoutStandin.WriteLine(testName.FullName); // Console.WriteLine("Test {0}", testName.FullName); }
public void SuiteStarted(TestName testName) { WriteTrace("SuiteStarted({0})", testName); }
public void TestStarted(TestName testName) { _logger(""); _logger(string.Format("Test started: {0} ", testName.FullName.Replace(Environment.NewLine, ""))); }
public void TestStarted(TestName testName) { foreach( EventListener listener in Extensions ) listener.TestStarted( testName ); }
public void TestStarted(TestName testName) { _outWriter.WriteLine("{0}: Test {1} started ... ", DateTime.Now.Ticks, testName.FullName); }
public void SuiteStarted(TestName testName) { _outWriter.WriteLine("{0}: Suite started - {1}", DateTime.Now.Ticks, testName); }
public void TestStarted(TestName testName) { testStarted.Add(testName.Name); }
/// <summary> /// Returns a <see cref="Tuple{T1, T2}"/> containing /// the name and average of the specific test under the /// <see langword="CPU component"/>. /// </summary> /// <param name="testCollection">The total collection of <see cref="TimeSpan"/>(s) /// for the component.</param> /// <param name="theTest">The test represented by <see cref="TestName"/>.</param> /// <returns></returns> protected override Tuple <string, TimeSpan> GenerateAverageTest(List <TimeSpan> testCollection, TestName theTest) { Tuple <string, TimeSpan> averageTest; switch (theTest) { case TestName.CPUSuccessorship: { TimeSpan totalTime = new TimeSpan(); for (byte b = 0; b < this.rs.IterationsPerCPUTest; b++) { totalTime = totalTime.Add(this.TestCollection[b]); } TimeSpan average = AverageTimespan(ref totalTime, this.rs.IterationsPerCPUTest); averageTest = Tuple.Create(GetTestName(theTest), average); break; } case TestName.CPUBoolean: { TimeSpan totalTime = new TimeSpan(); for (byte b = 0; b < this.rs.IterationsPerCPUTest; b++) { totalTime = totalTime.Add(this.TestCollection[b + (this.rs.IterationsPerCPUTest * (int)TestName.CPUBoolean)]); } TimeSpan average = AverageTimespan(ref totalTime, this.rs.IterationsPerCPUTest); averageTest = Tuple.Create(GetTestName(theTest), average); break; } case TestName.CPUQueue: { TimeSpan totalTime = new TimeSpan(); for (byte b = 0; b < this.rs.IterationsPerCPUTest; b++) { totalTime = totalTime.Add(this.TestCollection[b + (this.rs.IterationsPerCPUTest * (int)TestName.CPUQueue)]); } TimeSpan average = AverageTimespan(ref totalTime, this.rs.IterationsPerCPUTest); averageTest = Tuple.Create(GetTestName(theTest), average); break; } case TestName.CPULinkedList: { TimeSpan totalTime = new TimeSpan(); for (byte b = 0; b < this.rs.IterationsPerCPUTest; b++) { totalTime = totalTime.Add(this.TestCollection[b + (this.rs.IterationsPerCPUTest * (int)TestName.CPULinkedList)]); } TimeSpan average = AverageTimespan(ref totalTime, this.rs.IterationsPerCPUTest); averageTest = Tuple.Create(GetTestName(theTest), average); break; } case TestName.CPUTree: { TimeSpan totalTime = new TimeSpan(); for (byte b = 0; b < this.rs.IterationsPerCPUTest; b++) { totalTime = totalTime.Add(this.TestCollection[b + (this.rs.IterationsPerCPUTest * (int)TestName.CPUTree)]); } TimeSpan average = AverageTimespan(ref totalTime, this.rs.IterationsPerCPUTest); averageTest = Tuple.Create(GetTestName(theTest), average); break; } default: { return(Tuple.Create("**UnknownTest**", new TimeSpan())); } } return(averageTest); }
/// <summary> /// Add a TestName to a NameFilter /// </summary> /// <param name="testName"></param> public void Add( TestName testName ) { testNames.Add( testName ); }
/// <summary> /// Called when the test suite run is started. /// </summary> /// <param name="testName"> /// The test name. /// </param> public void SuiteStarted(TestName testName) { }