public void When_UserDifferenceObject_Is_Shown()
            {
                var factory = new ViewControllerFactory();
                var activateController = factory.CreateController<CombineActiveUserDifferenceWithUserModelController>(
                    typeof(UserModelDifferenceObject));
                bool combined = false;
                Isolate.WhenCalled(() => activateController.CombineWithApplicationUserDiffs()).DoInstead(context => combined = true);

                factory.Activate(activateController);

                Assert.IsTrue(combined);

            }
            public void When_Current_UserDifferenceObject_Changed()
            {
                var factory = new ViewControllerFactory();
                var controller = factory.CreateController<CombineActiveUserDifferenceWithUserModelController>(typeof(UserModelDifferenceObject));
                bool combined = false;
                Isolate.WhenCalled(() => controller.CombineWithApplicationUserDiffs()).DoInstead(context => combined = true);
                factory.Activate(controller, new HandleInfo { CurrentObjectChanged = true });

                factory.CurrentObjectChangedHandler.Invoke(this, EventArgs.Empty);

                Assert.IsTrue(combined);

            }
Esempio n. 3
0
        public void When_Object_Is_Decorated_With_HideFromNewMenu_Attribute_Should_Not_Appear_To_Menu(){
            XafTypesInfo.Instance.RegisterEntity(typeof(Person));
            XafTypesInfo.Instance.FindTypeInfo(typeof (Person)).AddAttribute(new HideFromNewMenuAttribute());
            var controller = new NewObjectViewController();
            controller.NewObjectAction.Items.Add(new ChoiceActionItem("", typeof (Person)));
            var viewControllerFactory = new ViewControllerFactory();
            var hideFromNewMenuViewController = viewControllerFactory.CreateController<HideFromNewMenuViewController>(ViewType.Any, new Person(Session.DefaultSession));
            var frame = Isolate.Fake.Instance<Frame>(Members.CallOriginal);
            frame.RegisterController(controller);
            Isolate.WhenCalled(() => hideFromNewMenuViewController.Frame).WillReturn(frame);
            viewControllerFactory.Activate(hideFromNewMenuViewController, new HandleInfo{ControlsCreated = true});

            viewControllerFactory.ControlsCreatedHandler.Invoke(this,EventArgs.Empty);

            Assert.AreEqual(0, controller.NewObjectAction.Items.Count);

        }