public void Read_Should_ThrowUnKnowFormatException_When_AnyRecordIsNotEqual5Fields() { var filePath = Path.Combine(_fileDirectory, "incorrect.xml"); using (var stream = File.OpenRead(filePath)) { Assert.ThrowsException <UnKnowFormatException>(() => _reader.Read(stream)); } }
private void CallXmlReader(IFormFile file, ref List <string> errorMesages) { XmlTransactionModel xmlTransactionModel = xmlTransactionReader.Read(file); if (xmlTransactionModel != null) { foreach (XmlTransaction transaction in xmlTransactionModel.Transactions) { errorMesages.AddRange(xmlValidator.Validate(transaction)); } if (errorMesages.Count == 0) { IEnumerable <TransactionModel> transactionModels = xmlTransactionModel.MapToModel(); transactionRepository.AddRange(transactionModels); } } }