Skip to content

Commit d7b6679

Browse files
committed
BookLib: rename test base class to ApplicationsTest
1 parent c232f20 commit d7b6679

File tree

10 files changed

+58
-58
lines changed

10 files changed

+58
-58
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
1-
using Microsoft.VisualStudio.TestTools.UnitTesting;
2-
using System.ComponentModel.Composition;
3-
using System.ComponentModel.Composition.Hosting;
4-
using System.Waf.UnitTesting.Mocks;
5-
using Waf.BookLibrary.Library.Applications.Controllers;
6-
7-
namespace Test.BookLibrary.Library.Applications;
8-
9-
[TestClass]
10-
public abstract class TestClassBase
11-
{
12-
public CompositionContainer? Container { get; private set; }
13-
14-
[TestInitialize]
15-
public void Initialize()
16-
{
17-
var catalog = new AggregateCatalog();
18-
catalog.Catalogs.Add(new AssemblyCatalog(typeof(MockMessageService).Assembly));
19-
catalog.Catalogs.Add(new AssemblyCatalog(typeof(TestClassBase).Assembly));
20-
catalog.Catalogs.Add(new AssemblyCatalog(typeof(ModuleController).Assembly));
21-
22-
OnCatalogInitialize(catalog);
23-
24-
Container = new(catalog, CompositionOptions.DisableSilentRejection);
25-
var batch = new CompositionBatch();
26-
batch.AddExportedValue(Container);
27-
Container.Compose(batch);
28-
29-
OnInitialize();
30-
}
31-
32-
[TestCleanup]
33-
public void Cleanup()
34-
{
35-
OnCleanup();
36-
Container?.Dispose();
37-
}
38-
39-
public T Get<T>() => Container!.GetExportedValue<T>();
40-
41-
public Lazy<T> GetLazy<T>() => new(() => Container!.GetExportedValue<T>());
42-
43-
protected virtual void OnCatalogInitialize(AggregateCatalog catalog) { }
44-
45-
protected virtual void OnInitialize() { }
46-
47-
protected virtual void OnCleanup() { }
48-
}
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using System.ComponentModel.Composition;
3+
using System.ComponentModel.Composition.Hosting;
4+
using System.Waf.UnitTesting.Mocks;
5+
using Waf.BookLibrary.Library.Applications.Controllers;
6+
7+
namespace Test.BookLibrary.Library.Applications;
8+
9+
[TestClass]
10+
public abstract class ApplicationsTest
11+
{
12+
public CompositionContainer? Container { get; private set; }
13+
14+
[TestInitialize]
15+
public void Initialize()
16+
{
17+
var catalog = new AggregateCatalog();
18+
catalog.Catalogs.Add(new AssemblyCatalog(typeof(MockMessageService).Assembly));
19+
catalog.Catalogs.Add(new AssemblyCatalog(typeof(ApplicationsTest).Assembly));
20+
catalog.Catalogs.Add(new AssemblyCatalog(typeof(ModuleController).Assembly));
21+
22+
OnCatalogInitialize(catalog);
23+
24+
Container = new(catalog, CompositionOptions.DisableSilentRejection);
25+
var batch = new CompositionBatch();
26+
batch.AddExportedValue(Container);
27+
Container.Compose(batch);
28+
29+
OnInitialize();
30+
}
31+
32+
[TestCleanup]
33+
public void Cleanup()
34+
{
35+
OnCleanup();
36+
Container?.Dispose();
37+
}
38+
39+
public T Get<T>() => Container!.GetExportedValue<T>();
40+
41+
public Lazy<T> GetLazy<T>() => new(() => Container!.GetExportedValue<T>());
42+
43+
protected virtual void OnCatalogInitialize(AggregateCatalog catalog) { }
44+
45+
protected virtual void OnInitialize() { }
46+
47+
protected virtual void OnCleanup() { }
48+
}

