Example #1
0
        public async Task Get()
        {
            var branch = new Branch()
            {
                Id             = Guid.NewGuid(),
                OrganisationId = Guid.NewGuid(),
                Name           = "Branch1"
            };

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

            service.Setup(c => c.GetBranch(It.IsAny <ScopeOptions>(), It.Is <Guid>(m => m == branch.Id.Value)))
            .ReturnsAsync(branch);

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

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

            var result = await controller.Get(branch.Id.Value);

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

            Assert.Same(branch, returnValue);
        }
Example #2
0
        public void Get_calls_dataProvider_and_returns_apiresponse()
        {
            //  Arrange
            var data = new List <BranchDTO>();

            _dataProvider.GetAllBranches().Returns(data);

            //  Act
            var result = _controller.Get();

            //  Assert
            _dataProvider.Received(1).GetAllBranches();
            Assert.IsInstanceOf <OkNegotiatedContentResult <ApiResponse <IList <BranchDTO> > > >(result);
        }