示例#1
0
        public void Application_Instance_Should_Be_Known(){
            var editor = new ModelEditorPropertyEditor(null, null);
            var application = Isolate.Fake.Instance<XafApplication>();

            editor.Setup(Isolate.Fake.Instance<ObjectSpace>(),application);

            Assert.AreEqual(editor.Application, application);
        }
        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 ModelEditorControl_Will_Save_Save_Settings_At_A_Node(){
            var editor = new ModelEditorPropertyEditor(null, null);
            editor.Setup(Isolate.Fake.Instance<ObjectSpace>(),Isolate.Fake.Instance<XafApplication>());

            throw new NotImplementedException();
//            ModelEditorControl control = editor.GetModelEditorControl(new Dictionary());

//            Assert.IsNotNull(control.SettingsStorage);
//            Assert.IsInstanceOfType(typeof(SettingsStorageOnDictionary),control.SettingsStorage);

        }
        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);
        }
        public void CurrentObjectModel_Should_Be_Equal_CurrentObject_PersistentApp_Not_Modified_Cloned_Combined_With_Controller_Diffs(){

            string s = "<Application><BOModel><Class Name=\"MyClass2\" Caption=\"el\"></Class></BOModel></Application>";
            var modelEditorPropertyEditor = new ModelEditorPropertyEditor(null, null);
            Isolate.WhenCalled(() => modelEditorPropertyEditor.Control.Controller.IsModified).WillReturn(true);
            var modelDifferenceObject = new ModelDifferenceObject(Session.DefaultSession);
            Isolate.WhenCalled(() => modelEditorPropertyEditor.CurrentObject).WillReturn(modelDifferenceObject);
            Isolate.WhenCalled(() => modelDifferenceObject.PersistentApplication.Model.Clone()).WillReturn(DefaultDictionary2);
            Isolate.WhenCalled(() => modelEditorPropertyEditor.Control.Controller.Dictionary.GetDiffs()).WillReturn(new Dictionary(new DictionaryXmlReader().ReadFromString(s),Schema.GetCommonSchema()));

            modelEditorPropertyEditor.ModifyCurrentObjectModel();
            
            Assert.AreEqual("el", new ApplicationNodeWrapper(modelDifferenceObject.Model).BOModel.FindClassByName("MyClass2").Caption);
        }
        public void CurrentObject_Model_Should_Be_Validated_Every_Time_CurrentObject_Is_Saving(){
            var editor = new ModelEditorPropertyEditor(null, null);
            bool validated = false;
            Isolate.WhenCalled(() => editor.Control.Controller.Dictionary.GetDiffs()).ReturnRecursiveFake();
            Isolate.WhenCalled(() => editor.Control.Controller.Dictionary.Validate()).DoInstead(context => validated=true);
            var objectSpace = new ObjectSpace(new UnitOfWork(XpoDefault.DataLayer),XafTypesInfo.Instance);
            var modelDifferenceObject = new ModelDifferenceObject(objectSpace.Session) { PersistentApplication = new PersistentApplication(objectSpace.Session) };
            editor.CurrentObject = modelDifferenceObject;
            editor.Setup(objectSpace, Isolate.Fake.Instance<XafApplication>());

            objectSpace.CommitChanges();

            Assert.IsTrue(validated);

        }
示例#8
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);

        }
