コード例 #1
0
        public void CreateStructureLinkTest()
        {
            AddPrincipalToThread();

            AnnotateService target = new AnnotateService(Parameters.TestDatabaseName); // TODO: Initialize to an appropriate value

            StructureType t = CreatePopulatedStructureType(Parameters.TestDatabaseName);

            long[] IDs = target.UpdateStructureTypes(new StructureType[] { t });
            long[] IDsA; //ID's for struct A
            long[] IDsB; //ID's for struct B
            long StructureTypeID = IDs[0];

            t = target.GetStructureTypeByID(StructureTypeID);

            Structure newStructA = new Structure();
            Structure newStructB = new Structure();

            newStructA.TypeID = t.ID;
            newStructB.TypeID = t.ID;

            //Create location A
            Location newPosA = new Location();
            newPosA.ParentID = newStructA.ID;

            AnnotationPoint P = new AnnotationPoint();
            P.X = 0;
            P.Y = 0;
            P.Z = 0;
            newPosA.Position = P;

            CreateStructureRetval retvalA = target.CreateStructure(newStructA, newPosA);

            //CreateLocationB
            Location newPosB = new Location();
            newPosB.ParentID = newStructB.ID;

            AnnotationPoint Pb = new AnnotationPoint();
            Pb.X = -1;
            Pb.Y = -1;
            Pb.Z = -1;
            newPosA.Position = Pb;

            CreateStructureRetval retvalB = target.CreateStructure(newStructB, newPosB);

            Structure dbStructA = target.GetStructureByID(retvalA.structure.ID, false);
            Location dbPosA = target.GetLocationByID(retvalA.location.ID);

            Structure dbStructB = target.GetStructureByID(retvalB.structure.ID, false);
            Location dbPosB = target.GetLocationByID(retvalB.location.ID);

            Assert.IsTrue(dbStructA != null && dbStructA.ID == retvalA.structure.ID);
            Assert.IsTrue(dbPosA != null && dbPosA.ID == retvalA.location.ID);
            Assert.IsTrue(dbStructB != null && dbStructB.ID == retvalB.structure.ID);
            Assert.IsTrue(dbPosB != null && dbPosB.ID == retvalB.location.ID);

            //Link the structures
            StructureLink link = new StructureLink();
            link.SourceID = retvalA.structure.ID;
            link.TargetID = retvalB.structure.ID;

            target.CreateStructureLink(link);

            //Delete the link
            link.DBAction = DBACTION.DELETE;

            target.UpdateStructureLinks(new StructureLink[] { link });

            dbPosA.DBAction = DBACTION.DELETE;
            dbPosB.DBAction = DBACTION.DELETE;
            target.Update(new Location[] { dbPosA, dbPosB });

            //Check to make sure there aren't any locations for the structure
            long queryTimeInTicks;
            Location[] structLocs = target.GetLocationsForSection(dbStructA.ID, out queryTimeInTicks);
            Assert.IsTrue(structLocs.Length == 0);

            dbStructA.DBAction = DBACTION.DELETE;
            dbStructB.DBAction = DBACTION.DELETE;
            target.UpdateStructures(new Structure[] { dbStructA, dbStructB });

            Structure dbStructANull = target.GetStructureByID(retvalA.structure.ID, false);
            Location dbPosANull = target.GetLocationByID(retvalA.location.ID);
            Structure dbStructBNull = target.GetStructureByID(retvalB.structure.ID, false);
            Location dbPosBNull = target.GetLocationByID(retvalB.location.ID);

            Assert.IsNull(dbStructANull);
            Assert.IsNull(dbPosANull);
            Assert.IsNull(dbStructBNull);
            Assert.IsNull(dbPosBNull);

            //Delete the structure type
            t.DBAction = DBACTION.DELETE;
            target.UpdateStructureTypes(new StructureType[] { t });
        }
コード例 #2
0
        public void CreateStructureTest()
        {
            AddPrincipalToThread();

            AnnotateService target = new AnnotateService(Parameters.TestDatabaseName); // TODO: Initialize to an appropriate value

            StructureType t = CreatePopulatedStructureType("Test");

            long[] IDs = target.UpdateStructureTypes(new StructureType[] { t });
            long StructureTypeID = IDs[0];

            t = target.GetStructureTypeByID(StructureTypeID);

            Structure newStruct = new Structure();
            newStruct.TypeID = t.ID;

            Location newPos = new Location();
            newPos.ParentID = newStruct.ID;
            AnnotationPoint P = new AnnotationPoint();
            P.X = 0;
            P.Y = 0;
            P.Z = 0;
            newPos.Position = P;

            CreateStructureRetval retval = target.CreateStructure(newStruct, newPos);

            Structure dbStruct = target.GetStructureByID(retval.structure.ID, false);
            Location dbPos = target.GetLocationByID(retval.location.ID);

            Assert.IsTrue(dbStruct != null && dbStruct.ID == retval.structure.ID);
            Assert.IsTrue(dbPos != null && dbPos.ID == retval.location.ID);

            dbPos.DBAction = DBACTION.DELETE;
            target.Update(new Location[] { dbPos });

            //Check to make sure there aren't any locations for the structure
            long queryTimeInTicks;
            Location[] structLocs = target.GetLocationsForSection(dbStruct.ID, out queryTimeInTicks);
            Assert.IsTrue(structLocs.Length == 0);

            dbStruct.DBAction = DBACTION.DELETE;
            target.UpdateStructures(new Structure[] { dbStruct });

            Structure dbStructNull = target.GetStructureByID(retval.structure.ID, false);
            Location dbPosNull = target.GetLocationByID(retval.location.ID);

            Assert.IsNull(dbStructNull);
            Assert.IsNull(dbPosNull);

            //Delete the structure type
            t.DBAction = DBACTION.DELETE;
            target.UpdateStructureTypes(new StructureType[] { t });
        }