Skip to content

Commit

Permalink
Add console, trace and debug writeline calls to the lifecycle integra…
Browse files Browse the repository at this point in the history
…tion tests (#1464)
  • Loading branch information
engyebrahim authored Dec 14, 2022
1 parent 4d9ffba commit 8a21115
Show file tree
Hide file tree
Showing 21 changed files with 1,443 additions and 84 deletions.
1,071 changes: 989 additions & 82 deletions test/E2ETests/Smoke.E2E.Tests/SuiteLifeCycleTests.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Diagnostics;

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace SuiteLifeCycleTestProject;
Expand All @@ -15,11 +18,17 @@ public static void AssemblyInit(TestContext testContext)
{
s_testContext = testContext;
s_testContext.WriteLine("AssemblyInit was called");
Console.WriteLine("Console: AssemblyInit was called");
Trace.WriteLine("Trace: AssemblyInit was called");
Debug.WriteLine("Debug: AssemblyInit was called");
}

[AssemblyCleanup]
public static void AssemblyCleanup()
{
s_testContext.WriteLine("AssemblyCleanup was called");
Console.WriteLine("Console: AssemblyCleanup was called");
Trace.WriteLine("Trace: AssemblyCleanup was called");
Debug.WriteLine("Debug: AssemblyCleanup was called");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Diagnostics;
#if NET6_0_OR_GREATER
using System.Threading.Tasks;
#endif
Expand All @@ -23,42 +24,63 @@ public sealed class LifeCycleClassCleanup : IDisposable
public LifeCycleClassCleanup()
{
s_testContext.WriteLine("LifeCycleClassCleanup.ctor was called");
Console.WriteLine("Console: LifeCycleClassCleanup.ctor was called");
Trace.WriteLine("Trace: LifeCycleClassCleanup.ctor was called");
Debug.WriteLine("Debug: LifeCycleClassCleanup.ctor was called");
}

[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
{
s_testContext = testContext;
s_testContext.WriteLine("LifeCycleClassCleanup.ClassInitialize was called");
Console.WriteLine("Console: LifeCycleClassCleanup.ClassInitialize was called");
Trace.WriteLine("Trace: LifeCycleClassCleanup.ClassInitialize was called");
Debug.WriteLine("Debug: LifeCycleClassCleanup.ClassInitialize was called");
}

[TestInitialize]
public void TestInitialize()
{
TestContext.WriteLine("LifeCycleClassCleanup.TestInitialize was called");
Console.WriteLine("Console: LifeCycleClassCleanup.TestInitialize was called");
Trace.WriteLine("Trace: LifeCycleClassCleanup.TestInitialize was called");
Debug.WriteLine("Debug: LifeCycleClassCleanup.TestInitialize was called");
}

[TestMethod]
public void TestMethod()
{
TestContext.WriteLine("LifeCycleClassCleanup.TestMethod was called");
Console.WriteLine("Console: LifeCycleClassCleanup.TestMethod was called");
Trace.WriteLine("Trace: LifeCycleClassCleanup.TestMethod was called");
Debug.WriteLine("Debug: LifeCycleClassCleanup.TestMethod was called");
}

[TestCleanup]
public void TestCleanup()
{
TestContext.WriteLine("LifeCycleClassCleanup.TestCleanup was called");
Console.WriteLine("Console: LifeCycleClassCleanup.TestCleanup was called");
Trace.WriteLine("Trace: LifeCycleClassCleanup.TestCleanup was called");
Debug.WriteLine("Debug: LifeCycleClassCleanup.TestCleanup was called");
}

public void Dispose()
{
TestContext.WriteLine("LifeCycleClassCleanup.Dispose was called");
Console.WriteLine("Console: LifeCycleClassCleanup.Dispose was called");
Trace.WriteLine("Trace: LifeCycleClassCleanup.Dispose was called");
Debug.WriteLine("Debug: LifeCycleClassCleanup.Dispose was called");
}

#if NET6_0_OR_GREATER
public ValueTask DisposeAsync()
{
TestContext.WriteLine("LifeCycleClassCleanup.DisposeAsync was called");
Console.WriteLine("Console: LifeCycleClassCleanup.DisposeAsync was called");
Trace.WriteLine("Trace: LifeCycleClassCleanup.DisposeAsync was called");
Debug.WriteLine("Debug: LifeCycleClassCleanup.DisposeAsync was called");
return ValueTask.CompletedTask;
}
#endif
Expand All @@ -67,5 +89,8 @@ public ValueTask DisposeAsync()
public static void ClassCleanup()
{
s_testContext.WriteLine("LifeCycleClassCleanup.ClassCleanup was called");
Console.WriteLine("Console: LifeCycleClassCleanup.ClassCleanup was called");
Trace.WriteLine("Trace: LifeCycleClassCleanup.ClassCleanup was called");
Debug.WriteLine("Debug: LifeCycleClassCleanup.ClassCleanup was called");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Diagnostics;
#if NET6_0_OR_GREATER
using System.Threading.Tasks;
#endif
Expand All @@ -23,42 +24,63 @@ public sealed class LifeCycleClassCleanupEndOfAssembly : IDisposable
public LifeCycleClassCleanupEndOfAssembly()
{
s_testContext.WriteLine("LifeCycleClassCleanupEndOfAssembly.ctor was called");
Console.WriteLine("Console: LifeCycleClassCleanupEndOfAssembly.ctor was called");
Trace.WriteLine("Trace: LifeCycleClassCleanupEndOfAssembly.ctor was called");
Debug.WriteLine("Debug: LifeCycleClassCleanupEndOfAssembly.ctor was called");
}

[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
{
s_testContext = testContext;
s_testContext.WriteLine("LifeCycleClassCleanupEndOfAssembly.ClassInitialize was called");
Console.WriteLine("Console: LifeCycleClassCleanupEndOfAssembly.ClassInitialize was called");
Trace.WriteLine("Trace: LifeCycleClassCleanupEndOfAssembly.ClassInitialize was called");
Debug.WriteLine("Debug: LifeCycleClassCleanupEndOfAssembly.ClassInitialize was called");
}

[TestInitialize]
public void TestInitialize()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfAssembly.TestInitialize was called");
Console.WriteLine("Console: LifeCycleClassCleanupEndOfAssembly.TestInitialize was called");
Trace.WriteLine("Trace: LifeCycleClassCleanupEndOfAssembly.TestInitialize was called");
Debug.WriteLine("Debug: LifeCycleClassCleanupEndOfAssembly.TestInitialize was called");
}

[TestMethod]
public void TestMethod()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfAssembly.TestMethod was called");
Console.WriteLine("Console: LifeCycleClassCleanupEndOfAssembly.TestMethod was called");
Trace.WriteLine("Trace: LifeCycleClassCleanupEndOfAssembly.TestMethod was called");
Debug.WriteLine("Debug: LifeCycleClassCleanupEndOfAssembly.TestMethod was called");
}

[TestCleanup]
public void TestCleanup()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfAssembly.TestCleanup was called");
Console.WriteLine("Console: LifeCycleClassCleanupEndOfAssembly.TestCleanup was called");
Trace.WriteLine("Trace: LifeCycleClassCleanupEndOfAssembly.TestCleanup was called");
Debug.WriteLine("Debug: LifeCycleClassCleanupEndOfAssembly.TestCleanup was called");
}

public void Dispose()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfAssembly.Dispose was called");
Console.WriteLine("Console: LifeCycleClassCleanupEndOfAssembly.Dispose was called");
Trace.WriteLine("Trace: LifeCycleClassCleanupEndOfAssembly.Dispose was called");
Debug.WriteLine("Debug: LifeCycleClassCleanupEndOfAssembly.Dispose was called");
}

#if NET6_0_OR_GREATER
public ValueTask DisposeAsync()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfAssembly.DisposeAsync was called");
Console.WriteLine("Console: LifeCycleClassCleanupEndOfAssembly.DisposeAsync was called");
Trace.WriteLine("Trace: LifeCycleClassCleanupEndOfAssembly.DisposeAsync was called");
Debug.WriteLine("Debug: LifeCycleClassCleanupEndOfAssembly.DisposeAsync was called");
return ValueTask.CompletedTask;
}
#endif
Expand All @@ -67,5 +89,8 @@ public ValueTask DisposeAsync()
public static void ClassCleanup()
{
s_testContext.WriteLine("LifeCycleClassCleanupEndOfAssembly.ClassCleanup was called");
Console.WriteLine("Console: LifeCycleClassCleanupEndOfAssembly.ClassCleanup was called");
Trace.WriteLine("Trace: LifeCycleClassCleanupEndOfAssembly.ClassCleanup was called");
Debug.WriteLine("Debug: LifeCycleClassCleanupEndOfAssembly.ClassCleanup was called");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Diagnostics;
#if NET6_0_OR_GREATER
using System.Threading.Tasks;
#endif
Expand All @@ -13,7 +14,7 @@ namespace SuiteLifeCycleTestProject;
[TestClass]
public class LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass : IDisposable
#if NET6_0_OR_GREATER
, IAsyncDisposable
, IAsyncDisposable
#endif
{
private static TestContext s_testContext;
Expand All @@ -23,42 +24,63 @@ public class LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass : IDisp
public LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass()
{
s_testContext.WriteLine("LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.ctor was called");
Console.WriteLine("Console: LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.ctor was called");
Trace.WriteLine("Trace: LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.ctor was called");
Debug.WriteLine("Debug: LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.ctor was called");
}

[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
{
s_testContext = testContext;
s_testContext.WriteLine("LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.ClassInitialize was called");
Console.WriteLine("Console: LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.ClassInitialize was called");
Trace.WriteLine("Trace: LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.ClassInitialize was called");
Debug.WriteLine("Debug: LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.ClassInitialize was called");
}

[TestInitialize]
public void TestInitialize()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.TestInitialize was called");
Console.WriteLine("Console: LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.TestInitialize was called");
Trace.WriteLine("Trace: LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.TestInitialize was called");
Debug.WriteLine("Debug: LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.TestInitialize was called");
}

[TestMethod]
public void TestMethod()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.TestMethod was called");
Console.WriteLine("Console: LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.TestMethod was called");
Trace.WriteLine("Trace: LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.TestMethod was called");
Debug.WriteLine("Debug: LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.TestMethod was called");
}

[TestCleanup]
public void TestCleanup()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.TestCleanup was called");
Console.WriteLine("Console: LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.TestCleanup was called");
Trace.WriteLine("Trace: LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.TestCleanup was called");
Debug.WriteLine("Debug: LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.TestCleanup was called");
}

