Ejemplo n.º 1
0
        public void AddLinkBetween_createNewLink_pass()
        {
            ///////////////Create the things that we are going to create relationships between /////////////////
            var predator        = new Catalogue(CatalogueRepository, "Predator");
            var lazor           = new CatalogueItem(CatalogueRepository, predator, "QuadlzorVelocity");
            var highEnergyTable = new TableInfo(CatalogueRepository, "HighEnergyShizzle");
            var velocityColumn  = new ColumnInfo(CatalogueRepository, "Velocity Of Matter", "int", highEnergyTable);

            ////////////Check the creation worked ok
            Assert.IsNotNull(predator); //catalogue
            Assert.IsNotNull(lazor);

            Assert.IsNotNull(highEnergyTable); //underlying table stuff
            Assert.IsNotNull(velocityColumn);

            ////////////// Create links between stuff and check they were created successfully //////////////

            //create a link between catalogue item lazor and velocity column
            lazor.SetColumnInfo(velocityColumn);
            Assert.IsTrue(lazor.ColumnInfo.ID == velocityColumn.ID);

            ////////////////cleanup ---- Delete everything that we created -------- //////////////
            velocityColumn.DeleteInDatabase(); //delete causes CASCADE: CatalogueItem no longer associated with ColumnInfo because ColumnInfo died

            lazor.RevertToDatabaseState();

            Assert.IsNull(lazor.ColumnInfo);//involves a database query so won't actually invalidate the below

            predator.DeleteInDatabase();

            highEnergyTable.DeleteInDatabase();
        }