예제 #1
0
        public async Task GetBranchesSimple()
        {
            var branch = new BranchSimple()
            {
                Id   = Guid.NewGuid(),
                Name = "Branch1"
            };

            var branches = new List <BranchSimple>()
            {
                branch
            };

            var service     = new Mock <IBranchService>();
            var authService = TestHelper.MockAuthenticationService(Scope.Branch);

            ScopeOptions queryOptions = null;

            service.Setup(c => c.GetBranchesSimple(It.IsAny <ScopeOptions>()))
            .Callback((ScopeOptions options) => queryOptions = options)
            .ReturnsAsync(branches);

            var controller = new BranchesController(service.Object, authService.Object);

            controller.ControllerContext = TestHelper.GetControllerContext(new ClaimsPrincipal());

            var result = await controller.GetBranchesSimple();

            var okResult    = Assert.IsType <OkObjectResult>(result);
            var returnValue = Assert.IsType <List <BranchSimple> >(okResult.Value);

            Assert.Same(branches, returnValue);
        }