Esempio n. 1
0
        public void VariousOperations_PublishCorrectEvents()
        {
            ParameterizedTest
            .TestCase <Action <ScreenLifecycleOperations>, IEvent>(x => x.Initialize(), ScreenEvents.Initialize())
            .TestCase(x => x.Initialize(new Subject()), ScreenEvents.Initialize <Subject>())
            .TestCase(x => x.Activate(), ScreenEvents.Activate)
            .TestCase(x => x.Deactivate(), ScreenEvents.Deactivate)
            .TestCase(x => x.RequestClose(), ScreenEvents.RequestClose)
            .TestCase(x => x.Close(), ScreenEvents.Close)
            .Run((lifecycleAction, expectedEvent) => {
                List <IEvent> actualEvents    = new List <IEvent>();
                TestScreen screen             = new TestScreen();
                ScreenLifecycleOperations ops = new ScreenLifecycleOperations(Aggregator, screen);

                AddEventHandlerForAllEvents(
                    screen,
                    handlerAction: actualEvents.Add,
                    includeExceptionOccured: true
                    );

                lifecycleAction(ops);

                IEvent actualEvent = actualEvents.SingleOrDefault();
                Assert.AreEqual(expectedEvent, actualEvent);
            });
        }
Esempio n. 2
0
 public NormalGameView(Context context, IAttributeSet attrs, int defStyle)
     : base(context, attrs, defStyle)
 {
     GraphicMode = false;
     InitGameView ();
     screenEvents = new ScreenEvents (this);
 }
Esempio n. 3
0
 public GraphicGameView(Context context, IAttributeSet attrs)
     : base(context, attrs)
 {
     GraphicMode = true;
     InitGameView ();
     screenEvents = new ScreenEvents (this);
 }
Esempio n. 4
0
        public int CreatePresentations()
        {
            int namesProcessed = 0;

            ProcessTextBox.Text = string.Empty;


            //  this is also the trust ID
            List <string> names = GetNamesList();

            ProcessTextBox.AppendText("Processing: ");


            if (BuildPowerPointFile(names))
            {
                ProcessTextBox.AppendText(" - done");
                namesProcessed++;
            }

            ProcessTextBox.AppendText(Environment.NewLine);
            ProcessTextBox.ScrollToEnd();
            //ProcessedCount.Text = namesProcessed.ToString();

            ScreenEvents.DoEvents();


            return(namesProcessed);
        }
Esempio n. 5
0
 public LocatableScreen(EventAggregator aggregator)
     : base(aggregator)
 {
     Lifecycle.RegisterHandler(
         ScreenEvents.Initialize <BaseSubject>(),
         args => Subject = args.Subject
         );
 }
Esempio n. 6
0
 public InitializableScreen(EventAggregator aggregator)
     : base(aggregator)
 {
     Lifecycle.RegisterHandler(
         ScreenEvents.Initialize(),
         args => InitializeWasCalled = true
         );
 }
 protected void AttachEventHandlers()
 {
     AttachHandler(ScreenEvents.Initialize());
     AttachHandler(ScreenEvents.Initialize <TestSubject>());
     AttachHandler(ScreenEvents.Activate);
     AttachHandler(ScreenEvents.Deactivate);
     AttachHandler(ScreenEvents.RequestClose);
     AttachHandler(ScreenEvents.Close);
     AttachHandler(ScreenEvents.LifecycleExceptionOccured);
 }
Esempio n. 8
0
            public ScreenMock(EventAggregator aggregator)
                : base(aggregator)
            {
                RequestCloseResult = true;

                Lifecycle.RegisterHandler(ScreenEvents.Initialize(), Initialize);
                Lifecycle.RegisterHandler(ScreenEvents.Activate, OnActivate);
                Lifecycle.RegisterHandler(ScreenEvents.Deactivate, OnDeactivate);
                Lifecycle.RegisterHandler(ScreenEvents.RequestClose, OnRequestClose);
                Lifecycle.RegisterHandler(ScreenEvents.Close, OnClose);
            }
Esempio n. 9
0
        public void VariousOperations_WhenHandlerThrowsException_RaiseLifecycleExceptionOccuredEventAndThrowLifecycleException()
        {
            ParameterizedTest
            .TestCase <Action <ScreenLifecycleOperations>, IEvent>(x => x.Initialize(), ScreenEvents.Initialize())
            .TestCase(x => x.Initialize(new Subject()), ScreenEvents.Initialize <Subject>())
            .TestCase(x => x.Activate(), ScreenEvents.Activate)
            .TestCase(x => x.Deactivate(), ScreenEvents.Deactivate)
            .TestCase(x => x.RequestClose(), ScreenEvents.RequestClose)
            .TestCase(x => x.Close(), ScreenEvents.Close)
            .Run((lifecycleAction, expectedEvent) => {
                List <IEvent> actualEvents    = new List <IEvent>();
                TestScreen screen             = new TestScreen();
                ScreenLifecycleOperations ops = new ScreenLifecycleOperations(Aggregator, screen);

                InvalidOperationException sourceException = new InvalidOperationException();

                AddEventHandlerForAllEvents(
                    screen,
                    handlerAction: e => {
                    actualEvents.Add(e);
                    throw sourceException;
                },
                    includeExceptionOccured: false
                    );

                AddEventHandlerFor(
                    ScreenEvents.LifecycleExceptionOccured,
                    screen,
                    handlerAction: (ev, _) => actualEvents.Add(ev)
                    );

                var exceptionExpr = AssertHelper.Throws <ScreenLifecycleException>(() =>
                                                                                   lifecycleAction(ops)
                                                                                   );

                CollectionAssert.AreEquivalent(
                    new IEvent[] {
                    expectedEvent,
                    ScreenEvents.LifecycleExceptionOccured
                },
                    actualEvents
                    );

                Assert.AreEqual(sourceException, exceptionExpr.Exception.InnerException);
            });
        }