src/System.Waf/Samples/BookLibrary/BookLibrary.Library.Applications.Test/Controllers/BookControllerTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Test.BookLibrary.Library.Applications.Controllers;
1313

1414
[TestClass]
15-
public class BookControllerTest : TestClassBase
15+
public class BookControllerTest : ApplicationsTest
1616
{
1717
protected override void OnInitialize()
1818
{

src/System.Waf/Samples/BookLibrary/BookLibrary.Library.Applications.Test/Controllers/EntityControllerTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
namespace Test.BookLibrary.Library.Applications.Controllers;
1010

1111
[TestClass]
12-
public class EntityControllerTest : TestClassBase
12+
public class EntityControllerTest : ApplicationsTest
1313
{
1414
[TestMethod]
1515
public void ValidateBeforeSave()

src/System.Waf/Samples/BookLibrary/BookLibrary.Library.Applications.Test/Controllers/ModuleControllerTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Test.BookLibrary.Library.Applications.Controllers;
1313

1414
[TestClass]
15-
public class ModuleControllerTest : TestClassBase
15+
public class ModuleControllerTest : ApplicationsTest
1616
{
1717
protected override void OnInitialize()
1818
{

src/System.Waf/Samples/BookLibrary/BookLibrary.Library.Applications.Test/Controllers/PersonControllerTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace Test.BookLibrary.Library.Applications.Controllers;
1515

1616
[TestClass]
17-
public class PersonControllerTest : TestClassBase
17+
public class PersonControllerTest : ApplicationsTest
1818
{
1919
protected override void OnInitialize()
2020
{
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[assembly: SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", Scope = "type", Target = "~T:Test.BookLibrary.Library.Applications.TestClassBase")]
2-
[assembly: SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope", Justification = "<Pending>", Scope = "member", Target = "~M:Test.BookLibrary.Library.Applications.TestClassBase.Initialize")]
1+
[assembly: SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", Scope = "type", Target = "~T:Test.BookLibrary.Library.Applications.ApplicationsTest")]
2+
[assembly: SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope", Justification = "<Pending>", Scope = "member", Target = "~M:Test.BookLibrary.Library.Applications.ApplicationsTest.Initialize")]
33

src/System.Waf/Samples/BookLibrary/BookLibrary.Library.Applications.Test/ViewModels/LendToViewModelTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace Test.BookLibrary.Library.Applications.ViewModels;
88

99
[TestClass]
10-
public class LendToViewModelTest : TestClassBase
10+
public class LendToViewModelTest : ApplicationsTest
1111
{
1212
protected override void OnCleanup()
1313
{

src/System.Waf/Samples/BookLibrary/BookLibrary.Library.Applications.Test/ViewModels/PersonListViewModelTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace Test.BookLibrary.Library.Applications.ViewModels;
88

99
[TestClass]
10-
public class PersonListViewModelTest : TestClassBase
10+
public class PersonListViewModelTest : ApplicationsTest
1111
{
1212
[TestMethod]
1313
public void PersonListViewModelPersonsTest()

src/System.Waf/Samples/BookLibrary/BookLibrary.Library.Applications.Test/ViewModels/ShellViewModelTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace Test.BookLibrary.Library.Applications.ViewModels;
1111

1212
[TestClass]
13-
public class ShellViewModelTest : TestClassBase
13+
public class ShellViewModelTest : ApplicationsTest
1414
{
1515
[TestMethod]
1616
public void ShellViewModelBasicTest()

src/System.Waf/Samples/BookLibrary/BookLibrary.Reporting.Applications.Test/ReportingTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Test.BookLibrary.Reporting.Applications;
77

88
[TestClass]
9-
public class ReportingTest : TestClassBase
9+
public class ReportingTest : ApplicationsTest
1010
{
1111
protected override void OnCatalogInitialize(AggregateCatalog catalog)
1212
{

0 commit comments

Comments
 (0)