示例#1
0
        public void ReadValidCouplesFile()
        {
            // --- Arrange ----------------------------------------------------

            string sheet1Name = "Sheet1";
            var logInformation_1 = new LogEntry(LoggingEventType.Information, $"Reading sheet {sheet1Name} from file");
            var logInformation_2 = new LogEntry(LoggingEventType.Information, $"Read 6 rows from sheet {sheet1Name}.");

            var logger = new TestLoggingAdapter();
            var reader = new VakLatIlmoittautumisetReader(logger);

            // --- Act --------------------------------------------------------

            reader.ReadRegisteredCouples(excel_ValidCouplesWorkbook);

            // --- Assert -----------------------------------------------------

            Assert.That(logger.LogEntries.Count, Is.EqualTo(2));
            Assert.That(logger.LogEntries[0].Severity, Is.EqualTo(logInformation_1.Severity));
            Assert.That(logger.LogEntries[0].Message, Is.EqualTo(logInformation_1.Message));
            Assert.That(logger.LogEntries[1].Severity, Is.EqualTo(logInformation_2.Severity));
            Assert.That(logger.LogEntries[1].Message, Is.EqualTo(logInformation_2.Message));

            Assert.That(reader.DanceCoreIlmoittautumiset.Count, Is.EqualTo(5));
        }
示例#2
0
        private async Task OnInputFileChange(InputFileChangeEventArgs eventArgs)
        {
            fileName = eventArgs.File.Name;
            Console.WriteLine($"Got input file: {fileName}");

            using var fileStream   = eventArgs.File.OpenReadStream();
            using var memoryStream = new MemoryStream();
            await fileStream.CopyToAsync(memoryStream);

            var reader = new VakLatIlmoittautumisetReader(new MicrosoftLoggingAdapter(Logger));

            reader.ReadRegisteredCouples(memoryStream);

            ilmoittautumiset = new VakLatIlmoittautuminen[reader.DanceCoreIlmoittautumiset.Count];
            int idx = 0;

            foreach (var i in reader.DanceCoreIlmoittautumiset)
            {
                ilmoittautumiset[idx] = Mapper.Map <VakLatIlmoittautuminen>(i);
                idx++;
            }
            StateHasChanged();
        }