Ejemplo n.º 1
0
        public void TestClassifierName_ValidClassifier()
        {
            var options = new GlobalOptionsFactory().Load();

            var testDcm = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, nameof(TestClassifierName_ValidClassifier), "f1.dcm")); Path.Combine(TestContext.CurrentContext.TestDirectory, nameof(TestClassifierName_ValidClassifier), "f1.dcm");

            TestData.Create(testDcm);

            using (var tester = new MicroserviceTester(options.RabbitOptions, options.IsIdentifiableOptions))
            {
                tester.CreateExchange(options.IsIdentifiableOptions.IsIdentifiableProducerOptions.ExchangeName, null);

                options.IsIdentifiableOptions.ClassifierType = typeof(RejectAllClassifier).FullName;
                options.IsIdentifiableOptions.DataDirectory  = TestContext.CurrentContext.TestDirectory;

                var host = new IsIdentifiableHost(options, new IsIdentifiableServiceOptions());
                Assert.IsNotNull(host);
                host.Start();

                tester.SendMessage(options.IsIdentifiableOptions, new ExtractedFileStatusMessage()
                {
                    DicomFilePath       = "yay.dcm",
                    OutputFilePath      = testDcm.FullName,
                    ProjectNumber       = "100",
                    ExtractionDirectory = "./fish",
                    StatusMessage       = "yay!",
                    Status = ExtractedFileStatus.Anonymised
                });

                var awaiter = new TestTimelineAwaiter();
                awaiter.Await(() => host.Consumer.AckCount == 1);
            }
        }
Ejemplo n.º 2
0
        public void TestIsIdentifiable_TesseractStanfordDicomFileClassifier()
        {
            var options = new GlobalOptionsFactory().Load();

            // Create a test data directory containing IsIdentifiableRules with 0 rules, and tessdata with the eng.traineddata classifier
            // TODO(rkm 2020-04-14) This is a stop-gap solution until the tests are properly refactored
            var testRulesDir = new DirectoryInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "data", "IsIdentifiableRules"));

            testRulesDir.Create();
            options.IsIdentifiableOptions.DataDirectory = testRulesDir.Parent.FullName;
            var tessDir = new DirectoryInfo(Path.Combine(testRulesDir.Parent.FullName, "tessdata"));

            tessDir.Create();
            var dest = Path.Combine(tessDir.FullName, "eng.traineddata");

            if (!File.Exists(dest))
            {
                File.Copy(Path.Combine(DataDirectory, "tessdata", "eng.traineddata"), dest);
            }

            var testDcm = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, nameof(TestIsIdentifiable_TesseractStanfordDicomFileClassifier), "f1.dcm"));

            Path.Combine(TestContext.CurrentContext.TestDirectory, nameof(TestClassifierName_ValidClassifier), "f1.dcm");
            TestData.Create(testDcm);

            using (var tester = new MicroserviceTester(options.RabbitOptions, options.IsIdentifiableOptions))
            {
                options.IsIdentifiableOptions.ClassifierType = typeof(TesseractStanfordDicomFileClassifier).FullName;

                var host = new IsIdentifiableHost(options, new IsIdentifiableServiceOptions());
                host.Start();

                tester.SendMessage(options.IsIdentifiableOptions, new ExtractedFileStatusMessage
                {
                    DicomFilePath       = "yay.dcm",
                    OutputFilePath      = testDcm.FullName,
                    ProjectNumber       = "100",
                    ExtractionDirectory = "./fish",
                    StatusMessage       = "yay!",
                    Status = ExtractedFileStatus.Anonymised
                });

                var awaiter = new TestTimelineAwaiter();
                awaiter.Await(() => host.Consumer.AckCount == 1 || host.Consumer.NackCount == 1);
                Assert.AreEqual(1, host.Consumer.AckCount, "Tesseract not acking");
            }
        }