Пример #1
0
        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");
        }
Пример #2
0
        public void Should_show_the_content_of_a_page()
        {
            //given
            string[] arguments = {"get", "-url", "http://api.openweathermap.org/data/2.5/weather?q=paris&units=metric"};
            Command c = new Command(arguments);

            //when
            UrlOperations uo = new UrlOperations(c);
            string result = uo.getContent();

            //then
            Assert.AreEqual(uo.getContent(), "{\"coord\":{\"lon\":2.35,\"lat\":48.85},\"sys\":{\"message\":0.0366,\"country\":\"FR\",\"sunrise\":1401162895,\"sunset\":1401219641},\"weather\":[{\"id\":500,\"main\":\"Rain\",\"description\":\"light rain\",\"icon\":\"10d\"}],\"base\":\"cmc stations\",\"main\":{\"temp\":13.93,\"humidity\":85,\"pressure\":1013.1,\"temp_min\":12.78,\"temp_max\":15},\"wind\":{\"speed\":6.92,\"deg\":276.501},\"rain\":{\"3h\":1},\"clouds\":{\"all\":92},\"dt\":1401184765,\"id\":2988507,\"name\":\"Paris\",\"cod\":200}" + "\n");
        }