예제 #1
0
        public void NonTestRegisterTest()
        {
            // Arrange
            var target = new TestRegistrar();

            Assert.IsFalse(target.AreRegistered());

            var unityMoq = new Mock <IUnityContainer>();

            unityMoq.Setup(c => c.GetHashCode()).Returns(1);

            // Act
            target.Register(unityMoq.Object, false);

            // Assert
            Assert.IsTrue(target.AreRegistered(unityMoq.Object));
            Assert.IsTrue(target.RanRegistration);
            Assert.IsFalse(target.RanTestRegistration);

            // Act
            target.Register(unityMoq.Object, false);

            // Assert
            Assert.IsTrue(target.AreRegistered(unityMoq.Object));
            Assert.IsFalse(target.RanRegistration);
            Assert.IsFalse(target.RanTestRegistration);
        }
예제 #2
0
        public void RegisterUnityTest()
        {
            // Arrange
            var target = new TestRegistrar();

            DIContainer.Reset();

            Assert.IsFalse(target.AreRegistered());

            // Act
            target.Register(null, false);

            // Assert
            Assert.IsTrue(target.AreRegistered());
            Assert.IsTrue(target.RanRegistration);
            Assert.IsFalse(target.RanTestRegistration);

            // Act
            target.Register(null, false);

            // Assert
            Assert.IsTrue(target.AreRegistered());
            Assert.IsFalse(target.RanRegistration);
            Assert.IsFalse(target.RanTestRegistration);
        }
예제 #3
0
        public void TestRegisterTest()
        {
            var target = new TestRegistrar();

            Assert.IsFalse(target.AreRegistered());

            var unityMoq = new Mock <IUnityContainer>();

            target.Register(unityMoq.Object, true);

            Assert.IsTrue(target.AreRegistered(unityMoq.Object));
            Assert.IsFalse(target.RanRegistration);
            Assert.IsTrue(target.RanTestRegistration);

            target.Register(unityMoq.Object, true);

            Assert.IsTrue(target.AreRegistered(unityMoq.Object));
            Assert.IsFalse(target.RanRegistration);
            Assert.IsFalse(target.RanTestRegistration);
        }