-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BookLib: rename test base class to ApplicationsTest
- Loading branch information
Showing
10 changed files
with
58 additions
and
58 deletions.
There are no files selected for viewing
96 changes: 48 additions & 48 deletions
96
...ibrary.Applications.Test/TestClassBase.cs → ...ary.Applications.Test/ApplicationsTest.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 |
---|---|---|
@@ -1,48 +1,48 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System.ComponentModel.Composition; | ||
using System.ComponentModel.Composition.Hosting; | ||
using System.Waf.UnitTesting.Mocks; | ||
using Waf.BookLibrary.Library.Applications.Controllers; | ||
|
||
namespace Test.BookLibrary.Library.Applications; | ||
|
||
[TestClass] | ||
public abstract class TestClassBase | ||
{ | ||
public CompositionContainer? Container { get; private set; } | ||
|
||
[TestInitialize] | ||
public void Initialize() | ||
{ | ||
var catalog = new AggregateCatalog(); | ||
catalog.Catalogs.Add(new AssemblyCatalog(typeof(MockMessageService).Assembly)); | ||
catalog.Catalogs.Add(new AssemblyCatalog(typeof(TestClassBase).Assembly)); | ||
catalog.Catalogs.Add(new AssemblyCatalog(typeof(ModuleController).Assembly)); | ||
|
||
OnCatalogInitialize(catalog); | ||
|
||
Container = new(catalog, CompositionOptions.DisableSilentRejection); | ||
var batch = new CompositionBatch(); | ||
batch.AddExportedValue(Container); | ||
Container.Compose(batch); | ||
|
||
OnInitialize(); | ||
} | ||
|
||
[TestCleanup] | ||
public void Cleanup() | ||
{ | ||
OnCleanup(); | ||
Container?.Dispose(); | ||
} | ||
|
||
public T Get<T>() => Container!.GetExportedValue<T>(); | ||
|
||
public Lazy<T> GetLazy<T>() => new(() => Container!.GetExportedValue<T>()); | ||
|
||
protected virtual void OnCatalogInitialize(AggregateCatalog catalog) { } | ||
|
||
protected virtual void OnInitialize() { } | ||
|
||
protected virtual void OnCleanup() { } | ||
} | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System.ComponentModel.Composition; | ||
using System.ComponentModel.Composition.Hosting; | ||
using System.Waf.UnitTesting.Mocks; | ||
using Waf.BookLibrary.Library.Applications.Controllers; | ||
|
||
namespace Test.BookLibrary.Library.Applications; | ||
|
||
[TestClass] | ||
public abstract class ApplicationsTest | ||
{ | ||
public CompositionContainer? Container { get; private set; } | ||
|
||
[TestInitialize] | ||
public void Initialize() | ||
{ | ||
var catalog = new AggregateCatalog(); | ||
catalog.Catalogs.Add(new AssemblyCatalog(typeof(MockMessageService).Assembly)); | ||
catalog.Catalogs.Add(new AssemblyCatalog(typeof(ApplicationsTest).Assembly)); | ||
catalog.Catalogs.Add(new AssemblyCatalog(typeof(ModuleController).Assembly)); | ||
|
||
OnCatalogInitialize(catalog); | ||
|
||
Container = new(catalog, CompositionOptions.DisableSilentRejection); | ||
var batch = new CompositionBatch(); | ||
batch.AddExportedValue(Container); | ||
Container.Compose(batch); | ||
|
||
OnInitialize(); | ||
} | ||
|
||
[TestCleanup] | ||
public void Cleanup() | ||
{ | ||
OnCleanup(); | ||
Container?.Dispose(); | ||
} | ||
|
||
public T Get<T>() => Container!.GetExportedValue<T>(); | ||
|
||
public Lazy<T> GetLazy<T>() => new(() => Container!.GetExportedValue<T>()); | ||
|
||
protected virtual void OnCatalogInitialize(AggregateCatalog catalog) { } | ||
|
||
protected virtual void OnInitialize() { } | ||
|
||
protected virtual void OnCleanup() { } | ||
} |
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
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
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
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
4 changes: 2 additions & 2 deletions
4
...ystem.Waf/Samples/BookLibrary/BookLibrary.Library.Applications.Test/GlobalSuppressions.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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[assembly: SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", Scope = "type", Target = "~T:Test.BookLibrary.Library.Applications.TestClassBase")] | ||
[assembly: SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope", Justification = "<Pending>", Scope = "member", Target = "~M:Test.BookLibrary.Library.Applications.TestClassBase.Initialize")] | ||
[assembly: SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", Scope = "type", Target = "~T:Test.BookLibrary.Library.Applications.ApplicationsTest")] | ||
[assembly: SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope", Justification = "<Pending>", Scope = "member", Target = "~M:Test.BookLibrary.Library.Applications.ApplicationsTest.Initialize")] | ||
|
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
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
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
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