public EventFiredHandlerDecorator Initialize(EventFiredHandlerDecorator localHandler)
            {
                this.decorator = new EventFiredHandlerDecorator();

                // With the unit test factory everything becomes synchronous
                this.remoteEventBroker = new EventBroker(new UnitTestFactory());
                this.remoteEventBroker.AddDistributedExtension(new FakeDistributedEventBrokerExtension(new FakeEventBrokerBus(localHandler)));

                this.remoteSubscriberAndPublisher = new RemoteSubscriberAndPublisher();
                this.remoteEventBroker.Register(this.remoteSubscriberAndPublisher);

                return this.decorator;
            }
        public void DoesNotIntroduceGhostMethodsThroughRegistrationAndHandlingEvents()
        {
            this.testee = new EventBroker();

            ITestPublisher testPublisher = new MyPublisher();
            ITestSubscriber testSubscriber = new MySubscriber();

            int initialMethodCount = testSubscriber.GetType().GetMethods().GetLength(0);

            this.testee.Register(testPublisher);

            int methodCountAfterRegisteringPublisher = testSubscriber.GetType().GetMethods().GetLength(0);

            this.testee.Register(testSubscriber);

            int methodCountAfterRegisteringSubscriber = testSubscriber.GetType().GetMethods().GetLength(0);

            testPublisher.FireEvent();

            int methodCountAfterFiringEvent = testSubscriber.GetType().GetMethods().GetLength(0);

            methodCountAfterRegisteringPublisher.Should().Be(initialMethodCount, "registration of publisher should not introduce ghost methods");
            methodCountAfterRegisteringSubscriber.Should().Be(initialMethodCount, "registration of subscriber should not introduce ghost methods");
            methodCountAfterFiringEvent.Should().Be(initialMethodCount, "calling handler method should not introduce ghost methods");

            testSubscriber.MyValue.Should().Be(6);
        }
Example #3
0
        static void Main()
        {
            EventBroker = new EventBroker();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
  public AccountsOverviewViewModel(
     EventBroker eventBroker,
     AccountManager accountManager)
 {
      this.eventBroker = eventBroker;
      this.eventBroker.Register(this);
      this.accountManager = accountManager;
      this.AddAccountCommand = new RelayCommand(this.SwitchToAddAccoutView);
 }
        public PopUpViewModel(
            AccountsOverviewViewModel accountsOverviewViewModel,
            AddAccountDialogViewModel addAccountDialogViewModel,
            EventBroker eventBroker)
        {
            eventBroker.Register(this);
            this.accountsOverviewViewModel = accountsOverviewViewModel;
            this.addAccountDialogViewModel = addAccountDialogViewModel;

            this.SetViewContent(this.accountsOverviewViewModel);
        }
 public AddAccountDialogViewModel(
     AccountManager accountManager, 
     EventBroker eventBroker)
 {
     this.accountManager = accountManager;
     this.eventBroker = eventBroker;
     this.BrowseCommand = new RelayCommand(this.Browse, () => true);
     this.AddAccountCommand = new RelayCommand(
         this.AddAccount, 
         () => this.Username != string.Empty 
            && this.RootFolderPath != string.Empty);
 }
Example #7
0
        public void TestMethod1()
        {
            var eventBroker = new EventBroker();

            var publisher = new Publisher();
            eventBroker.Register(publisher);

            var subscriber = new Subscriber();
            eventBroker.Register(subscriber);

            publisher.FireSimpleEvent();
        }
Example #8
0
        private void SimpleEvent(int runNumber)
        {
            EventBroker eventBroker = new EventBroker();
            
            var p = new Publisher();
            var s = new Subscriber();

            eventBroker.Register(p);
            eventBroker.Register(s);

            this.Run(
                p.FireEvent,
                runNumber + " simple event",
                0);
        }
 public WebDriveManagerTaskBarIcon(
     TaskbarIcon taskbarIcon,
     AccountsOverviewViewModel accountsOverviewViewModel,
     AddAccountDialogViewModel addAccountDialogViewModel, 
     EventBroker eventBroker)
 {
     this.taskbarIcon = taskbarIcon;
     this.accountsOverviewViewModel = accountsOverviewViewModel;
     this.addAccountDialogViewModel = addAccountDialogViewModel;
     this.eventBroker = eventBroker;
     this.taskbarIcon.TrayMiddleMouseDown += (sender, args) => Application.Current.Shutdown();
     this.taskbarIcon.TrayPopupOpen += (sender, args) => this.taskbarIcon.TrayPopup.SetValue(UIElement.VisibilityProperty, Visibility.Visible);
     this.taskbarIcon.TrayPopup = this.CreatePopup();
     ////this.taskbarIcon.TrayToolTip = this.CreateToolTip(gameClient);
     this.taskbarIcon.ToolTip = "WebDriveManager";
     this.taskbarIcon.Icon = Resources.webdrivemanager;
 }
Example #10
0
        private void TrueMatcher(int runNumber)
        {
            EventBroker eventBroker = new EventBroker();

            eventBroker.AddGlobalMatcher(new Matcher(true));

            var p = new Publisher();
            var s = new Subscriber();

            eventBroker.Register(p);
            eventBroker.Register(s);

            this.Run(
                p.FireEvent,
                runNumber + " true matcher",
                0);
        }
Example #11
0
        private void Subscribers(int runNumber, int numberOfSubscribersInThisRun)
        {
            EventBroker eventBroker = new EventBroker();

            var p = new Publisher();
            var subscribers = new Subscriber[numberOfSubscribersInThisRun];

            for (int i = 0; i < numberOfSubscribersInThisRun; i++)
            {
                subscribers[i] = new Subscriber();
                eventBroker.Register(subscribers[i]);
            }

            eventBroker.Register(p);
           
            this.Run(
                p.FireEvent,
                runNumber + " number of subscribers " + numberOfSubscribersInThisRun,
                -9 * this.numberOfEvents / 10);
        }
Example #12
0
        protected MediaPlayer()
        {
            EventBroker = new EventBroker();

            _state = PlayState.Unknown;
        }