Пример #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 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 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);

        }
Пример #5
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 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());
        }