public CmdApplicationConfigurationListViewModel(
     IReader <CmdApplicationMeta, IEnumerable <CmdApplicationConfiguration> > reader,
     ICmdApplicationConfigurationViewModelFactory factory,
     IChannel <DeleteCmdApplicationConfigurationCommand> deleteChannel,
     IMessenger messenger)
 {
     this.Reader                 = reader;
     this.Factory                = factory;
     this.Messenger              = messenger;
     this.DeleteChannel          = deleteChannel;
     this.CurrentApplicationMeta = SsmsCmdApplication.Application;
     ApplicationConfigurations   = reader
                                   .Query(this.CurrentApplicationMeta)
                                   .Select(a =>
     {
         var vm = factory.Create(this.CurrentApplicationMeta);
         vm.PopulateFromCmdApplicationConfiguration(a);
         return(vm);
     })
                                   .ToObservableCollection();
     DomainEvents.Subscribe(this);
     this.SelectedConfiguration = ApplicationConfigurations.FirstOrDefault();
     this.Messenger.Register <AddCmdApplicationConfigurationEvent>(this, this.OnAddCmdApplicationConfigurationEvent);
     this.Messenger.Register <DeleteCmdApplicationConfigurationEvent>(this, this.OnDeleteCmdApplicationConfigurationEvent);
 }
        public void TestSubscribe()
        {
            //Define a message class to send
            var msg = new Msg {
                Content = MagicString
            };

            //subscribe you handlers
            DomainEvents <Msg> .Subscribe(Handler);

            //maby ways to send
            DomainEvents <Msg> .Publish(msg);

            DomainEvents.Publish(msg);
            DomainEvents.Publish(msg, typeof(Msg));

            Assert.AreEqual(counter, 3);

            //unsubcribe when done as we are not using weakreferences internally
            DomainEvents <Msg> .Unsubscribe(Handler);

            DomainEvents.Publish(msg);

            Assert.AreEqual(counter, 3);
        }
Esempio n. 3
0
        public static void PreInitialize()
        {
            var webStack = new AspNetWebStack();

            WebBootstrapper.PreInitializeWebStack(webStack);

            CmsConfiguration.Current.AddMvcSupport();
            CmsConfiguration.Current.AddWebFormsSupport();
            CmsConfiguration.Current.AddStaticContentSupport();

            ToolboxPropertyFilter.BlacklistedDeclaringAssemblies.AddRange(new[]
            {
                typeof(Control).Assembly,
                typeof(Controller).Assembly,
                typeof(WarpCoreEntity).Assembly
            });



            Dependency.Register <ICosmosOrm>(typeof(InMemoryDb));

            DomainEvents.Subscribe <SiteBootCompleted>(_ =>
            {
                var demoInstaller = new DemoInstaller();
                demoInstaller.SetupDynamicTypes();
                demoInstaller.SetupCustomFields();
                demoInstaller.SetupToolbox();
                demoInstaller.SetupBackendSite();


                PublishingShortcuts.PublishSites();
                demoInstaller.SetupTestSite();
            });
        }
Esempio n. 4
0
 public void PublishAnotherEventDoesNotInvokeHandlersOfOtherEvents(
     Mock <IEventHandler <TestEvent> > testHandler,
     TestAnotherEvent anotherEventData)
 {
     DomainEvents.Subscribe(testHandler.Object);
     DomainEvents.Publish(anotherEventData);
     testHandler.Verify(a => a.Handle(It.IsAny <TestEvent>()), Times.Never());
 }
Esempio n. 5
0
 public void PublishRaisesEventsToSubscriber(
     Mock <IEventHandler <TestEvent> > testHandler,
     TestEvent eventData)
 {
     DomainEvents.Subscribe(testHandler.Object);
     DomainEvents.Publish(eventData);
     testHandler.Verify(a => a.Handle(eventData), Times.Once());
 }
Esempio n. 6
0
 public void SubscribersRegisteredAfterClearingAllSubscriptionsGetsNotifiedOfEvents(
     Mock <IEventHandler <TestEvent> > testHandler,
     TestEvent eventData)
 {
     DomainEvents.ClearAllSubscriptions();
     DomainEvents.Subscribe(testHandler.Object);
     DomainEvents.Publish(eventData);
     testHandler.Verify(a => a.Handle(eventData), Times.Once());
 }
