Exemple #1
0
        public void PProxyListDefaultBehavior_can_apply_default_behavior_to_throw_FallthroughException_against_one_instance()
        {
            // Arrange
            IndirectionsContext.
            ExcludeGeneric().
            Include(PList <int> .AddT()).
            DefaultBehavior = IndirectionBehaviors.NotImplemented;

            var proxy = new PProxyList <int>();

            proxy.
            ExcludeGeneric().
            IncludeAddT().
            DefaultBehavior = IndirectionBehaviors.Fallthrough;
            LooseCrossDomainAccessor.GetOrRegister <GenericHolder <IndirectionAction <List <int>, int> > >().Source = proxy.AddT().Body;
            LooseCrossDomainAccessor.GetOrRegister <GenericHolder <List <int> > >().Source = (List <int>)proxy;


            // Act
            var addTarget = LooseCrossDomainAccessor.GetOrRegister <GenericHolder <IndirectionAction <List <int>, int> > >().Source;
            var target    = LooseCrossDomainAccessor.GetOrRegister <GenericHolder <List <int> > >().Source;
            var addOther  = PList <int> .AddT().Body;


            // Assert
            Assert.Throws <FallthroughException>(() => addTarget(target, 0));
            Assert.Throws <NotImplementedException>(() => addTarget(new List <int>(), 0));
            Assert.Throws <NotImplementedException>(() => addOther(null, 0));
        }
Exemple #2
0
        public void IsNowLunchBreak_should_return_indeterminate_result_if_original_behavior_is_performed_internally()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                IndirectionsContext.
                ExcludeGeneric().
                DefaultBehavior = IndirectionBehaviors.Fallthrough;

                // Act, Assert
                Assert.DoesNotThrow(() => LifeInfo.IsNowLunchBreak());
            }
        }
Exemple #3
0
        public void IsNowLunchBreak_should_rethrow_any_exception_if_an_exception_is_thrown_internally()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                IndirectionsContext.
                ExcludeGeneric().
                DefaultBehavior = IndirectionBehaviors.NotImplemented;

                // Act, Assert
                Assert.Throws <NotImplementedException>(() => LifeInfo.IsNowLunchBreak());
            }
        }
Exemple #4
0
        public void IsNowLunchBreak_should_return_false_if_default_value_is_returned_internally()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                IndirectionsContext.
                ExcludeGeneric().
                DefaultBehavior = IndirectionBehaviors.DefaultValue;

                // Act
                var result = LifeInfo.IsNowLunchBreak();

                // Assert
                Assert.IsFalse(result);
            }
        }
Exemple #5
0
        public void PArrayDefaultBehavior_can_apply_default_behavior_to_throw_FallthroughException_against_one_type()
        {
            // Arrange
            IndirectionsContext.
            ExcludeGeneric().
            DefaultBehavior = IndirectionBehaviors.NotImplemented;

            PArray.
            ExcludeGeneric().
            IncludeExistsOfTTArrayPredicateOfT <int>().
            DefaultBehavior = IndirectionBehaviors.Fallthrough;


            // Act
            var get_now = PDateTime.NowGet().Body;
            var exists  = PArray.ExistsOfTTArrayPredicateOfT <int>().Body;


            // Assert
            Assert.Throws <NotImplementedException>(() => get_now());
            Assert.Throws <FallthroughException>(() => exists(null, null));
        }
Exemple #6
0
        public void IndirectionsContextDefaultBehavior_can_apply_default_behavior_to_throw_FallthroughException_globally()
        {
            // Arrange
            IndirectionsContext.
            ExcludeGeneric().
            Include(PList <int> .AddT()).
            Include(PArray.ExistsOfTTArrayPredicateOfT <int>()).
            DefaultBehavior = IndirectionBehaviors.Fallthrough;


            // Act
            var get_now = PDateTime.NowGet().Body;
            var add     = PList <int> .AddT().Body;

            var exists = PArray.ExistsOfTTArrayPredicateOfT <int>().Body;


            // Assert
            Assert.Throws <FallthroughException>(() => get_now());
            Assert.Throws <FallthroughException>(() => add(null, 0));
            Assert.Throws <FallthroughException>(() => exists(null, null));
        }
Exemple #7
0
        public void IndirectionsContextDefaultBehavior_can_apply_default_behavior_to_return_default_value_globally()
        {
            // Arrange
            IndirectionsContext.
            ExcludeGeneric().
            Include(PList <int> .AddT()).
            Include(PArray.ExistsOfTTArrayPredicateOfT <int>()).
            DefaultBehavior = IndirectionBehaviors.DefaultValue;


            // Act
            var get_now = PDateTime.NowGet().Body;
            var add     = PList <int> .AddT().Body;

            var exists = PArray.ExistsOfTTArrayPredicateOfT <int>().Body;


            // Assert
            Assert.AreEqual(default(DateTime), get_now());
            Assert.DoesNotThrow(() => add(null, 10));
            Assert.IsFalse(exists(null, null));
        }