Пример #1
0
        public void ControlledUpdate_EntityWithMigrationLevelAuthorization_OverrideAnyLevel()
        {
            //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.Migration(thing))
            {
                thing.Name = newName;
            }

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

            //ACT
            using (PebblecodeUpdateContexts.Migration(thing))
            {
                thing.Name = newName;
            }
            Dictionary <string, string> currentAuth =
                SerialisationUtils.FromXml <Dictionary <string, string> >(thing.DbPropertyAuthorization);

            //ASSERT
            Assert.IsTrue(currentAuth.ContainsKey("Name"));
            Assert.AreEqual(previousHigherContext, currentAuth["Name"]);
        }
Пример #3
0
        public void MyGen_ForControlledEntities_EntityIsInstanceOfConcreteControlledUpdateEntity()
        {
            //ARRANGE
            ControlledUpdateThing thing = new ControlledUpdateThing();

            //ASSERT
            Assert.IsInstanceOf <ConcreteControlledUpdateEntity>(thing);
        }
Пример #4
0
        public void ControlledUpdate_EntityWithNoUpdateContext_ThrowsException()
        {
            //ARRANGE
            ControlledUpdateThing thing
                = new ControlledUpdateThing
                {
                DbName = "Test Thing",
                DbPropertyAuthorization = GetBasicAuthXml()
                };
            const string newName = "New Thing";

            //ACT
            thing.Name = newName;
        }
Пример #5
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);
        }
 public static void Delete(Flags toDelete, ControlledUpdateThing controlledUpdateThing)
 {
     _instance.Delete(toDelete, controlledUpdateThing);
 }
 public static void Refresh(ControlledUpdateThing controlledUpdateThing, Flags toPopulate)
 {
     _instance.Refresh(new ControlledUpdateThingList(controlledUpdateThing), toPopulate);
 }
 public static void Populate(ControlledUpdateThing controlledUpdateThing, Flags toPopulate)
 {
     _instance.Populate(controlledUpdateThing, toPopulate);
 }