public void MerchantFileReader_ShouldGenerateError_WhenIncorrectDataProvided(string entry) { // Arrange var merchantReader = new MerchantReader(); var memoryStream = GenerateStreamFromString(entry); StreamReader reader = new StreamReader(memoryStream); var exceptionTrhown = false; // Act try { var merrhants = merchantReader.Read(reader, new MerchantParser()); } catch (Exception exception) { exceptionTrhown = true; Assert.Equal("Improper format of merchant data", exception.Message); } // Assert Assert.True(exceptionTrhown); }
public void MerchantFileReader_ShouldReadMerchants_WhenCorrectDataProvided() { // Arrange var merchantReader = new MerchantReader(); var text = @"7-ELEVEN 1 0 CIRCLE_K 1 20"; var memoryStream = GenerateStreamFromString(text); StreamReader reader = new StreamReader(memoryStream); // Act var merrhants = merchantReader.Read(reader, new MerchantParser()); // Assert Assert.Equal(2, merrhants.Count); Assert.Equal(sevenEleven, merrhants[sevenEleven].Name); Assert.Equal(0, merrhants[sevenEleven].DiscountPercentage); Assert.Equal(1, merrhants[sevenEleven].FeeAsPercentage); Assert.Equal(circleK, merrhants[circleK].Name); Assert.Equal(20, merrhants[circleK].DiscountPercentage); Assert.Equal(1, merrhants[circleK].FeeAsPercentage); }