Пример #1
0
        public void If_User_Has_Permnission_To_Combine_With_Application_Model_Combination_Should_Occur()
        {
            ModelCombinePermission permission = null;
            Isolate.WhenCalled(() => SecuritySystem.IsGranted(null)).DoInstead(context =>
            {
                permission = context.Parameters[0] as ModelCombinePermission;
                return true;
            });
            var modelAspectObject = new ModelDifferenceObject(Session.DefaultSession){Model =DefaultDictionary,PersistentApplication = new PersistentApplication(Session.DefaultSession)};
            var queryModelAspectObject = Isolate.Fake.InstanceAndSwapAll<QueryModelDifferenceObject>();
            Isolate.WhenCalled(() => queryModelAspectObject.GetActiveModelDifference(  "")).WillReturn(modelAspectObject);
            var store = new XpoUserModelDictionaryDifferenceStore( Isolate.Fake.Instance<XafApplication>());
            var aspectObject = new UserModelDifferenceObject(Session.DefaultSession){
                                                                                        PersistentApplication = new PersistentApplication(Session.DefaultSession),
                                                                                        NonPersistent = true,
                                                                                        Model = DefaultDictionary2
                                                                                    };
            
            store.OnDifferenceObjectSaving(aspectObject, new Dictionary());


            Assert.IsNotNull(permission);
            Assert.AreEqual(ApplicationModelCombineModifier.Allow, permission.Modifier);
            Assert.IsFalse(modelAspectObject.IsNewObject);
            Assert.IsNotNull(new ApplicationNodeWrapper(modelAspectObject.Model).BOModel.FindClassByName("MyClass2"));
        }
Пример #2
0
        public void When_Saving_It_Should_Combined_With_Application_Diffs(){
            Isolate.WhenCalled(() => Validator.RuleSet.ValidateAll(null, null)).ReturnRecursiveFake();
            var modelDictionaryDifferenceStore = new XpoUserModelDictionaryDifferenceStore( Isolate.Fake.Instance<XafApplication>());
            var modelDifferenceObject = new UserModelDifferenceObject(Session.DefaultSession){PersistentApplication = new PersistentApplication(Session.DefaultSession),Model = DefaultDictionary};

            modelDictionaryDifferenceStore.OnDifferenceObjectSaving(modelDifferenceObject, elDictionary);

            Assert.AreEqual("el", new ApplicationNodeWrapper(modelDifferenceObject.Model).BOModel.FindClassByName("MyClass").Caption);
        }
Пример #3
0
        public void CauseOf_Application_Is_Unique_It_Should_Check_DataStore_Before_Creating_New()
        {

            var modelDictionaryDifferenceStore = new XpoUserModelDictionaryDifferenceStore(Isolate.Fake.Instance<XafApplication>());
            new PersistentApplication(Session.DefaultSession) { Name = "appName" }.Save();
            var application = Isolate.Fake.InstanceAndSwapAll<QueryPersistentApplication>();
            var persistentApplication = new PersistentApplication(Session.DefaultSession);
            Isolate.WhenCalled(() => application.Find("")).WillReturn(persistentApplication);
            Isolate.WhenCalled(() => modelDictionaryDifferenceStore.OnDifferenceObjectSaving(null, new Dictionary())).IgnoreCall();
            Isolate.WhenCalled(() => modelDictionaryDifferenceStore.GetActiveDifferenceObject()).WillReturn(null);
            Isolate.WhenCalled(() => modelDictionaryDifferenceStore.GetNewDifferenceObject(null)).WillReturn(new ModelDifferenceObject(Session.DefaultSession));

            modelDictionaryDifferenceStore.SaveDifference(new Dictionary(Schema.GetCommonSchema()));

            Isolate.Verify.WasCalledWithAnyArguments(() => application.Find(""));
        }