Example #1
0
        public void PProxyJapaneseLunisolarCalendarDefaultBehavior_can_apply_default_behavior_to_throw_NotImplementedException_against_one_instance()
        {
            // Arrange
            var proxy = new PProxyJapaneseLunisolarCalendar();

            proxy.
            ExcludeGeneric().
            DefaultBehavior = IndirectionBehaviors.NotImplemented;

            {
                var bag = TaggedBagFactory <OfPJapaneseLunisolarCalendar.GetYearInfoInt32Int32Impl> .Make(proxy.GetYearInfoInt32Int32().Body);

                LooseCrossDomainAccessor.GetOrRegister <GenericHolder <TaggedBag <OfPJapaneseLunisolarCalendar.GetYearInfoInt32Int32Impl, IndirectionFunc <JapaneseLunisolarCalendar, int, int, int> > > >().Source = bag;
            }
            {
                var bag = TaggedBagFactory <OfPJapaneseLunisolarCalendar.GetGregorianYearInt32Int32Impl> .Make(proxy.GetGregorianYearInt32Int32().Body);

                LooseCrossDomainAccessor.GetOrRegister <GenericHolder <TaggedBag <OfPJapaneseLunisolarCalendar.GetGregorianYearInt32Int32Impl, IndirectionFunc <JapaneseLunisolarCalendar, int, int, int> > > >().Source = bag;
            }
            LooseCrossDomainAccessor.GetOrRegister <GenericHolder <JapaneseLunisolarCalendar> >().Source = (JapaneseLunisolarCalendar)proxy;


            // Act
            var getYearInfoTarget      = LooseCrossDomainAccessor.GetOrRegister <GenericHolder <TaggedBag <OfPJapaneseLunisolarCalendar.GetYearInfoInt32Int32Impl, IndirectionFunc <JapaneseLunisolarCalendar, int, int, int> > > >().Source.Value;
            var getGregorianYearTarget = LooseCrossDomainAccessor.GetOrRegister <GenericHolder <TaggedBag <OfPJapaneseLunisolarCalendar.GetGregorianYearInt32Int32Impl, IndirectionFunc <JapaneseLunisolarCalendar, int, int, int> > > >().Source.Value;
            var target = LooseCrossDomainAccessor.GetOrRegister <GenericHolder <JapaneseLunisolarCalendar> >().Source;


            // Assert
            Assert.Throws <NotImplementedException>(() => getGregorianYearTarget(target, 0, 0));
            Assert.Throws <FallthroughException>(() => getGregorianYearTarget(new JapaneseLunisolarCalendar(), 0, 0));
            Assert.Throws <NotImplementedException>(() => getYearInfoTarget(target, 0, 0));
            Assert.Throws <FallthroughException>(() => getYearInfoTarget(new JapaneseLunisolarCalendar(), 0, 0));
        }
Example #2
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));
        }
Example #3
0
        public void PArrayDefaultBehavior_can_apply_default_behavior_to_throw_NotImplementedException_against_one_type()
        {
            // Arrange
            PArray.
            ExcludeGeneric().
            IncludeExistsOfTTArrayPredicateOfT <int>().
            DefaultBehavior = IndirectionBehaviors.NotImplemented;


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


            // Assert
            Assert.IsNull(get_now);
            Assert.Throws <NotImplementedException>(() => exists(null, null));
        }
Example #4
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));
        }
Example #5
0
        public void IndirectionHolder_can_transport_untyped_delegates_to_different_AppDomain()
        {
            // Arrange
            {
                PULColumns.ValidateStateULTableStatus().Body = args => { throw new NotSupportedException(); };
                #region Prepare JIT. This simulates the behavior during profiling. Actually, it is unnecessary to go that far with that.
                var validateStateULTableStatus = PULColumns.ValidateStateULTableStatus().Body;
                Assert.Throws <NotSupportedException>(() => validateStateULTableStatus(new object[] { new ULTableStatus() }));
                #endregion
            }

            AppDomain.CurrentDomain.RunAtIsolatedDomain(() =>
            {
                InstanceGetters.NewAdditionalDelegatesAssemblyRepository = () => new MockAdditionalDelegatesAssemblyRepository();

                // Act
                var validateStateULTableStatus = PULColumns.ValidateStateULTableStatus().Body;


                // Assert
                Assert.Throws <NotSupportedException>(() => validateStateULTableStatus(new object[] { new ULTableStatus() }));
            });
        }