public void ShouldThrowExceptionWhenFileNotExists() { //Arrange const string wrongFilePath = @"/File_doesn't_exist.json"; var fileReader = new GeneralFileReader(); //Act //Assert Assert.Throws <FileNotFoundException>(() => fileReader.Read(wrongFilePath)); }
public void ShouldReadFileCorrectly() { //Arrange var buildDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var testFilePath = $"{buildDir}\\App_Data\\test_beer_repository.json"; var correctResult = File.ReadAllText(testFilePath); IFileReader fileReader = new GeneralFileReader(); //Act var fileReaderResult = fileReader.Read(testFilePath); //Assert Assert.AreEqual(correctResult, fileReaderResult); }