Esempio n. 10
0
        private void AddEventHandlerForAllEvents(
            IScreenBase target,
            Action <IEvent> handlerAction,
            bool includeExceptionOccured = false
            )
        {
            Action <IEvent, object> action = (ev, _) => handlerAction(ev);

            AddEventHandlerFor(ScreenEvents.Initialize(), target, action);
            AddEventHandlerFor(ScreenEvents.Initialize <Subject>(), target, action);
            AddEventHandlerFor(ScreenEvents.Activate, target, action);
            AddEventHandlerFor(ScreenEvents.Deactivate, target, action);
            AddEventHandlerFor(ScreenEvents.RequestClose, target, action);
            AddEventHandlerFor(ScreenEvents.Close, target, action);

            if (includeExceptionOccured)
            {
                AddEventHandlerFor(ScreenEvents.LifecycleExceptionOccured, target, action);
            }
        }
Esempio n. 11
0
 public void RemoveEventListener(ScreenEvents type, Action listener)
 {
 }
Esempio n. 12
0
 public void RemoveEventListener(ScreenEvents type, Action listener, bool capture)
 {
 }
 public void CreatedState_HandlesEventsCorrectly()
 {
     ParameterizedTest
     .TestCase(Success(LifecycleState.Created, TriggerEvent.Initialize, LifecycleState.Initialized, ScreenEvents.Initialize()))
     .TestCase(Success(LifecycleState.Created, TriggerEvent.InitializeSubject, LifecycleState.Initialized, ScreenEvents.Initialize(), ScreenEvents.Initialize <TestSubject>()))
     .TestCase(InvalidStateException(LifecycleState.Created, TriggerEvent.Activate))
     .TestCase(InvalidStateException(LifecycleState.Created, TriggerEvent.Deactivate))
     .TestCase(InvalidStateException(LifecycleState.Created, TriggerEvent.RequestClose))
     .TestCase(InvalidStateException(LifecycleState.Created, TriggerEvent.Close))
     .TestCase(InvalidStateException(LifecycleState.Created, TriggerEvent.LifecycleException))
     .Run(ExecuteTestCase);
 }
 public ScreenWithInterfaceSubject(EventAggregator aggregator)
     : base(aggregator)
 {
     Lifecycle.RegisterHandler(ScreenEvents.Initialize <ISubject>(), HandleInitialize);
 }
Esempio n. 15
0
 public void AddEventListener(ScreenEvents type, IEventListener listener, bool capture)
 {
 }
Esempio n. 16
0
 public void RemoveEventListener(ScreenEvents type, HtmlEventHandler listener)
 {
 }
Esempio n. 17
0
 public void AddEventListener(ScreenEvents type, HtmlEventHandler listener)
 {
 }
Esempio n. 18
0
 public void RemoveEventListener(ScreenEvents type, HtmlEventHandlerWithTarget<Screen> listener, bool capture)
 {
 }
Esempio n. 19
0
 public void AddEventListener(ScreenEvents type, HtmlEventHandlerWithTarget<Screen> listener)
 {
 }
 public TestScreen(EventAggregator aggregator)
     : base(aggregator)
 {
     Lifecycle.RegisterHandler(ScreenEvents.Initialize <TSubject>(), HandleInitialize);
 }
Esempio n. 21
0
 public void AddEventListener(ScreenEvents type, IEventListener listener)
 {
 }
Esempio n. 22
0
 public void RemoveEventListener(ScreenEvents type, IEventListener listener, bool capture)
 {
 }
Esempio n. 23
0
 public void RemoveEventListener(ScreenEvents type, IEventListener listener)
 {
 }
Esempio n. 24
0
 public void RemoveEventListener(ScreenEvents type, HtmlEventHandlerWithTarget <Screen> listener)
 {
 }
Esempio n. 25
0
 public void AddEventListener(ScreenEvents type, HtmlEventHandlerWithTarget <Screen> listener, bool capture)
 {
 }
Esempio n. 26
0
 public void RemoveEventListener(ScreenEvents type, IEventListener listener)
 {
 }
Esempio n. 27
0
 public void RemoveEventListener(ScreenEvents type, HtmlEventHandler listener, bool capture)
 {
 }
Esempio n. 28
0
 public void AddEventListener(ScreenEvents type, HtmlEventHandler listener, bool capture)
 {
 }
Esempio n. 29
0
 public void AddEventListener(ScreenEvents type, Action listener, bool capture)
 {
 }
Esempio n. 30
0
 public void AddEventListener(ScreenEvents type, IEventListener listener)
 {
 }
Esempio n. 31
0
 public void AddEventListener(ScreenEvents type, Action listener)
 {
 }
Esempio n. 32
0
 public void AddEventListener(ScreenEvents type, Action listener)
 {
 }
Esempio n. 33
0
 public void RemoveEventListener(ScreenEvents type, Action listener)
 {
 }