Skip to content

Commit

Permalink
Add Integration tests for cleanup inheritance behaviors with differen…
Browse files Browse the repository at this point in the history
…t scenarios (#1459)

Co-authored-by: Amaury Levé <[email protected]>
  • Loading branch information
engyebrahim and Evangelink committed Dec 14, 2022
1 parent 8b0b6d0 commit 590549c
Show file tree
Hide file tree
Showing 9 changed files with 737 additions and 3 deletions.
256 changes: 253 additions & 3 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
@@ -0,0 +1,71 @@
// 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;
#if NET6_0_OR_GREATER
using System.Threading.Tasks;
#endif

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace SuiteLifeCycleTestProject;

[TestClass]
public class LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass : IDisposable
#if NET6_0_OR_GREATER
, IAsyncDisposable
#endif
{
private static TestContext s_testContext;

public TestContext TestContext { get; set; }

public LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass()
{
s_testContext.WriteLine("LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.ctor was called");
}

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

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

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

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

public void Dispose()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.Dispose was called");
}

#if NET6_0_OR_GREATER
public ValueTask DisposeAsync()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.DisposeAsync was called");
return ValueTask.CompletedTask;
}
#endif

[ClassCleanup(InheritanceBehavior.BeforeEachDerivedClass, ClassCleanupBehavior.EndOfAssembly)]
public static void ClassCleanup()
{
s_testContext.WriteLine("LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.ClassCleanup was called");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// 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;
#if NET6_0_OR_GREATER
using System.Threading.Tasks;
#endif

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace SuiteLifeCycleTestProject;

[TestClass]
public class LifeCycleClassCleanupEndOfAssemblyAndNone : IDisposable
#if NET6_0_OR_GREATER
, IAsyncDisposable
#endif
{
private static TestContext s_testContext;

public TestContext TestContext { get; set; }

public LifeCycleClassCleanupEndOfAssemblyAndNone()
{
s_testContext.WriteLine("LifeCycleClassCleanupEndOfAssemblyAndNone.ctor was called");
}

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

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

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

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

public void Dispose()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfAssemblyAndNone.Dispose was called");
}

#if NET6_0_OR_GREATER
public ValueTask DisposeAsync()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfAssemblyAndNone.DisposeAsync was called");
return ValueTask.CompletedTask;
}
#endif

[ClassCleanup(ClassCleanupBehavior.EndOfAssembly)]
public static void ClassCleanup()
{
s_testContext.WriteLine("LifeCycleClassCleanupEndOfAssemblyAndNone.ClassCleanup was called");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// 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;
#if NET6_0_OR_GREATER
using System.Threading.Tasks;
#endif

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace SuiteLifeCycleTestProject;

[TestClass]
public class LifeCycleClassCleanupEndOfClassAndBeforeEachDerivedClass : IDisposable
#if NET6_0_OR_GREATER
, IAsyncDisposable
#endif
{
private static TestContext s_testContext;

public TestContext TestContext { get; set; }

public LifeCycleClassCleanupEndOfClassAndBeforeEachDerivedClass()
{
s_testContext.WriteLine("LifeCycleClassCleanupEndOfClassAndBeforeEachDerivedClass.ctor was called");
}

[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
{
s_testContext = testContext;
s_testContext.WriteLine("LifeCycleClassCleanupEndOfClassAndBeforeEachDerivedClass.ClassInitialize was called");
}

[TestInitialize]
public void TestInitialize()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfClassAndBeforeEachDerivedClass.TestInitialize was called");
}

[TestMethod]
public void TestMethod()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfClassAndBeforeEachDerivedClass.TestMethod was called");
}

[TestCleanup]
public void TestCleanup()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfClassAndBeforeEachDerivedClass.TestCleanup was called");
}

public void Dispose()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfClassAndBeforeEachDerivedClass.Dispose was called");
}

#if NET6_0_OR_GREATER
public ValueTask DisposeAsync()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfClassAndBeforeEachDerivedClass.DisposeAsync was called");
return ValueTask.CompletedTask;
}
#endif

