Ejemplo n.º 1
0
        public async Task UserControllerTest_Find_returnInternalServerError()
        {
            // Arrange
            _userStore.Setup(x => x.SearchUser(It.IsAny <string>())).Throws(new Exception("asd"));

            // Act
            var controller = new UserApiController(_userStore.Object);
            var res        = await controller.Find("jonathan");

            // Assert
            _userStore.Verify(x => x.SearchUser(It.IsAny <string>()));
            Assert.IsInstanceOfType(res, typeof(ExceptionResult));
        }
Ejemplo n.º 2
0
        public async Task UserControllerTest_Find_returnsOk()
        {
            // Arrange
            _userStore.Setup(x => x.SearchUser(It.IsAny <string>())).Returns(Task.FromResult <IEnumerable <IAzureUser> >(new List <IAzureUser>
            {
                new UserViewModel(),
                new UserViewModel(),
            }));

            // Act
            var controller = new UserApiController(_userStore.Object);
            var res        = await controller.Find("jonathan") as OkNegotiatedContentResult <List <UserViewModel> >;

            // Assert
            _userStore.Verify(x => x.SearchUser(It.IsAny <string>()));
            Assert.IsNotNull(res);
            Assert.AreEqual(res.Content.Count(), 2);
        }