public void Set_UniqueName_To_Application_Type_FullName(){
            var persistentApplication = new PersistentApplication(Session.DefaultSession);

            modelDifferenceModule.UpdatePersistentApplication(application);

            Assert.AreEqual(application.GetType().FullName, persistentApplication.UniqueName);
        }
        public void Set_Model_To_Application_Model()
        {
            var persistentApplication = new PersistentApplication(Session.DefaultSession);

            modelDifferenceModule.UpdatePersistentApplication(application);

            Assert.AreEqual(application.Model, persistentApplication.Model);
        }
        public void Can_Be_Searched_By_Name(){
            var persistentApplication1 = new PersistentApplication(Session.DefaultSession){UniqueName = "appname"};
            persistentApplication1.Save();
            var application = new QueryPersistentApplication(Session.DefaultSession);

            var persistentApplication = application.Find("appname");

            Assert.AreEqual(persistentApplication1, persistentApplication);
        }
        public void Set_Name_To_Application_Title()
        {
            var persistentApplication = new PersistentApplication(Session.DefaultSession);
            application.Title = "title";

            modelDifferenceModule.UpdatePersistentApplication(application);

            Assert.AreEqual("title", persistentApplication.Name);
        }
        public void If_Name_Is_Set_Do_Not_Update_Ite()
        {
            var persistentApplication = new PersistentApplication(Session.DefaultSession){Name = "name"};

            application.Title = "title";

            modelDifferenceModule.UpdatePersistentApplication(application);

            Assert.AreEqual("name", persistentApplication.Name);
        }
Esempio n. 6
0
        public void Cause_PersistentApplication_ShouldBe_Unique_Should_Query_DataStore_Befare_Creating_New(){
            var application = new PersistentApplication(Session.DefaultSession){UniqueName = "appName"};
            application.Save();
            var modelDifferenceObject = new ModelDifferenceObject(Session.DefaultSession);


            modelDifferenceObject.InitializeMembers("", "appName");

            Assert.AreEqual(application, modelDifferenceObject.PersistentApplication);
        }
        public void Many_Disabled_Objects_With_Same_ApplicationName_DifferenceType_Can_Exist(DifferenceType differenceType, ValidationState validationState)
        {
            var ruleSet = new RuleSet();

            var persistentApplication = new PersistentApplication(Session.DefaultSession);
            new ModelDifferenceObject(Session.DefaultSession) { Disabled = true, PersistentApplication = persistentApplication }.Save();

            var modelDifferenceObject = new ModelDifferenceObject(Session.DefaultSession) { Disabled = true, PersistentApplication = persistentApplication };
            Isolate.WhenCalled(() => modelDifferenceObject.DifferenceType).WillReturn(differenceType);
            RuleSetValidationResult target = ruleSet.ValidateTarget(modelDifferenceObject, ContextIdentifier.Save);

            var resultItem = target.Results.Where(item => item.Rule is RuleCombinationOfPropertiesIsUnique).Single();
            Assert.AreEqual(validationState, resultItem.State);
        }
        public void Name_Is_Unique()
        {
            new PersistentApplication(Session.DefaultSession) { UniqueName = "name" }.Save();

            var application = new PersistentApplication(Session.DefaultSession) { Name = "name" };
            var target = new RuleSet().ValidateTarget(application, ContextIdentifier.Save);

            var items =
                target.Results.Where(
                    item =>
                    item.Rule is RuleUniqueValue &&
                    item.Rule.UsedProperties.Contains(application.GetPropertyInfo(x => x.UniqueName).Name)).FirstOrDefault();
            Assert.IsNotNull(items);
            Assert.AreEqual(ValidationState.Invalid, items.State);
        }
        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(""));
        }
        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);


        }
Esempio n. 11
0
        public void Some_Properties_Should_Change(){
            DateTime dateTime = DateTime.Now;
            Mock mock = MockManager.Mock(typeof (CloneObjectViewController),Constructor.NotMocked);
            mock.CallBase.ExpectAlways("CloneObject");
            var singleChoiceActionExecuteEventArgs = Isolate.Fake.InstanceAndSwapAll<SingleChoiceActionExecuteEventArgs>();
            var data = new ModelDifferenceObject(Session.DefaultSession){Name = "name"};
            Isolate.WhenCalled(() => singleChoiceActionExecuteEventArgs.ShowViewParameters.CreatedView.CurrentObject).WillReturn(data);
            var persistentApplication = new PersistentApplication(Session.DefaultSession);
            var controller = new ViewControllerFactory().CreateController<CloneObjectViewController>(ViewType.DetailView, new ModelDifferenceObject(Session.DefaultSession){PersistentApplication = persistentApplication});
            controller.CloneObjectAction.Active.Clear();
            
            controller.CloneObjectAction.DoExecute(new ChoiceActionItem(new DictionaryNode(""), data));

            Assert.IsNull(data.Name);
            Assert.IsTrue(data.Disabled);
            Assert.GreaterThan(data.DateCreated, dateTime);
            Assert.AreEqual(persistentApplication, data.PersistentApplication);
            
        }
Esempio n. 12
0
        public void If_PersistentApp_Not_Updated_Update_It_MarkIt_And_Save_It()
        {
            bool updated = false;
            
            var objectSpace = Isolate.Fake.Instance<ObjectSpace>();
            Isolate.WhenCalled(() => objectSpace.Session).WillReturn(Session.DefaultSession);
            Isolate.WhenCalled(() => ObjectSpace.FindObjectSpace(null)).WillReturn(objectSpace);
            bool commited = false;
            Isolate.WhenCalled(() => objectSpace.CommitChanges()).DoInstead(context => commited= true);
            var persistentApplication = new PersistentApplication(Session.DefaultSession);
            Isolate.WhenCalled(() => modelDifferenceModule.GetPersistentApplication(null)).WillReturn(persistentApplication);
            Isolate.WhenCalled(() => modelDifferenceModule.UpdatePersistentApplication(null)).DoInstead(context => {updated=true;return persistentApplication;});

//            eventHandler.Invoke(this,new LogonEventArgs(null));

            Assert.IsTrue(updated);
            Assert.IsTrue((bool) modelDifferenceModule.PersistentApplicationModelUpdated);
            Assert.IsTrue(commited);

        }