示例#1
0
        public void FixtureSetUp()
        {
            LooseCrossDomainAccessor.Clear();
            LooseFunc <int, int, int> .Unload();

            LooseFunc <int, int, int> .Register();
        }
示例#2
0
 public void FixtureSetUp()
 {
     LooseCrossDomainAccessor.Clear();
     LooseStopwatch.Unload();
     LooseStopwatch.Register();
     LooseStopwatch.Holder.Source = new Stopwatch();
 }
示例#3
0
        public void FixtureTearDown()
        {
            LooseFunc <int, int, int> .Holder.Source = null;
            LooseFunc <int, int, int> .Unload();

            LooseCrossDomainAccessor.Clear();
        }
示例#4
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));
        }
示例#5
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));
        }
示例#6
0
        public void FixtureSetUp()
        {
            LooseCrossDomainAccessor.Clear();
            LooseConsole.Unload();
            LooseConsole.Register();
            LooseConsole.Holder.Source = Console.Out;

            // Pre-call to run the action that was registered in this AppDomain,
            // not in other AppDomain but in this AppDomain.
            // Because the event loop that is managed by NUnit GUI - contains calling
            // Write or WriteLine method - runs in other thread.
            Console.Write(string.Empty);
            Console.Out.Flush();
        }
        public new static TException Throws <TException>(TestDelegate code, string message, params object[] args) where TException : Exception
        {
            try
            {
                code();
            }
            catch (Exception ex)
            {
                if (!LooseCrossDomainAccessor.IsTypeOf(ex, typeof(TException)))
                {
                    return(NUnit.Framework.Assert.Throws <TException>(code, message, args));
                }

                return(ex as TException);
            }

            throw new AssertionException("");  // avoid build failure(you will never get here).
        }
示例#8
0
 public void FixtureTearDown()
 {
     LooseStopwatch.Holder.Source = null;
     LooseStopwatch.Unload();
     LooseCrossDomainAccessor.Clear();
 }
示例#9
0
 public void TearDown()
 {
     InstanceGetters.NewAdditionalDelegatesAssemblyRepository = null;
     InstanceGetters.NewIndirectionAssemblyRepository         = null;
     LooseCrossDomainAccessor.Clear();
 }
示例#10
0
 public void SetUp()
 {
     LooseCrossDomainAccessor.Clear();
     InstanceGetters.NewIndirectionAssemblyRepository         = () => new MockIndirectionAssemblyRepository();
     InstanceGetters.NewAdditionalDelegatesAssemblyRepository = () => new MockAdditionalDelegatesAssemblyRepository();
 }