[ClassCleanup(InheritanceBehavior.BeforeEachDerivedClass, ClassCleanupBehavior.EndOfClass)]
public static void ClassCleanup()
{
s_testContext.WriteLine("LifeCycleClassCleanupEndOfClassAndBeforeEachDerivedClass.ClassCleanup was called");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// 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;
#if NET6_0_OR_GREATER
using System.Threading.Tasks;
#endif

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace SuiteLifeCycleTestProject;

[TestClass]
public class LifeCycleClassCleanupEndOfClassAndNone : IDisposable
#if NET6_0_OR_GREATER
, IAsyncDisposable
#endif
{
private static TestContext s_testContext;

public TestContext TestContext { get; set; }

public LifeCycleClassCleanupEndOfClassAndNone()
{
s_testContext.WriteLine("LifeCycleClassCleanupEndOfClassAndNone.ctor was called");
}

[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
{
s_testContext = testContext;
s_testContext.WriteLine("LifeCycleClassCleanupEndOfClassAndNone.ClassInitialize was called");
}

[TestInitialize]
public void TestInitialize()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfClassAndNone.TestInitialize was called");
}

[TestMethod]
public void TestMethod()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfClassAndNone.TestMethod was called");
}

[TestCleanup]
public void TestCleanup()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfClassAndNone.TestCleanup was called");
}

public void Dispose()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfClassAndNone.Dispose was called");
}

#if NET6_0_OR_GREATER
public ValueTask DisposeAsync()
{
TestContext.WriteLine("LifeCycleClassCleanupEndOfClassAndNone.DisposeAsync was called");
return ValueTask.CompletedTask;
}
#endif

[ClassCleanup(ClassCleanupBehavior.EndOfClass)]
public static void ClassCleanup()
{
s_testContext.WriteLine("LifeCycleClassCleanupEndOfClassAndNone.ClassCleanup was called");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace SuiteLifeCycleTestProject;

[TestClass]
public sealed class LifeCycleDerivedClassCleanupEndOfAssemblyAndBeforeEachDerivedClass : LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass
{
private static TestContext s_testContext;

public TestContext DerivedClassTestContext { get; set; }

public LifeCycleDerivedClassCleanupEndOfAssemblyAndBeforeEachDerivedClass()
{
s_testContext.WriteLine("LifeCycleDerivedClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.ctor was called");
}

[ClassInitialize]
public static void DerivedClassInitialize(TestContext testContext)
{
s_testContext = testContext;
s_testContext.WriteLine("LifeCycleDerivedClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.ClassInitialize was called");
}

[TestInitialize]
public void DerivedClassTestInitialize()
{
TestContext.WriteLine("LifeCycleDerivedClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.TestInitialize was called");
}

[TestMethod]
public void DerivedClassTestMethod()
{
TestContext.WriteLine("LifeCycleDerivedClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.TestMethod was called");
}

[TestCleanup]
public void DerivedClassTestCleanup()
{
TestContext.WriteLine("LifeCycleDerivedClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.TestCleanup was called");
}

[ClassCleanup]
public static void DerivedClassCleanup()
{
s_testContext.WriteLine("LifeCycleDerivedClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.ClassCleanup was called");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace SuiteLifeCycleTestProject;

[TestClass]
public sealed class LifeCycleDerivedClassCleanupEndOfAssemblyAndNone : LifeCycleClassCleanupEndOfAssemblyAndNone
{
private static TestContext s_testContext;

public TestContext DerivedClassTestContext { get; set; }

public LifeCycleDerivedClassCleanupEndOfAssemblyAndNone()
{
s_testContext.WriteLine("LifeCycleDerivedClassCleanupEndOfAssemblyAndNone.ctor was called");
}

[ClassInitialize]
public static void DerivedClassInitialize(TestContext testContext)
{
s_testContext = testContext;
s_testContext.WriteLine("LifeCycleDerivedClassCleanupEndOfAssemblyAndNone.ClassInitialize was called");
}

[TestInitialize]
public void DerivedClassTestInitialize()
{
TestContext.WriteLine("LifeCycleDerivedClassCleanupEndOfAssemblyAndNone.TestInitialize was called");
}

[TestMethod]
public void DerivedClassTestMethod()
{
TestContext.WriteLine("LifeCycleDerivedClassCleanupEndOfAssemblyAndNone.TestMethod was called");
}

[TestCleanup]
public void DerivedClassTestCleanup()
{
TestContext.WriteLine("LifeCycleDerivedClassCleanupEndOfAssemblyAndNone.TestCleanup was called");
}

[ClassCleanup]
public static void DerivedClassCleanup()
{
s_testContext.WriteLine("LifeCycleDerivedClassCleanupEndOfAssemblyAndNone.ClassCleanup was called");
}
}
Loading

0 comments on commit 590549c

Please sign in to comment.