Пример #1
0
        public void Constructor_ThrowsArgumentException_OnInvalidArgs()
        {
            // Check keyValue arg
            Assert.Throws <ArgumentException>(() => { var _ = new ExtractionIdentifierRejectionInfo(null, new Dictionary <string, int> {
                    { "bar", 1 }
                }); });
            Assert.Throws <ArgumentException>(() => { var _ = new ExtractionIdentifierRejectionInfo("  ", new Dictionary <string, int> {
                    { "bar", 1 }
                }); });

            // Check rejectionItems arg
            Assert.Throws <ArgumentException>(() => { var _ = new ExtractionIdentifierRejectionInfo("foo", null); });
            Assert.Throws <ArgumentException>(() => { var _ = new ExtractionIdentifierRejectionInfo("foo", new Dictionary <string, int>()); });

            // Check empty dict key
            Assert.Throws <ArgumentException>(() => { var _ = new ExtractionIdentifierRejectionInfo("foo", new Dictionary <string, int> {
                    { "  ", 1 }
                }); });

            // Check entries with 0 count
            var exc = Assert.Throws <ArgumentException>(() =>
            {
                var _ = new ExtractionIdentifierRejectionInfo(
                    "foo",
                    new Dictionary <string, int>
                {
                    { "bar", 0 },
                    { "baz", 0 },
                }
                    );
            });

            Assert.AreEqual("Dict contains key(s) with a zero count: bar,baz", exc.Message);
        }
Пример #2
0
 private static void WriteJobRejections(TextWriter streamWriter, ExtractionIdentifierRejectionInfo extractionIdentifierRejectionInfo)
 {
     streamWriter.WriteLine($"-   ID: {extractionIdentifierRejectionInfo.ExtractionIdentifier}");
     foreach ((string reason, int count) in extractionIdentifierRejectionInfo.RejectionItems.OrderByDescending(x => x.Value))
     {
         streamWriter.WriteLine($"    -   {count}x '{reason}'");
     }
 }