コード例 #1
0
        public async Task IShouldCanSeeTheWalletExtract()
        {
            var viewModel = new ExtractViewModel();

            var mockForWalletService = new Mock <IWalletApplicationService>();

            mockForWalletService.Setup(d => d.GetExtract(It.IsAny <string>()))
            .ReturnsAsync(viewModel)
            .Verifiable();

            var mockForHttpContextAccessor = new Mock <IHttpContextAccessor>();

            mockForHttpContextAccessor.Setup(d => d.HttpContext.User.Identity.Name)
            .Returns(It.IsAny <string>())
            .Verifiable();

            var controller = new WalletController(
                mockForWalletService.Object,
                mockForHttpContextAccessor.Object);

            var result = await controller.Extract();

            var resultOk   = result as OkObjectResult;
            var resultData = resultOk.Value as BalanceViewModel;

            Assert.IsInstanceOfType(result, typeof(ActionResult));
            Assert.AreEqual(resultOk.StatusCode, 200);
            mockForWalletService.VerifyAll();
        }