Ejemplo n.º 1
0
        /// <summary>
        /// Sorts the names in the given file
        /// outputs sorted names into a file named "sorted-names-list.txt".
        /// </summary>
        /// <param name="inputFilename">The file to sort.</param>
        private static void SortNames(string inputFilename)
        {
            try
            {
                var delimiter      = " ";
                var outputFilename = "sorted-names-list.txt";

                var reader     = new PersonFileReader(inputFilename);
                var parser     = new PersonFileParser(delimiter);
                var writer     = new PersonFileWriter(outputFilename);
                var sorter     = new PersonSorter(new PersonNameComparer());
                var validator  = new PersonValidator();
                var processor  = new PersonProcessor(reader, parser, writer, validator, sorter);
                var sortedList = processor.Process();

                foreach (var person in sortedList)
                {
                    System.Console.WriteLine(person.ToString());
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 2
0
        public void CanProcessMessage()
        {
            var processor = new PersonProcessor(consumer.Object, publisher.Object);
            var elvis     = new PersonMessage {
                Id = Guid.NewGuid(), Name = "Elvis"
            };
            var message = new SQSEvent.SQSMessage {
                Body = elvis.ToJson()
            };

            consumer.Setup(x => x.Process(new[] { message }))
            .Returns(Task.CompletedTask);

            processor.Process(new[] { message });
        }
        public void Is_File_Processed_Successfully()
        {
            // Arrange
            var inputFilename  = "./unsorted-names-list.txt";
            var outputFilename = "sorted-names-list.txt";
            var delimiter      = "";
            var reader         = new PersonFileReader(inputFilename);
            var parser         = new PersonFileParser(delimiter);
            var writer         = new PersonFileWriter(outputFilename);
            var sorter         = new PersonSorter(new PersonNameComparer());
            var validator      = new PersonValidator();
            var processor      = new PersonProcessor(reader, parser, writer, validator, sorter);

            // Act
            var sortedList = processor.Process();

            // Assert
            Assert.IsTrue(true);
        }