Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Usage: ocr-kata </path/to/file>");
            }

            var filePath = args.Single();

            var entries = EntryParser.Parse(filePath, 3);

            foreach (var entry in entries)
            {
                Console.WriteLine(Format(entry));
            }
        }
Ejemplo n.º 2
0
 public void Parse_ArgumentNull()
 {
     ItemUnderTest.Parse(null);
 }
Ejemplo n.º 3
0
            public static Entry First(string hashTagString)
            {
                var parser = new EntryParser(hashTagString);

                return(parser.Parse());
            }
Ejemplo n.º 4
0
        public async Task EntryParser_CanParse_All()
        {
            string[] exclusions = { "coll_thes_above_meta.json", "sense_learn_apple.json", "sense_above.json", "sense_med_doctor.json" };
            var      asm        = Assembly.GetExecutingAssembly();
            var      resources  = asm.GetManifestResourceNames();

            var settings = new JsonSerializerSettings
            {
                TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple,
                TypeNameHandling  = TypeNameHandling.Objects,
                NullValueHandling = NullValueHandling.Ignore
            };

            foreach (var resource in resources)
            {
                if (exclusions.Any(e => resource.EndsWith(e)))
                {
                    continue;
                }

                await using var resourceStream = asm.GetManifestResourceStream(resource);

                using var reader = new StreamReader(resourceStream);
                string content = await reader.ReadToEndAsync();

                try
                {
                    var data = JsonConvert.DeserializeObject <DictionaryEntry[]>(content, Converter.Settings);

                    // ACT
                    var result = _entryParser.Parse("api", data);

                    // ASSERT
                    result.Entries.ShouldNotBeEmpty();

                    // verify serialization/deserialization
                    var serialized   = JsonConvert.SerializeObject(result, settings);
                    var deserialized = JsonConvert.DeserializeObject <ResultModel>(serialized, settings);
                }
                catch (Exception ex)
                {
                    throw new NotImplementedException(resource, ex);
                }
            }
        }
Ejemplo n.º 5
0
        public void UseCaseOneShouldHave11Entries()
        {
            var pathToUseCase = Path.Combine(TestContext.CurrentContext.TestDirectory, "../../../ExampleFiles/UseCase1.txt");

            Assert.That(EntryParser.Parse(pathToUseCase, 3), Has.Count.EqualTo(11));
        }