public void PassingNullGroupidToAuditControllerGetErrorDataAsyncResultsBadRequest()
        {
            //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.GetErrorDataAsync(null, null);

            Assert.IsInstanceOfType(actionResult.Result, typeof(BadRequestResult));
        }
        public void PassingSomeUnauthorizableGroupidToAuditControllerGetErrorDataAsyncResultsUnauthorizedResult()
        {
            //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.GetErrorDataAsync("1", null);

            Assert.IsInstanceOfType(actionResult.Result, typeof(UnauthorizedResult));
        }
        public void PassingCorrectGroupidToAuditControllerGetErrorDataAsyncResultsInProcess()
        {
            //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.GetDataLoadErrors(11, ""))
            .ReturnsAsync(errors);

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

            Assert.AreEqual(((OkNegotiatedContentResult <List <ErrorModel> >)actionResult.Result).Content.Capacity, 1);
        }
        public void PassingInvalidGroupidToAuditControllerGetErrorDataAsyncResultsUnauthorizedResult()
        {
            //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.GetErrorDataAsync("123", "");

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