public void Dispose()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.Dispose was called");
Console.WriteLine("Console: LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.Dispose was called");
Trace.WriteLine("Trace: LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.Dispose was called");
Debug.WriteLine("Debug: LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.Dispose was called");
}

#if NET6_0_OR_GREATER
public ValueTask DisposeAsync()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.DisposeAsync was called");
Console.WriteLine("Console: LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.DisposeAsync was called");
Trace.WriteLine("Trace: LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.DisposeAsync was called");
Debug.WriteLine("Debug: LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.DisposeAsync was called");
return ValueTask.CompletedTask;
}
#endif
Expand All @@ -67,5 +89,8 @@ public ValueTask DisposeAsync()
public static void ClassCleanup()
{
s_testContext.WriteLine("LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.ClassCleanup was called");
Console.WriteLine("Console: LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.ClassCleanup was called");
Trace.WriteLine("Trace: LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.ClassCleanup was called");
Debug.WriteLine("Debug: LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.ClassCleanup was called");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Diagnostics;
#if NET6_0_OR_GREATER
using System.Threading.Tasks;
#endif
Expand All @@ -13,7 +14,7 @@ namespace SuiteLifeCycleTestProject;
[TestClass]
public class LifeCycleClassCleanupEndOfAssemblyAndNone : IDisposable
#if NET6_0_OR_GREATER
, IAsyncDisposable
, IAsyncDisposable
#endif
{
private static TestContext s_testContext;
Expand All @@ -23,42 +24,63 @@ public class LifeCycleClassCleanupEndOfAssemblyAndNone : IDisposable
public LifeCycleClassCleanupEndOfAssemblyAndNone()
{
s_testContext.WriteLine("LifeCycleClassCleanupEndOfAssemblyAndNone.ctor was called");
Console.WriteLine("Console: LifeCycleClassCleanupEndOfAssemblyAndNone.ctor was called");
Trace.WriteLine("Trace: LifeCycleClassCleanupEndOfAssemblyAndNone.ctor was called");
Debug.WriteLine("Debug: LifeCycleClassCleanupEndOfAssemblyAndNone.ctor was called");
}

[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
{
s_testContext = testContext;
s_testContext.WriteLine("LifeCycleClassCleanupEndOfAssemblyAndNone.ClassInitialize was called");
Console.WriteLine("Console: LifeCycleClassCleanupEndOfAssemblyAndNone.ClassInitialize was called");
Trace.WriteLine("Trace: LifeCycleClassCleanupEndOfAssemblyAndNone.ClassInitialize was called");
Debug.WriteLine("Debug: LifeCycleClassCleanupEndOfAssemblyAndNone.ClassInitialize was called");
}

[TestInitialize]
public void TestInitialize()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfAssemblyAndNone.TestInitialize was called");
Console.WriteLine("Console: LifeCycleClassCleanupEndOfAssemblyAndNone.TestInitialize was called");
Trace.WriteLine("Trace: LifeCycleClassCleanupEndOfAssemblyAndNone.TestInitialize was called");
Debug.WriteLine("Debug: LifeCycleClassCleanupEndOfAssemblyAndNone.TestInitialize was called");
}

[TestMethod]
public void TestMethod()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfAssemblyAndNone.TestMethod was called");
Console.WriteLine("Console: LifeCycleClassCleanupEndOfAssemblyAndNone.TestMethod was called");
Trace.WriteLine("Trace: LifeCycleClassCleanupEndOfAssemblyAndNone.TestMethod was called");
Debug.WriteLine("Debug: LifeCycleClassCleanupEndOfAssemblyAndNone.TestMethod was called");
}

[TestCleanup]
public void TestCleanup()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfAssemblyAndNone.TestCleanup was called");
Console.WriteLine("Console: LifeCycleClassCleanupEndOfAssemblyAndNone.TestCleanup was called");
Trace.WriteLine("Trace: LifeCycleClassCleanupEndOfAssemblyAndNone.TestCleanup was called");
Debug.WriteLine("Debug: LifeCycleClassCleanupEndOfAssemblyAndNone.TestCleanup was called");
}