示例#10
0
        public void Before_Application_Saving_Current_Object_Should_Validate_ModelEditorControl_Dictionary()
        {
            
            bool validated = false;
            var editor = new ModelEditorPropertyEditor(null, null);
            var modelDifferenceObject = new ModelDifferenceObject(Session.DefaultSession);
            Isolate.WhenCalled(() => editor.CurrentObject).WillReturn(modelDifferenceObject);
            Isolate.WhenCalled(() => editor.Control.Controller.Dictionary.Validate()).DoInstead(context => validated=true);
            var objectSpace = Isolate.Fake.Instance<ObjectSpace>();
            using (RecorderManager.StartRecording()){
                objectSpace.ObjectSaving += null;
            }
            editor.Setup(objectSpace, null);
            var handler = (EventHandler<ObjectManipulatingEventArgs>) RecorderManager.LastMockedEvent.GetEventHandle();

            handler.Invoke(this,new ObjectManipulatingEventArgs(modelDifferenceObject));

            Assert.IsTrue(validated);
        }
        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());
        }
        public void CurrentObject_Model_Should_Be_Set_To_Control_Controller_Dictionary_Every_Time_CurrentObject_Is_Saving(){
            var editor = new ModelEditorPropertyEditor(null, null);
            var dictionary = new Dictionary(new DictionaryNode("test"));
            Isolate.WhenCalled(() => editor.Control.Controller.Dictionary).WillReturn(dictionary);
            var objectSpace = new ObjectSpace(new UnitOfWork(XpoDefault.DataLayer),XafTypesInfo.Instance);
            var modelDifferenceObject = new ModelDifferenceObject(objectSpace.Session) { PersistentApplication = new PersistentApplication(objectSpace.Session) };
            editor.CurrentObject=modelDifferenceObject;
            editor.Setup(objectSpace, Isolate.Fake.Instance<XafApplication>());
            
            objectSpace.CommitChanges();

            Assert.AreEqual(dictionary.RootNode.ToXml(), modelDifferenceObject.Model.RootNode.ToXml());
        }
        public void ModelEditorControlController_Should_Have_Editor_Model_And_CurrentObject_CurrentLanguage(){
            var editor = new ModelEditorPropertyEditor(null, null){
                                                                      CurrentObject =new ModelDifferenceObject(Session.DefaultSession)
                                                                          {PersistentApplication = new PersistentApplication(Session.DefaultSession),PreferredAspect = "el"}
                                                                  };
            Isolate.WhenCalled(() => editor.Control).WillReturn(new ModelEditorControl());
            var dictionary = new Dictionary();
            throw new NotImplementedException();
//            Isolate.WhenCalled(() => editor.GetModel()).WillReturn(dictionary);

//            var controller = editor.GetModelEditorController(Isolate.Fake.Instance<XafApplication>());
//
//            Assert.AreEqual("el", controller.CurrentAspect);
//            Assert.AreEqual(dictionary, controller.Dictionary);
        }
        public void Model_Should_be_Created_By_Combining_Persistent_ApplicationModel_DefaultLanguage_And_PrefferedLanguage_With_CurrentObject_DefaultLang_And_PrefferedLanguage(){
            var persistentAppDictionary = DefaultDictionary.Clone();
            persistentAppDictionary.AddAspect("el",elDictionary.Clone().RootNode);
            const string s = "<Application><BOModel><Class Name=\"MyClass\" Caption=\"el2\"></Class></BOModel></Application>";
            var diffObjectDictionary = new Dictionary(new DictionaryXmlReader().ReadFromString(s), Schema.GetCommonSchema());
            diffObjectDictionary.AddAspect("el", new DictionaryXmlReader().ReadFromString("<Application><BOModel><Class Name=\"MyClass\" Caption=\"el3\"></Class></BOModel></Application>"));
            var editor = new ModelEditorPropertyEditor(null, null)
                         {
                             CurrentObject =new ModelDifferenceObject(
                                 Session.DefaultSession)
                                            {
                                                Model = diffObjectDictionary,
                                                PersistentApplication = new PersistentApplication(Session.DefaultSession) { Model = persistentAppDictionary },
                                                PreferredAspect = "el"
                                            }
                         };

//            var dictionary = editor.GetModel();

//            dictionary.CurrentAspectProvider.CurrentAspect = "el";
//            Assert.AreEqual("el3", new ApplicationNodeWrapper(dictionary).BOModel.FindClassByName("MyClass").Caption);
            throw new NotImplementedException();
            
        }