public void Exercise1Service_GetUser_ReturnsUserResponse() { //act var response = _exercise1Service.GetUser(); //assert Assert.AreEqual("Jasmine Kaur", response.Name); }
public void Initialize() { // arrange _exercise1Service = Substitute.For <IExercise1Service>(); _exercise1Service.GetUser().Returns(new UserResponse() { Name = "Jas", Token = "123" }); _userController = Substitute.ForPartsOf <UserController>(_exercise1Service); }
public IActionResult Get() { try { var response = _exercise1Service.GetUser(); return(Ok(response)); } catch (System.Exception ex) { // todo: exception logging & handling } return(new BadRequestResult()); }
public IActionResult Exercise1([FromBody] ApiRequest request) { var result = Exercise1Service.GetUser(request.url); if (result.IsOk) { Exercise1Response response = new Exercise1Response() { name = result.Value.name, token = result.Value.token }; return(Ok(new ApiResponse() { passed = true, url = request.url, message = response })); } else { return(BadRequest(result.Errors)); } }