Example #1
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_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());
        }