public void Test_Execute_Reference()
        {
            TestUser user = new TestUser();

            user.ID        = Guid.NewGuid();
            user.FirstName = "-- First Name -- ";
            user.LastName  = "-- Last Name --";
            //user.Username = "******";

            TestRole role = new TestRole();

            role.ID   = Guid.NewGuid();
            role.Name = "-- Test Role --";

            user.Roles = new TestRole[] { role };

            string newTypeName = "TestAccount";

            EntityReference reference = DataAccess.Data.Referencer.GetActiveReferences(user)[0];

            XmlDocument document = XmlUtilities.SerializeToDocument(reference);

            RenameTypeCommand command = new RenameTypeCommand();

            command.TypeName    = user.ShortTypeName;
            command.NewTypeName = newTypeName;

            command.Execute(document);

            EntityReference updatedReference = (EntityReference)XmlUtilities.DeserializeFromDocument(document, typeof(EntityReference));

            Assert.AreEqual(newTypeName, updatedReference.Type1Name, "The type name wasn't changed.");
        }
Beispiel #2
0
        public void Test_Execute_Entity()
        {
            TestUser user = new TestUser();

            user.ID        = Guid.NewGuid();
            user.FirstName = "-- First Name -- ";
            user.LastName  = "-- Last Name --";
            //user.Username = "******";

            XmlDocument document = XmlUtilities.SerializeToDocument(user);

            RenamePropertyCommand command = new RenamePropertyCommand();

            command.TypeName        = user.ShortTypeName;
            command.PropertyName    = "FirstName";
            command.NewPropertyName = "Username";

            command.Execute(document);

            TestUser updatedUser = (TestUser)XmlUtilities.DeserializeFromDocument(document, typeof(TestUser));

            // This should have moved the "FirstName" property to "Username" and therefore the new "Username" property value
            // should be equal with the original "FirstName" property
            Assert.AreEqual(user.FirstName, updatedUser.Username, "The property wasn't renamed properly.");
        }
        public void Test_Execute_Entity()
        {
            TestUser user = new TestUser();

            user.ID        = Guid.NewGuid();
            user.FirstName = "-- First Name -- ";
            user.LastName  = "-- Last Name --";
            //user.Username = "******";

            XmlDocument document = XmlUtilities.SerializeToDocument(user);

            RenameTypeCommand command = new RenameTypeCommand();

            command.TypeName    = user.ShortTypeName;
            command.NewTypeName = "TestAccount";

            command.Execute(document);

            Assert.AreEqual("TestAccount", document.DocumentElement.Name, "The type name wasn't updated on the document element node.");

            TestAccount account = (TestAccount)XmlUtilities.DeserializeFromDocument(document, typeof(TestAccount));

            Assert.AreEqual(user.FirstName, account.FirstName, "The properties don't match.");
        }
Beispiel #4
0
        public void Test_RenewSchema()
        {
            TestUser user = new TestUser();

            user.ID        = Guid.NewGuid();
            user.FirstName = "--FirstName--";
            user.LastName  = "--LastName--";
            user.Email     = "--Email--";
            user.Username  = "******";

            XmlDocument document = XmlUtilities.SerializeToDocument(user);

            RenamePropertyCommand command1 = new RenamePropertyCommand();

            command1.PropertyName    = "LastName";
            command1.NewPropertyName = "Surname";
            command1.TypeName        = "TestUser";

            DataSchemaCommandCollection commands = new DataSchemaCommandCollection();

            commands.Add(command1);

            DataSchema schema = (DataSchema)DataAccess.Data.InitializeDataSchema();

            schema.SchemaCommands = commands;

            schema.RenewSchema(document);

            TestUser user2 = (TestUser)XmlUtilities.DeserializeFromDocument(document, user.GetType());

            Assert.IsNotNull(user2, "user2 == null");

            Assert.AreEqual(user.ID.ToString(), user2.ID.ToString(), "The IDs don't match.");

            Assert.AreEqual(user.LastName, user2.Surname, "The value of the LastName wasn't moved to the Surname property like it should have.");
        }