public void Can_Be_Deleted(){
            var modelDifferenceObject = new ModelDifferenceObject(Session.DefaultSession){PersistentApplication = new PersistentApplication(Session.DefaultSession)};
            modelDifferenceObject.Save();

            modelDifferenceObject.Delete();

            Assert.IsTrue(modelDifferenceObject.IsDeleted);
        }
        public void Create_A_New_DifferenceObject_If_No_Active_DifferenceObject_Found()
        {
            var modelAspectObject = new ModelDifferenceObject(Session.DefaultSession);
            Isolate.Swap.AllInstances<ModelDifferenceObject>().With(modelAspectObject);
            Isolate.WhenCalled(() => modelAspectObject.Save()).IgnoreCall();
            var application = Isolate.Fake.Instance<XafApplication>();
            application.ApplicationName = "ApplicationName";
            var dictionary = new Dictionary(Schema.GetCommonSchema());
            Isolate.WhenCalled(() => dictionary.Aspects).WillReturn(new List<string> { "aspect" });
            Isolate.WhenCalled(() => application.Model).WillReturn(dictionary);
            var store = Isolate.Fake.Instance<XpoDictionaryDifferenceStore>(Members.CallOriginal, ConstructorWillBe.Called, new object[] { Session.DefaultSession, application });
            Isolate.WhenCalled(() => store.GetNewDifferenceObject(null)).WillReturn(modelAspectObject);
            Isolate.WhenCalled(() => store.GetActiveDifferenceObject()).WillReturn(null);


            store.SaveDifference(dictionary);

            Isolate.Verify.WasCalledWithAnyArguments(() => modelAspectObject.Save());
        }
Exemple #3
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
//            return;
            string modelId = typeof(MasterDetailStore).Name;
            if (new QueryModelDifferenceObject(Session).GetActiveModelDifference(modelId) == null)
            {
                ModelDifferenceObject modelDifferenceObject =
                    new ModelDifferenceObject(Session).InitializeMembers(modelId);
                modelDifferenceObject.Name = modelId;
                modelDifferenceObject.Save();
            }
        }
        public void Same_Application_Objets_Cannot_Exist(DifferenceType differenceType, ValidationState validationState)
        {
            var ruleSet = new RuleSet();
            var persistentApplication = new PersistentApplication(Session.DefaultSession);
            var modelDifferenceObject = new ModelDifferenceObject(Session.DefaultSession) { PersistentApplication = persistentApplication };
            modelDifferenceObject.Save();

            var modelDifferenceObject1 = new ModelDifferenceObject(Session.DefaultSession) { PersistentApplication = persistentApplication };
            Isolate.WhenCalled(() => modelDifferenceObject1.DifferenceType).WillReturn(differenceType);

            RuleSetValidationResult target = ruleSet.ValidateTarget(modelDifferenceObject1, ContextIdentifier.Save);


            Assert.IsInstanceOfType(typeof(RuleCombinationOfPropertiesIsUnique), target.Results[0].Rule);
            Assert.AreEqual(validationState, target.Results[0].State);


        }
        public void Model_Is_Persistent()
        {
            var dictionary = DefaultDictionary;
            dictionary.AddAspect("el",elDictionary.RootNode);
            var modelDifferenceObject = new ModelDifferenceObject(Session.DefaultSession) { Model = dictionary,PersistentApplication = new PersistentApplication(Session.DefaultSession)};
            modelDifferenceObject.Save();

            var o = (ModelDifferenceObject)new Session(XpoDefault.DataLayer).GetObject(modelDifferenceObject);

            Assert.AreEqual(dictionary.RootNode.ToXml(), o.Model.RootNode.ToXml());
        }