コード例 #1
0
        public async void change_status_should_return_with_response_model()
        {
            //arrange
            var userService = new Mock <IUserService>();

            userService.Setup(x => x.ChangeStatus(1, true)).Returns(() => Task.FromResult(new bool()));

            //act
            var sut = new UserControllerBuilder().WithUserService(userService.Object)
                      .Build();

            var view = await sut.ChangeStatus(1, true);

            //assert
            Assert.NotNull(view);

            var model = view.Data;

            Assert.NotNull(model);
            Assert.IsAssignableFrom(typeof(ResponseModel), model);

            sut.AssertPostAndAntiForgeryTokenAttribute("ChangeStatus", new[] { typeof(int), typeof(bool) });
            userService.Verify(x => x.ChangeStatus(1, true), Times.Once);
        }