Пример #1
0
        public async Task GetReturnsNotFound()
        {
            // Arrange
            _getUserService.Stub(s => s.GetUserById(45))
            .Throw(new BusinessException(Resource.ExceptionUserNotFound));

            var controller = new GetUserController(
                _getUserService);

            // Act
            IHttpActionResult actionResult = await controller.Get(45);
        }
Пример #2
0
        public async Task GetReturnsUserWithSameId()
        {
            // Arrange


            _getUserService.Stub(s => s.GetUserById(45))
            .Return(Task.FromResult <UserDto>(new UserDto {
                Id = 45
            }));


            var controller = new GetUserController(
                _getUserService);

            // Act
            IHttpActionResult actionResult = await controller.Get(45);

            var contentResult = actionResult as OkNegotiatedContentResult <UserDto>;

            // Assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(45, contentResult.Content.Id);
        }