Ejemplo n.º 1
0
        public void Register_ThrowsException_WithMultipleRegistrationOfSameService()
        {
            MockService service = new MockService();
            LifetimeManager lifetimeManager = new LifetimeManager();

            lifetimeManager.Register(service);

            Assert.ThrowsException<InvalidOperationException>(() => lifetimeManager.Register(service));
        }
        public void Unregister_ThrowsException_IfServiceIsNull()
        {
            LifetimeManager lifetimeManager = new LifetimeManager();

            var e = Assert.Throws<ArgumentNullException>(() => lifetimeManager.Unregister(null));

            Assert.Equal("Value cannot be null.\r\nParameter name: service", e.Message);
            Assert.Equal("service", e.ParamName);
        }
Ejemplo n.º 3
0
        public void Unregister_ThrowsException_IfServiceIsNotRegistered()
        {
            MockService service1 = new MockService();
            MockService service2 = new MockService();
            LifetimeManager lifetimeManager = new LifetimeManager();

            lifetimeManager.Register(service1);

            Assert.ThrowsException<InvalidOperationException>(() => lifetimeManager.Unregister(service2));
        }
        public void Register_ThrowsException_WithMultipleRegistrationOfSameService()
        {
            MockService service = new MockService();
            LifetimeManager lifetimeManager = new LifetimeManager();

            lifetimeManager.Register(service);

            var e = Assert.Throws<InvalidOperationException>(() => lifetimeManager.Register(service));

            Assert.Equal("Cannot register the service as it is already registered.", e.Message);
        }
        public void Unregister_ThrowsException_IfServiceIsNotRegistered()
        {
            MockService service1 = new MockService();
            MockService service2 = new MockService();
            LifetimeManager lifetimeManager = new LifetimeManager();

            lifetimeManager.Register(service1);

            var e = Assert.Throws<InvalidOperationException>(() => lifetimeManager.Unregister(service2));

            Assert.Equal("Cannot unregister the service as it is not currently registered.", e.Message);
        }
Ejemplo n.º 6
0
        public void Unregister_ThrowsException_IfServiceIsNull()
        {
            LifetimeManager lifetimeManager = new LifetimeManager();

            Assert.ThrowsException<ArgumentNullException>(() => lifetimeManager.Unregister(null));
        }