Ejemplo n.º 1
0
        public async void Test_Account_Get_404()
        {
            //setup
            Mock <IAccountServiceV9> serviceMock = new Mock <IAccountServiceV9>();
            AccountV9Controller      controller  = new AccountV9Controller(serviceMock.Object);

            serviceMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new ActionResultV9(false, default(object))));

            //act
            IActionResult result = await controller.Get(default(int));

            //verify
            result.Should().BeOfType <StatusCodeResult>();
            (result as StatusCodeResult).StatusCode.Should().Be(404);
            serviceMock.Verify(x => x.Get(It.IsAny <int>()));
        }
Ejemplo n.º 2
0
        public async void Test_Account_Get_200()
        {
            //setup
            Mock <IAccountServiceV9> serviceMock = new Mock <IAccountServiceV9>();
            AccountV9Controller      controller  = new AccountV9Controller(serviceMock.Object);

            serviceMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new ActionResultV9(true, new AccountResponseModelV9())));

            //act
            IActionResult result = await controller.Get(default(int));

            //verify
            result.Should().BeOfType <OkObjectResult>();
            (result as OkObjectResult).StatusCode.Should().Be(200);
            (result as OkObjectResult).Value.Should().NotBeNull();
            serviceMock.Verify(x => x.Get(It.IsAny <int>()));
        }