public void Go_To_Next_Until_Get_To_End_Test(string mazeId, string state) { var stubPathService = new Mock <IPathService>(); var server = FluentMockServer.Start(null, false); var client = new RestfulClient(server.Urls.Select(u => string.Concat(new Uri(u))).First() + "pony-challenge/maze", true); IGameService gameService = new GameService(client); var resultResponseMove = new ResponseMove(); var pathWay = new Model.Robot.PathWay(0, new List <MoveType> { MoveType.West }); stubPathService.Setup(fm => fm.FindMoves(mazeId)).Returns(pathWay); var responseBody = new Dictionary <string, object> { ["state"] = "active", ["state-result"] = "Move accepted" }; server.Given(Request.Create().UsingPost()) .RespondWith(Response.Create() .WithStatusCode(200) .WithHeader("content-type", "application/json; charset=utf-8") .WithBodyAsJson(responseBody, Encoding.UTF8)); var roboteEngine = new RobotEngine(gameService, stubPathService.Object); var result = roboteEngine.GotoNext(mazeId); Assert.AreEqual(result.State, "active"); }
public static ResponseMoveModel ToMap(this ResponseMove model) { return(new ResponseMoveModel { MazeId = model.StateResult, State = model.State }); }
public void When_Pass_Name_Invalid_MazeId_To_Move(string mazeId) { var mockPathService = new Mock <IRestfulClient>(); var result = new ResponseMove(); mockPathService.Setup(x => x.Execute <ResponseMove>(It.IsAny <RestClientModel>())).Callback <RestClientModel>(c => { result = new ResponseMove { State = "maze with that id is not found" }; }).Returns(() => result); IGameService gameService = new GameService(mockPathService.Object); var gameServiceobj = gameService.Move(mazeId); Assert.AreEqual(gameServiceobj.State, "maze with that id is not found"); }