public void Interceptor_is_created_for_given_type()
        {
            Assert.IsType <Perfect>(new InterceptorElement(1)
            {
                TypeName = typeof(Perfect).AssemblyQualifiedName
            }.CreateInterceptor());

            var element = new InterceptorElement(1)
            {
                TypeName = typeof(Day).AssemblyQualifiedName
            };

            var arg = element.Parameters.NewElement();

            arg.ValueString = "1";

            arg             = element.Parameters.NewElement();
            arg.ValueString = "2";
            arg.TypeName    = "System.Int32";

            var interceptor = (Day)element.CreateInterceptor();

            Assert.Equal("1", interceptor.Such);
            Assert.Equal(2, interceptor.A);
        }
        public void Exception_is_thrown_if_type_could_not_be_loaded()
        {
            var element = new InterceptorElement(1)
            {
                TypeName = "HanginRound"
            };

            Assert.Equal(
                Strings.InterceptorTypeNotFound("HanginRound"),
                Assert.Throws <InvalidOperationException>(() => element.CreateInterceptor()).Message);
        }
        public void Exception_is_thrown_if_constructor_arguments_dont_match_expected_parameters()
        {
            var element = new InterceptorElement(1)
            {
                TypeName = typeof(SatelliteOfLove).AssemblyQualifiedName
            };

            Assert.Equal(
                Strings.InterceptorTypeNotFound(typeof(SatelliteOfLove).AssemblyQualifiedName),
                Assert.Throws <InvalidOperationException>(() => element.CreateInterceptor()).Message);

            var arg = element.Parameters.NewElement();

            arg.ValueString = "1";
            arg.TypeName    = "System.Int32";

            Assert.Equal(
                Strings.InterceptorTypeNotFound(typeof(SatelliteOfLove).AssemblyQualifiedName),
                Assert.Throws <InvalidOperationException>(() => element.CreateInterceptor()).Message);
        }
        public void Exception_is_thrown_for_type_that_does_not_implement_IDbInterceptor()
        {
            var element = new InterceptorElement(1)
            {
                TypeName = typeof(WalkOnTheWildSide).AssemblyQualifiedName
            };

            Assert.Equal(
                Strings.InterceptorTypeNotInterceptor(typeof(WalkOnTheWildSide).AssemblyQualifiedName),
                Assert.Throws <InvalidOperationException>(() => element.CreateInterceptor()).Message);
        }
        public void Interceptor_is_created_for_given_type()
        {
            Assert.IsType<Perfect>(new InterceptorElement(1) { TypeName = typeof(Perfect).AssemblyQualifiedName }.CreateInterceptor());

            var element = new InterceptorElement(1) { TypeName = typeof(Day).AssemblyQualifiedName };
            
            var arg = element.Parameters.NewElement();
            arg.ValueString = "1";
            
            arg = element.Parameters.NewElement();
            arg.ValueString = "2";
            arg.TypeName = "System.Int32";

            var interceptor = (Day)element.CreateInterceptor();
            Assert.Equal("1", interceptor.Such);
            Assert.Equal(2, interceptor.A);
        }
        public void Exception_is_thrown_for_type_that_does_not_implement_IDbInterceptor()
        {
            var element = new InterceptorElement(1) { TypeName = typeof(WalkOnTheWildSide).AssemblyQualifiedName };

            Assert.Equal(
                Strings.InterceptorTypeNotInterceptor(typeof(WalkOnTheWildSide).AssemblyQualifiedName),
                Assert.Throws<InvalidOperationException>(() => element.CreateInterceptor()).Message);
        }
        public void Exception_is_thrown_if_type_could_not_be_loaded()
        {
            var element = new InterceptorElement(1) { TypeName = "HanginRound" };

            Assert.Equal(
                Strings.InterceptorTypeNotFound("HanginRound"),
                Assert.Throws<InvalidOperationException>(() => element.CreateInterceptor()).Message);
        }
        public void Exception_is_thrown_if_constructor_arguments_dont_match_expected_parameters()
        {
            var element = new InterceptorElement(1) { TypeName = typeof(SatelliteOfLove).AssemblyQualifiedName };

            Assert.Equal(
                Strings.InterceptorTypeNotFound(typeof(SatelliteOfLove).AssemblyQualifiedName),
                Assert.Throws<InvalidOperationException>(() => element.CreateInterceptor()).Message);

            var arg = element.Parameters.NewElement();
            arg.ValueString = "1";
            arg.TypeName = "System.Int32";

            Assert.Equal(
                Strings.InterceptorTypeNotFound(typeof(SatelliteOfLove).AssemblyQualifiedName),
                Assert.Throws<InvalidOperationException>(() => element.CreateInterceptor()).Message);
        }