Ejemplo n.º 1
0
        public void Exercise1Service_GetUser_ReturnsUserResponse()
        {
            //act
            var response = _exercise1Service.GetUser();

            //assert
            Assert.AreEqual("Jasmine Kaur", response.Name);
        }
Ejemplo n.º 2
0
 public void Initialize()
 {
     // arrange
     _exercise1Service = Substitute.For <IExercise1Service>();
     _exercise1Service.GetUser().Returns(new UserResponse()
     {
         Name = "Jas", Token = "123"
     });
     _userController = Substitute.ForPartsOf <UserController>(_exercise1Service);
 }
Ejemplo n.º 3
0
 public IActionResult Get()
 {
     try
     {
         var response = _exercise1Service.GetUser();
         return(Ok(response));
     }
     catch (System.Exception ex)
     {
         // todo: exception logging & handling
     }
     return(new BadRequestResult());
 }
Ejemplo n.º 4
0
        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));
            }
        }