Beispiel #1
0
        public void When_Updating_Model_It_Should_Add_AllCultures_As_Predifined_Values_Of_CurrentLanguage_Member(){
            var dictionary = DictionaryFactory.Create(typeof(ModelDifferenceObject));
            var module = new ModelDifferenceModule();
            Isolate.WhenCalled(() => module.GetAllCultures()).WillReturn("test");

            module.UpdateModel(dictionary);

            var name = new ModelDifferenceObject(Session.DefaultSession).GetPropertyInfo(x=>x.PreferredAspect).Name;
            var single = new ApplicationNodeWrapper(dictionary).BOModel.FindClassByType(typeof(ModelDifferenceObject)).AllProperties.Where(wrapper => wrapper.Name==name).Single();
            Assert.AreEqual("test", single.Node.GetAttributeValue("PredefinedValues"));
        }
Beispiel #2
0
        public void Create_User_And_Role_DynamicMembers()
        {

            var module = new ModelDifferenceModule();
            bool user = false;
            Isolate.WhenCalled(() => UserDifferenceObjectBuilder.CreateDynamicMembers(null)).DoInstead(context => user = true);
            bool role = false;
            Isolate.WhenCalled(() => RoleDifferenceObjectBuilder.CreateDynamicMembers(Isolate.Fake.Instance<ISecurityComplex>())).DoInstead(context => role = true);

            module.CustomizeTypesInfo(XafTypesInfo.Instance);

            Assert.IsTrue(role);
            Assert.IsTrue(user);
        }
Beispiel #3
0
        public void If_Security_Is_Not_Complex_UserType_Is_Set_Remove_RoleAspect_Node()
        {
            Isolate.WhenCalled(() => SecuritySystem.UserType).WillReturn(typeof(User));
            var wrapper = new ApplicationNodeWrapper(new Dictionary(new DictionaryNode(ApplicationNodeWrapper.NodeName), Schema.GetCommonSchema()));
            wrapper.Load(typeof(RoleModelDifferenceObject));
            
            var module = new ModelDifferenceModule();
            Isolate.WhenCalled(() => module.AddCultures(null)).IgnoreCall();
         
            module.UpdateModel(wrapper.Dictionary);

            Assert.AreEqual(0, wrapper.BOModel.Classes.Count);

        }
Beispiel #4
0
        public void UserModel_Should_Be_Assign()
        {
            var module = new ModelDifferenceModule();
            var application = Isolate.Fake.Instance<XafApplication>();
            using (RecorderManager.StartRecording())
            {
                application.CreateCustomUserModelDifferenceStore += null;
            }
            module.Setup(application);
            var handler = ((EventHandler<CreateCustomModelDifferenceStoreEventArgs>)RecorderManager.LastMockedEvent.GetEventHandle());
            var args = new CreateCustomModelDifferenceStoreEventArgs();

            handler.Invoke(this, args);

            Assert.IsTrue(args.Handled);
            Assert.IsInstanceOfType(typeof(XpoUserModelDictionaryDifferenceStore), args.Store);
        }
Beispiel #5
0
        public void DefaultLanguage_IsContained_In_Cultures(){
            var module = new ModelDifferenceModule();

            var cultures = module.GetAllCultures();

            var strings = cultures.Split(';');
            Assert.AreEqual(CultureInfo.GetCultures(CultureTypes.AllCultures).Count()+1, strings.Length);
            Assert.AreEqual(DictionaryAttribute.DefaultLanguage, strings[0]);
        }