示例#1
0
        /// <summary>
        /// Defines the entry point of the application.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public static void Main(string[] args)
        {
            string finish         = "n";
            string travelDistance = "";

            while (finish.ToLower().Equals("n"))
            {
                Console.Write("Please enter the distance for a starship to travel: ");
                travelDistance = Console.ReadLine();

                StarWarsShipService starWarsShipService = new StarWarsShipService();

                Console.WriteLine(starWarsShipService.GetAllStarWarsShips(travelDistance));

                Console.Write($"Do you want to finish 'Y' or 'N': ");
                finish = Console.ReadLine();
            }
        }
        public void GetAllStarWarsShips_ShouldReturnString_When_Data_IsValid_And_Next_Has_Value()
        {
            StarWarsShipsTest = new StarWarsShips()
            {
                Count    = 1,
                Next     = $"starships/?page=2",
                Previous = null,
            };
            StarWarsShipsTest.Results.Add(new Ship()
            {
                Name        = "executor",
                Consumables = "2 days",
                MGLT        = "100"
            });

            StarWarsShipsTest2 = new StarWarsShips()
            {
                Count    = 1,
                Next     = null,
                Previous = null,
            };
            StarWarsShipsTest2.Results.Add(new Ship()
            {
                Name        = "deathstar",
                Consumables = "2 years",
                MGLT        = "60"
            });

            mockHttpRequest.Setup(h => h.CallEndpoint(It.IsAny <string>())).Returns(StarWarsShipsTest);

            mockHttpRequest.Setup(h => h.CallEndpoint(StarWarsShipsTest.Next)).Returns(StarWarsShipsTest2);

            var response = StarWarsShipService.GetAllStarWarsShips("1000");

            Assert.IsNotNull(response);

            Assert.AreEqual("executor: 0\ndeathstar: 0\n", response);
        }
        public void GetAllStarWarsShips_ShouldReturnString_When_Data_IsValid_And_Last_Stop_Is_A_Refuel()
        {
            StarWarsShipsTest = new StarWarsShips()
            {
                Count    = 1,
                Next     = null,
                Previous = null,
            };
            StarWarsShipsTest.Results.Add(new Ship()
            {
                Name        = "executor",
                Consumables = "1 day",
                MGLT        = "100"
            });

            mockHttpRequest.Setup(h => h.CallEndpoint(It.IsAny <string>())).Returns(StarWarsShipsTest);

            var response = StarWarsShipService.GetAllStarWarsShips("24000");

            Assert.IsNotNull(response);

            Assert.AreEqual("executor: 9\n", response);
        }
示例#4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StarwarsTestBase"/> class.
 /// </summary>
 public StarWarsTestBase()
 {
     mockHttpRequest     = new Mock <IHttpRequest>();
     StarWarsShipService = new StarWarsShipService(mockHttpRequest.Object);
 }