Example #1
0
        public void WhenBuildingWithoutParameterlessCtorServiceThenThrowsNotSupportedException()
        {
            // Assign
            BadService          service = new BadService("test");
            DefaultProxyBuilder builder = this.CreateTestableBuilder();

            this.interceptor.Setup(i => i.OnExecuting());
            this.interceptor.Setup(i => i.OnExecuted());
            this.interceptor.Setup(i => i.OnException(It.IsAny <Exception>()));
            bool exceptionRaised = false;

            // Act
            try
            {
                builder.Build(service, this.interceptor.Object);
            }
            catch (NotSupportedException)
            {
                exceptionRaised = true;
            }

            // Assert
            this.interceptor.Verify(i => i.OnExecuting(), Times.Never());
            this.interceptor.Verify(i => i.OnExecuted(), Times.Never());
            this.interceptor.Verify(i => i.OnException(It.IsAny <Exception>()), Times.Never());
            Assert.True(exceptionRaised);
        }
Example #2
0
        public void WhenBuildingWithoutParameterlessCtorServiceThenThrowsNotSupportedException()
        {
            // Assign
            BadService service = new BadService("test");
            DefaultProxyBuilder builder = this.CreateTestableBuilder();

            this.interceptor.Setup(i => i.OnExecuting());
            this.interceptor.Setup(i => i.OnExecuted());
            this.interceptor.Setup(i => i.OnException(It.IsAny<Exception>()));
            bool exceptionRaised = false;

            // Act
            try
            {
                builder.Build(service, this.interceptor.Object);
            }
            catch (NotSupportedException)
            {
                exceptionRaised = true;
            }

            // Assert
            this.interceptor.Verify(i => i.OnExecuting(), Times.Never());
            this.interceptor.Verify(i => i.OnExecuted(), Times.Never());
            this.interceptor.Verify(i => i.OnException(It.IsAny<Exception>()), Times.Never());
            Assert.True(exceptionRaised);
        }