Esempio n. 7
0
 public void ClearAllSubscriptionsDoesNotRaiseEventsToPreviouslySubscribedClients(
     Mock <IEventHandler <TestEvent> > testHandler,
     TestEvent eventData)
 {
     DomainEvents.Subscribe(testHandler.Object);
     DomainEvents.ClearAllSubscriptions();
     DomainEvents.Publish(eventData);
     testHandler.Verify(a => a.Handle(eventData), Times.Never());
 }
Esempio n. 8
0
 public void ExecuteDeleteCmdApplicationConfigurationCommandWithNullThrowsException(
     CmdApplicationConfigurationService sut,
     TestDomainEventHandler <ConfigurationDeletedEvent> deleteHandler,
     DeleteCmdApplicationConfigurationCommand command)
 {
     DomainEvents.Subscribe(deleteHandler);
     sut.Execute(command);
     Assert.True(deleteHandler.EventHandlerInvoked);
 }
Esempio n. 9
0
 public static void Configure()
 {
     //account
     DomainEvents.Subscribe(new FrozeAccountEventHandler());
     DomainEvents.Subscribe(new GrantApplyNumberEventHandler());
     DomainEvents.Subscribe(new LossAccountEventHandler());
     DomainEvents.Subscribe(new RecoverAccountEventHandler());
     DomainEvents.Subscribe(new ResetPasswordEventHandler());
     DomainEvents.Subscribe(new SubmitVerifyEventHandler());
     DomainEvents.Subscribe(new VerifyByUserEventHandler());
 }
Esempio n. 10
0
 public void ExecuteSaveCmdApplicationConfigurationWithExistingNameRaisesRejectedEvent(
     [Frozen] Mock <ICmdApplicationConfigurationRepository> repository,
     SaveCmdApplicationConfigurationCommand command,
     TestDomainEventHandler <CmdApplicationConfigurationSaveRejected> testHandler,
     CmdApplicationConfigurationService sut)
 {
     repository
     .Setup(a => a.CheckIfConfigurationWithSameNameExists(command.ApplicationConfiguration))
     .Returns(true);
     DomainEvents.Subscribe(testHandler);
     sut.Execute(command);
     Assert.True(testHandler.EventHandlerInvoked);
 }
Esempio n. 11
0
        public void PublishRaisesEventsToAllSubscribers(
            IEnumerable <Mock <IEventHandler <TestEvent> > > testHandlers,
            TestEvent eventData)
        {
            foreach (var testHandler in testHandlers)
            {
                DomainEvents.Subscribe(testHandler.Object);
            }

            DomainEvents.Publish(eventData);

            foreach (var testHandler in testHandlers)
            {
                testHandler.Verify(a => a.Handle(eventData), Times.Once());
            }
        }
Esempio n. 12
0
        public CmdApplicationConfigurationViewModel(
            CmdApplicationMeta applicationMeta,
            List <ParameterViewModel> properties,
            IChannel <SaveCmdApplicationConfigurationCommand> channel,
            IEnumerable <CmdApplicationConfigurationParser <string> > stringParsers)
        {
            if (applicationMeta == null)
            {
                throw new ArgumentNullException(nameof(applicationMeta));
            }

            if (properties == null)
            {
                throw new ArgumentNullException(nameof(properties));
            }

            if (channel == null)
            {
                throw new ArgumentNullException(nameof(channel));
            }


            if (stringParsers == null)
            {
                throw new ArgumentNullException(nameof(stringParsers));
            }

            this.ApplicationMeta = applicationMeta;
            this.ApplicationName = applicationMeta.ApplicationName;
            this.Properties      = properties;
            this.Channel         = channel;
            this.StringParsers   = stringParsers;
            this.Save            = new RelayCommand(this.OnSaveExecuted, () => this.IsInEditMode);
            this.ToggleEdit      = new RelayCommand(this.OnToggleEditExecuted);
            this.Launch          = new RelayCommand(this.OnLaunchExecuted);
            DomainEvents.Subscribe <ConfigurationSavedEvent>(this);
            DomainEvents.Subscribe <CmdApplicationConfigurationSaveRejected>(this);
        }
Esempio n. 13
0
 public void SubscribeWithNullThrowsException()
 {
     Assert.Throws <ArgumentNullException>(() => DomainEvents.Subscribe <IEvent>(null));
 }
 public static void BuildUpDomainEvents()
 {
     DomainEvents.Subscribe <SiteStructureChanged>(x => CmsRoutes.RegenerateAllRoutes());
 }