Пример #1
0
        public void ControlledUpdate_EntityWithLowerAuthorization_DontAllowPropertyToBeSet()
        {
            //ARRANGE
            const string higherContext = "HigherUser";
            var          auth          = new Dictionary <string, string> {
                { "Name", higherContext }
            };
            string authXml = SerialisationUtils.ToXml(auth);
            ControlledUpdateThing thing
                = new ControlledUpdateThing
                {
                DbName = "Test Thing",
                DbPropertyAuthorization = authXml
                };
            const string newName = "New Thing";

            //ACT
            using (PebblecodeUpdateContexts.LowerUser(thing))
            {
                thing.Name = newName;
            }

            //ASSERT
            Assert.AreNotEqual(newName, thing.Name);
        }
Пример #2
0
        public void ControlledUpdate_EntityWithNoPrviousAuthorization_AllowPropertyToBeSet()
        {
            //ARRANGE
            ControlledUpdateThing thing
                = new ControlledUpdateThing
                {
                DbName = "Test Thing",
                DbPropertyAuthorization = GetBasicAuthXml()
                };
            const string newName = "New Thing";

            //ACT
            using (PebblecodeUpdateContexts.LowerUser(thing))
            {
                thing.Name = newName;
            }

            //ASSERT
            Assert.AreEqual(newName, thing.Name);
        }