public void Dispose()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfAssemblyAndNone.Dispose was called");
Console.WriteLine("Console: LifeCycleClassCleanupEndOfAssemblyAndNone.Dispose was called");
Trace.WriteLine("Trace: LifeCycleClassCleanupEndOfAssemblyAndNone.Dispose was called");
Debug.WriteLine("Debug: LifeCycleClassCleanupEndOfAssemblyAndNone.Dispose was called");
}

#if NET6_0_OR_GREATER
public ValueTask DisposeAsync()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfAssemblyAndNone.DisposeAsync was called");
Console.WriteLine("Console: LifeCycleClassCleanupEndOfAssemblyAndNone.DisposeAsync was called");
Trace.WriteLine("Trace: LifeCycleClassCleanupEndOfAssemblyAndNone.DisposeAsync was called");
Debug.WriteLine("Debug: LifeCycleClassCleanupEndOfAssemblyAndNone.DisposeAsync was called");
return ValueTask.CompletedTask;
}
#endif
Expand All @@ -67,5 +89,8 @@ public ValueTask DisposeAsync()
public static void ClassCleanup()
{
s_testContext.WriteLine("LifeCycleClassCleanupEndOfAssemblyAndNone.ClassCleanup was called");
Console.WriteLine("Console: LifeCycleClassCleanupEndOfAssemblyAndNone.ClassCleanup was called");
Trace.WriteLine("Trace: LifeCycleClassCleanupEndOfAssemblyAndNone.ClassCleanup was called");
Debug.WriteLine("Debug: LifeCycleClassCleanupEndOfAssemblyAndNone.ClassCleanup was called");
}
}
Loading

0 comments on commit 8a21115

Please sign in to comment.