Skip to content

Commit f682322

Browse files
committed
Change generic testing methods for verifing registered types
Instead of returning a bool use assertions
1 parent 3de3b2e commit f682322

3 files changed

Lines changed: 13 additions & 8 deletions

File tree

src/UnityContainerAttributeRegistrationTest/Attribute/RegisterInstanceAttributeTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public void TestPopulate(Type providerType, Type expectedFrom, Type expectedTo,
4242
IList<IContainerRegistration> result = container.Registrations.ToArray();
4343

4444
AreEqual(2, result.Count);
45-
IsTrue(IsUnityContainerRegistration(result[0]));
46-
IsTrue(IsExpectedRegisteredContainer(result[1], expectedFrom, expectedTo, expectedInstanceLifetimeManagerType));
45+
IsUnityContainerRegistration(result[0]);
46+
IsExpectedRegisteredContainer(result[1], expectedFrom, expectedTo, expectedInstanceLifetimeManagerType);
4747
}
4848

4949
[Test]

src/UnityContainerAttributeRegistrationTest/Attribute/RegisterTypeAttributeTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ public void TestPopulate(Type to, Type expectedFrom, Type expectedTypeLifetimeMa
7171

7272
AreEqual(2, result.Count);
7373

74-
IsTrue(IsUnityContainerRegistration(result[0]));
75-
IsTrue(IsExpectedRegisteredContainer(result[1], expectedFrom, to, expectedTypeLifetimeMangerType));
74+
IsUnityContainerRegistration(result[0]);
75+
IsExpectedRegisteredContainer(result[1], expectedFrom, to, expectedTypeLifetimeMangerType);
7676
}
7777

7878
[Test]

src/UnityContainerAttributeRegistrationTest/Helper/TestBase.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,23 @@
22

33
using Unity;
44

5+
using static NUnit.Framework.Assert;
6+
57

68
namespace UnityContainerAttributeRegistrationTest.Helper
79
{
810
public abstract class TestBase
911
{
10-
protected bool IsUnityContainerRegistration(IContainerRegistration registration)
12+
protected void IsUnityContainerRegistration(IContainerRegistration registration)
1113
{
1214
bool registeredType = registration.RegisteredType == typeof(IUnityContainer);
1315
bool mappedToType = registration.MappedToType == typeof(UnityContainer);
1416

15-
return registeredType && mappedToType;
17+
IsTrue(registeredType);
18+
IsTrue(mappedToType);
1619
}
1720

18-
protected bool IsExpectedRegisteredContainer(IContainerRegistration registration,
21+
protected void IsExpectedRegisteredContainer(IContainerRegistration registration,
1922
Type expectedFrom,
2023
Type expectedTo,
2124
Type expectedTypeLifetimeManagerType)
@@ -24,7 +27,9 @@ protected bool IsExpectedRegisteredContainer(IContainerRegistration registration
2427
bool mappedToType = registration.MappedToType == expectedTo;
2528
bool lifetimeManager = registration.LifetimeManager.GetType() == expectedTypeLifetimeManagerType;
2629

27-
return registeredType && mappedToType && lifetimeManager;
30+
IsTrue(registeredType);
31+
IsTrue(mappedToType);
32+
IsTrue(lifetimeManager);
2833
}
2934
}
3035
}

0 commit comments

Comments
 (0)