public void IgnoreExtraField_In_FileStream() { //Arrange var mockDataservice = new Mock <IDataService>(MockBehavior.Strict); var importer = new Importer.Importer(mockDataservice.Object, enableValidation: false); var mappings = new List <FieldMapping>() { new FieldMapping() { DatabaseFieldName = "Naam", MappedFieldName = "A" }, new FieldMapping() { DatabaseFieldName = "Relatie_Id", MappedFieldName = "B" } }; var streamreader = CreateReader($"A;B;C{Environment.NewLine}TestA;TestB;TestC"); mockDataservice.Setup(t => t.SaveDossier(It.Is <Dossier>(y => y.Naam == "TestA" && y.Relatie_Id == "TestB" && y.IdentificatieKenmerk == null))); // Act importer.SaveDossiers(mappings, streamreader); // Assert Assert.That(importer.Error, Is.EqualTo(false)); }
public void Notice_unexpected_EOF_Dossier() { //Arrange var mockDataservice = new Mock <IDataService>(MockBehavior.Strict); var importer = new Importer.Importer(mockDataservice.Object, enableValidation: false); var mappings = new List <FieldMapping>() { new FieldMapping() { DatabaseFieldName = "Naam", MappedFieldName = "A" }, }; var streamreader = CreateReader($"A;B{Environment.NewLine}TestA;TestB{Environment.NewLine}this_is_not_a_good_csv"); mockDataservice.Setup(t => t.SaveDossier(It.Is <Dossier>(y => y.Naam == "TestA" && y.Relatie_Id == null && y.IdentificatieKenmerk == null))); // Act importer.SaveDossiers(mappings, streamreader); // Assert Assert.That(importer.Error, Is.EqualTo(true)); Assert.That(importer.ErrorsImportDossiers.ToString(), Contains.Substring("ERROR: Dossier this_is_not_a_good_csv kon niet worden ingelezen, aantal kolommen is onjuist")); }