public void When_A_New_UserDifferenceObject_Is_Saved_it_Should_Contain_Same_NUmber_Of_Aspect_As_The_Application(){
            var application = Isolate.Fake.Instance<XafApplication>();
            Isolate.WhenCalled(() => application.Model.Aspects).WillReturn(new List<string>{DictionaryAttribute.DefaultLanguage,"el"});
            var store = new XpoUserModelDictionaryDifferenceStore( application);
            Isolate.WhenCalled(() => store.GetActiveDifferenceObjects()).WillReturn(new List<ModelDifferenceObject>().AsQueryable());
            Dictionary dictionary = null;
            Isolate.WhenCalled(() => store.SaveDifference(null)).DoInstead(context => dictionary=(Dictionary) context.Parameters[0]);

            store.LoadDifference(Schema.GetCommonSchema());

            Assert.AreEqual(2, dictionary.Aspects.Count);

        }
        public void If_No_ActiveDifference_Found_Then_A_New_UserDifferenceObject_Should_Be_Saved()
        {
            var application = Isolate.Fake.Instance<XafApplication>();
            application.ApplicationName = "appName";
            var store = new XpoUserModelDictionaryDifferenceStore(application);
            Isolate.WhenCalled(() => store.GetActiveDifferenceObjects()).WillReturn(new List<ModelDifferenceObject>().AsQueryable());
            Isolate.WhenCalled(() => store.GetActiveDifferenceObjects()).CallOriginal();
            bool saved = false;
            Isolate.WhenCalled(() => store.SaveDifference(null)).DoInstead(context => { saved = true; });


            store.LoadDifference(Schema.GetCommonSchema());

            Assert.IsTrue(saved);
        }
Exemple #3
0
        public void if_AspectObject_Is_Not_Persistent_WillNot_be_saved(bool nonPersistent)
        {
            var store = new XpoUserModelDictionaryDifferenceStore(Isolate.Fake.Instance<XafApplication>());

            var modelStoreObject = new UserModelDifferenceObject(Session.DefaultSession){
                                                                                            PersistentApplication = new PersistentApplication(Session.DefaultSession),
                                                                                            NonPersistent = nonPersistent
                                                                                        };
            Isolate.WhenCalled(() => modelStoreObject.Save()).WillThrow(new NotImplementedException());
            Isolate.WhenCalled(() => store.GetActiveDifferenceObject()).WillReturn(modelStoreObject);
            var dictionary = new Dictionary(Schema.GetCommonSchema());
            Isolate.WhenCalled(() => dictionary.Aspects).WillReturn(new List<string> { "aspect" });
            Isolate.Fake.StaticMethods(typeof(Validator));

            store.SaveDifference(dictionary);
        }
        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(""));
        }