示例#1
0
        public void TestIdentifierSwap2ForGuids(DatabaseType dbType)
        {
            var db     = GetCleanedServer(dbType);
            var mapTbl = db.ExpectTable("Map");

            //the declaration of what the guid namer table should be
            var options = new IdentifierMapperOptions();

            options.MappingConnectionString = db.Server.Builder.ConnectionString;
            options.MappingTableName        = mapTbl.GetFullyQualifiedName();
            options.SwapColumnName          = "priv";
            options.ReplacementColumnName   = "pub";
            options.MappingDatabaseType     = dbType;

            var swapper = new ForGuidIdentifierSwapper();

            swapper.Setup(options);

            string reason;

            Assert.AreEqual(36, swapper.GetSubstitutionFor("01010101", out reason).Length);
            Assert.AreEqual(36, swapper.GetSubstitutionFor("02020202", out reason).Length);

            var answer1 = swapper.GetSubstitutionFor("03030303", out reason);

            var answer2 = swapper.GetSubstitutionFor("04040404", out reason);

            var answer3 = swapper.GetSubstitutionFor("03030303", out reason);

            Assert.AreEqual(answer1, answer3);

            Assert.AreNotEqual(answer1, answer2);
        }
示例#2
0
        public void TestIdentifierSwap2ForGuids_WithSeperateSwappers(DatabaseType dbType)
        {
            var db     = GetCleanedServer(dbType);
            var mapTbl = db.ExpectTable("Map");

            //the declaration of what the guid namer table should be
            var options = new IdentifierMapperOptions();

            options.MappingConnectionString = db.Server.Builder.ConnectionString;
            options.MappingTableName        = mapTbl.GetFullyQualifiedName();
            options.SwapColumnName          = "priv";
            options.ReplacementColumnName   = "pub";
            options.MappingDatabaseType     = dbType;

            var swapper1 = new ForGuidIdentifierSwapper();

            swapper1.Setup(options);

            var swapper2 = new ForGuidIdentifierSwapper();

            swapper2.Setup(options);

            var answer1 = swapper1.GetSubstitutionFor("01010101", out _);
            var answer2 = swapper2.GetSubstitutionFor("01010101", out _);

            Assert.AreEqual(answer1, answer2);

            Assert.IsNotNull(answer1);
            Assert.IsNotNull(answer2);
        }
示例#3
0
        public void TestIdentifierSwapForGuid(DatabaseType dbType)
        {
            var db     = GetCleanedServer(dbType);
            var mapTbl = db.ExpectTable("Map");

            //the declaration of what the guid namer table should be
            var options = new IdentifierMapperOptions();

            options.MappingConnectionString = db.Server.Builder.ConnectionString;
            options.MappingTableName        = mapTbl.GetFullyQualifiedName();
            options.SwapColumnName          = "priv";
            options.ReplacementColumnName   = "pub";
            options.MappingDatabaseType     = dbType;

            var swapper = new ForGuidIdentifierSwapper();

            swapper.Setup(options);
            swapper.Setup(options);
            swapper.Setup(options); //this isn't just for the lols, this will test both the 'create it mode' and the 'discover it mode'

            var consumer = new IdentifierMapperQueueConsumer(Mock.Of <IProducerModel>(), swapper);

            var msg = GetTestDicomFileMessage();

            string reason;

            consumer.SwapIdentifier(msg, out reason);

            var newDs         = DicomTypeTranslater.DeserializeJsonToDataset(msg.DicomDataset);
            var guidAllocated = newDs.GetValue <string>(DicomTag.PatientID, 0);

            var dt = mapTbl.GetDataTable();

            Assert.AreEqual(1, dt.Rows.Count);

            //e.g. '841A2E3E-B7C9-410C-A5D1-816B95C0E806'
            Assert.AreEqual(36, guidAllocated.Length);
        }