public void Dictionry_Should_Be_Current_Objet_Dictionary(){
            var editor = new ModelEditorPropertyEditor(null, null);
            Isolate.WhenCalled(() => editor.CurrentObject).ReturnRecursiveFake();
            Isolate.WhenCalled(() => editor.CurrentObject.GetCombinedModel()).WillReturn(DefaultDictionary);

            ModelEditorController controller = editor.GetModelEditorController(Isolate.Fake.Instance<XafApplication>());

            Assert.AreEqual(DefaultDictionary, controller.Dictionary);
        }
        public void CurrentAspect_Should_Be_CurrentObjectLanguage()
        {
            var editor = new ModelEditorPropertyEditor(null, null);
            Isolate.WhenCalled(() => editor.CurrentObject.GetCombinedModel()).WillReturn(DefaultDictionary);
            Isolate.WhenCalled(() => editor.CurrentObject.CurrentLanguage).WillReturn("el");

            ModelEditorController controller = editor.GetModelEditorController(Isolate.Fake.Instance<XafApplication>());

            Assert.AreEqual("el", controller.CurrentAspect);
        }
        public void ModelEditorPropertyEditor_Control_Will_Be_A_ModelEditorControl(){
            var editor = new ModelEditorPropertyEditor(null, null);
//            Isolate.WhenCalled(() => editor.GetModel()).ReturnRecursiveFake();
            Isolate.WhenCalled(() => editor.GetModelEditorController(Isolate.Fake.Instance<XafApplication>())).ReturnRecursiveFake();
            editor.Setup(Isolate.Fake.Instance<ObjectSpace>(), Isolate.Fake.Instance<XafApplication>());
            Isolate.Swap.NextInstance<ModelEditorControl>().With(Isolate.Fake.Instance<ModelEditorControl>());

            editor.CreateControl();

            Assert.IsInstanceOfType(typeof(ModelEditorControl), editor.Control);
        }
Example #4
0
        public void ModelEditorControl_Controller_Should_Be_Set_Every_Time_Editor_ReadsValue()
        {
            var mock = MockManager.Mock(typeof(ModelEditorPropertyEditor));
            mock.CallBase.ExpectCall("ReadValueCore");
            var editor = new ModelEditorPropertyEditor(null, null);
            Isolate.WhenCalled(() => editor.Control).WillReturn(new ModelEditorControl());
            Isolate.NonPublic.WhenCalled(editor, "CanReadValue").WillReturn(true);
            var controller = Isolate.Fake.Instance<ModelEditorController>();
            Isolate.WhenCalled(() => editor.GetModelEditorController(null)).WillReturn(controller);

            editor.ReadValue();

            Assert.AreEqual(controller, editor.Control.Controller);


        }
        public void When_Current_Node_Attribute_Changed_It_Should_Modify_Object()
        {
            var editor = new ModelEditorPropertyEditor(null, null);
            Isolate.WhenCalled(() => editor.CurrentObject).ReturnRecursiveFake();
            Isolate.WhenCalled(() => editor.CurrentObject.GetCombinedModel()).WillReturn(DefaultDictionary);
            bool modified = false;
            Isolate.WhenCalled(() => editor.ModifyCurrentObjectModel()).DoInstead(context => modified = true);
            var editorController = Isolate.Fake.InstanceAndSwapAll<ModelEditorController>();
            using (RecorderManager.StartRecording()){
                editorController.CurrentAttributeValueChanged += null;
            }
            editor.GetModelEditorController(Isolate.Fake.Instance<XafApplication>());
            var handler = (EventHandler) RecorderManager.LastMockedEvent.GetEventHandle();

            handler.Invoke(this,EventArgs.Empty);

            Assert.IsTrue(modified);

        }
        public void When_Model_Dictionary_Is_Modified_Current_Object_Model_Should_Be_Set_To_Dictionary_Diffs()
        {
            var mock = MockManager.Mock(typeof(ModelEditorPropertyEditor),Constructor.NotMocked);
            mock.CallBase.ExpectCall("ReadValueCore");
            var editor = new ModelEditorPropertyEditor(null, null){CurrentObject = Isolate.Fake.Instance<ModelDifferenceObject>()};
            Isolate.WhenCalled(() => editor.Control).WillReturn(new ModelEditorControl());
            Isolate.NonPublic.WhenCalled(editor, "CanReadValue").WillReturn(true);
            var controller = Isolate.Fake.Instance<ModelEditorController>();
            Isolate.WhenCalled(() => controller.Dictionary.GetDiffs()).WillReturn(DefaultDictionary);
            Isolate.WhenCalled(() => editor.GetModelEditorController(null)).WillReturn(controller);
            using (RecorderManager.StartRecording()){
                controller.ModifiedChanged += null;
            }
            editor.ReadValue();
            var eventHandle = (EventHandler) RecorderManager.LastMockedEvent.GetEventHandle();

            eventHandle.Invoke(this,EventArgs.Empty);

            Assert.AreEqual(controller.Dictionary.GetDiffs().RootNode.ToXml(), editor.CurrentObject.Model.RootNode.ToXml());
        }