public void PassingNullGroupidToAuditControllerResultsBadRequest()
        {
            //Mock data factory
            var datafactory = new Mock <IDataFactory>(MockBehavior.Strict);
            //Mock Authorization
            var authorization = new Mock <IAuthorizationProvider>(MockBehavior.Strict);

            var controller = new AuditController(datafactory.Object, authorization.Object);

            Task <IHttpActionResult> actionResult = controller.GetDataAsync(null, null);

            Assert.IsInstanceOfType(actionResult.Result, typeof(BadRequestResult));
        }
        public void PassingSomeunauthorizableGroupidToAuditControllerGetDataAsyncResultsUnauthorizedResult()
        {
            //Mock data factory
            var datafactory = new Mock <IDataFactory>(MockBehavior.Strict);
            //Mock Authorization
            var authorization = new Mock <IAuthorizationProvider>(MockBehavior.Strict);

            var controller = new AuditController(datafactory.Object, authorization.Object);

            authorization.Setup(m => m.IsAuthorized("1")).Returns(false);

            Task <IHttpActionResult> actionResult = controller.GetDataAsync("1", null);

            Assert.IsInstanceOfType(actionResult.Result, typeof(UnauthorizedResult));
        }
        public void PassingCorrectGroupidToAuditControllerResultsInProcess()
        {
            //Mock Repository
            var repository = new Mock <IPortalRepository>(MockBehavior.Strict);
            //Mock data factory
            var datafactory = new Mock <IDataFactory>(MockBehavior.Strict);
            //Mock Authorization
            var authorization = new Mock <IAuthorizationProvider>(MockBehavior.Strict);

            datafactory.Setup(d => d.GetPortalRepository()).Returns(repository.Object);

            var controller = new AuditController(datafactory.Object, authorization.Object);

            authorization.Setup(m => m.IsAuthorized("11")).Returns(true);
            repository.Setup(x => x.GetDataLoadUploads(11, "", 1))
            .ReturnsAsync(dataloads);

            Task <IHttpActionResult> actionResult = controller.GetDataAsync("11", "", 1);

            Assert.AreEqual(((OkNegotiatedContentResult <List <DataLoadUploads> >)actionResult.Result).Content.Capacity, 1);
        }
        public void PassingInvalidGroupidToAuditControllerResultsUnauthorizedResult()
        {
            //Mock Repository
            var repository = new Mock <IPortalRepository>(MockBehavior.Strict);
            //Mock data factory
            var datafactory = new Mock <IDataFactory>(MockBehavior.Strict);

            //Mock Authorization
            datafactory.Setup(d => d.GetPortalRepository()).Returns(repository.Object);

            var authorization = new Mock <IAuthorizationProvider>(MockBehavior.Strict);

            authorization.Setup(s => s.IsAuthorized(It.IsNotIn <string>(new List <string>()
            {
                "426"
            }))).Returns(false);

            var controller = new AuditController(datafactory.Object, authorization.Object);

            Task <IHttpActionResult> actionResult = controller.GetDataAsync("123", null);

            Assert.IsInstanceOfType(actionResult.Result, typeof(UnauthorizedResult));
        }