public void Should_save_the_content_of_a_page() { //given string[] arguments = {"get", "-url", "http://api.openweathermap.org/data/2.5/weather?q=paris&units=metric", "-save", @"C:\Users\erwan\abc.json"}; Command c = new Command(arguments); //when UrlOperations uo = new UrlOperations(c); uo.saveContent(); string line; string readFile = ""; // Read the file System.IO.StreamReader file = new System.IO.StreamReader(c.getSave()); while((line = file.ReadLine()) != null) { readFile += line; } file.Close(); //then Assert.AreEqual(uo.getContent(), readFile + "\n"); }
public void Should_find_the_file_created() { //given string[] arguments = {"get", "-url", "http://api.openweathermap.org/data/2.5/weather?q=paris&units=metric", "-save", @"C:\Users\erwan\abc.json"}; Command c = new Command(arguments); //when UrlOperations uo = new UrlOperations(c); uo.saveContent(); //then Assert.AreEqual(File.Exists(c.getSave()), true); }