コード例 #1
0
        public void Handle_Inactivate_Test()
        {
            #region === ARRANGE ===

            int businessConsultNumber = 0;
            int businessChangeNumber  = 0;

            int    id       = 555;
            string username = "******";
            string hash     = "223cb19e27ef605dcef5f03d977bf3c6cdc5161d489800117bddebdc2b0d08661ff5add09c812a3fdb9f5d98c737480994646f28cd63739fe565455c79b7e6ca";

            Mock <IMediatorsFactory> mockedBusinessEventsFactory = new Mock <IMediatorsFactory>();
            Mock <IInfrastructureOperationsFactory> mockedInfrastructureOperationsFactory = new Mock <IInfrastructureOperationsFactory>();
            BusinessDataMediator businessDataMediator = new BusinessDataMediator();
            User user = new User(id, username, hash, true, businessDataMediator);

            businessDataMediator.AppendBusinessConsultNeedHandler((sender, args) => {
                args.result = new List <User>()
                {
                    user
                };
                businessConsultNumber++;
            });

            businessDataMediator.AppendBusinessChangeNeedHandler((sender, handler) => { businessChangeNumber++; });

            mockedBusinessEventsFactory.Setup(x => x.CreateBusinessDataMediator(It.IsAny <EventHandler <BusinessConsultEventArgs> >(), It.IsAny <EventHandler <BusinessChangeEventArgs> >())).Returns(businessDataMediator);

            InactivateUser command = new InactivateUser {
                Id = new Guid(), userId = id
            };
            UsersComandHandler comandHandler = new UsersComandHandler(mockedBusinessEventsFactory.Object, mockedInfrastructureOperationsFactory.Object);

            #endregion

            #region === ACT ===

            comandHandler.Handle(command);


            #endregion

            #region === ASSERT ===

            Assert.AreEqual <int>(1, businessConsultNumber);
            Assert.AreEqual <int>(1, businessChangeNumber);
            Assert.AreEqual <bool>(false, user.active);

            #endregion
        }
コード例 #2
0
        public void Inactivate(InactivateUser command)
        {
            ICommandHandler <InactivateUser> commandHandler = commandHandlerFactory.CreateCommandHandler <InactivateUser>();

            commandHandler.Handle(command);
        }