-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Integration tests for cleanup inheritance behaviors with differen…
…t scenarios (#1459) Co-authored-by: Amaury Levé <amauryleve@microsoft.com>
- Loading branch information
1 parent
8b0b6d0
commit 590549c
Showing
9 changed files
with
737 additions
and
3 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
.../SuiteLifeCycleTestProject/LifeCycleClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
...2ETests/TestAssets/SuiteLifeCycleTestProject/LifeCycleClassCleanupEndOfAssemblyAndNone.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
...ets/SuiteLifeCycleTestProject/LifeCycleClassCleanupEndOfClassAndBeforeEachDerivedClass.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
test/E2ETests/TestAssets/SuiteLifeCycleTestProject/LifeCycleClassCleanupEndOfClassAndNone.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...ifeCycleTestProject/LifeCycleDerivedClassCleanupEndOfAssemblyAndBeforeEachDerivedClass.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
.../TestAssets/SuiteLifeCycleTestProject/LifeCycleDerivedClassCleanupEndOfAssemblyAndNone.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |
Oops, something went wrong.