public void CreateUserBL_WithParameters_Ok()
        {
            IStyleDataAccess styleDataAccess = new StyleDataAccess();

            IStyleBusinessLogic styleBL = new StyleBusinessLogic(styleDataAccess);

            Assert.IsNotNull(styleBL);
        }
Exemplo n.º 2
0
 public IHttpActionResult Post([FromBody] StyleModel styleModel)
 {
     try
     {
         Utils.IsAValidToken(Request, AuthorizationBusinessLogic);
         Utils.HasAdminPermissions(Request, AuthorizationBusinessLogic);
         StyleBusinessLogic.Add(styleModel.ToEntity());
         return(Ok(styleModel));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Exemplo n.º 3
0
 public IHttpActionResult Get([FromUri] string name)
 {
     try
     {
         Utils.IsAValidToken(Request, AuthorizationBusinessLogic);
         Utils.HasAdminPermissions(Request, AuthorizationBusinessLogic);
         Style style = StyleBusinessLogic.Get(name);
         return(Ok(StyleModel.ToModel(style)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Exemplo n.º 4
0
 public IHttpActionResult Delete([FromUri] String name)
 {
     try
     {
         Utils.IsAValidToken(Request, AuthorizationBusinessLogic);
         Utils.HasAdminPermissions(Request, AuthorizationBusinessLogic);
         StyleBusinessLogic.Delete(name);
         return(Ok("Style deleted"));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Exemplo n.º 5
0
 public IHttpActionResult Get()
 {
     try
     {
         Utils.IsAValidToken(Request, AuthorizationBusinessLogic);
         Utils.HasAdminPermissions(Request, AuthorizationBusinessLogic);
         IList <Style>      styles       = StyleBusinessLogic.Get();
         IList <StyleModel> stylesModels = Utils.ConvertEntitiesToModels(styles);
         return(Ok(stylesModels));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
        public void IntegrationTest()
        {
            Guid token          = Guid.NewGuid();
            var  requestMessage = new HttpRequestMessage();

            requestMessage.Headers.Add("Token", token + "");
            mockUserAuthorizationLogic.Setup(b1 => b1.IsAValidToken(token)).Returns(true);
            mockUserAuthorizationLogic.Setup(b1 => b1.IsAdmin(token)).Returns(true);

            IStyleDataAccess    styleDA         = new StyleDataAccess();
            IStyleBusinessLogic styleBL         = new StyleBusinessLogic(styleDA);
            StyleController     styleController = new StyleController(styleBL, mockUserAuthorizationLogic.Object);

            styleController.Request = requestMessage;

            Style style = Utils.CreateStyleForTest();

            styleController.Post(StyleModel.ToModel(style));
        }
        public void IntegrationTest()
        {
            Guid token          = Guid.NewGuid();
            var  requestMessage = new HttpRequestMessage();

            requestMessage.Headers.Add("Token", token + "");
            mockUserAuthorizationLogic.Setup(b1 => b1.IsAValidToken(token)).Returns(true);
            mockUserAuthorizationLogic.Setup(b1 => b1.IsAdmin(token)).Returns(true);

            IStyleDataAccess         styleDA              = new StyleDataAccess();
            IStyleBusinessLogic      styleBL              = new StyleBusinessLogic(styleDA);
            IStyleClassDataAccess    styleClassDA         = new StyleClassDataAccess();
            IStyleClassBusinessLogic styleClassBL         = new StyleClassBusinessLogic(styleClassDA, styleBL);
            StyleClassController     styleClassController = new StyleClassController(styleClassBL, mockUserAuthorizationLogic.Object);

            styleClassController.Request = requestMessage;

            StyleClass      styleClassA = Utils.CreateStyleClassForTest();
            StyleClassModel styleClassM = StyleClassModel.ToModel(styleClassA);

            styleClassM.InheritedPlusProperStyles = new List <StyleModel>();
            styleClassController.Post(styleClassM);
        }
        public void IntegrationTest()
        {
            Guid token          = Guid.NewGuid();
            var  requestMessage = new HttpRequestMessage();

            requestMessage.Headers.Add("Token", token + "");
            mockUserAuthorizationLogic.Setup(b1 => b1.IsAValidToken(token)).Returns(true);
            mockUserAuthorizationLogic.Setup(b1 => b1.IsAdmin(token)).Returns(true);

            IStyleDataAccess         styleDA      = new StyleDataAccess();
            IStyleBusinessLogic      styleBL      = new StyleBusinessLogic(styleDA);
            IStyleClassDataAccess    styleClassDA = new StyleClassDataAccess();
            IStyleClassBusinessLogic styleClassBL = new StyleClassBusinessLogic(styleClassDA, styleBL);
            IFormatDataAccess        formatDA     = new FormatDataAccess();
            IFormatBusinessLogic     formatBL     = new FormatBusinessLogic(formatDA, styleClassBL);
            FormatController         formatC      = new FormatController(formatBL, mockUserAuthorizationLogic.Object);

            formatC.Request = requestMessage;

            Format      formatA      = Utils.CreateFormatForTest();
            FormatModel formatModelA = FormatModel.ToModel(formatA);

            formatC.Post(formatModelA);
        }
        public void integration()
        {
            var                         requestMessage = new HttpRequestMessage();
            IUserDataAccess             da             = new UserDataAccess();
            IUserBusinessLogic          userBL         = new UserBusinessLogic(new UserDataAccess());
            IAuthorizationBusinessLogic auth           = new AuthorizationBusinessLogic(da);
            IStyleDataAccess            styleDA        = new StyleDataAccess();
            IStyleBusinessLogic         styleBL        = new StyleBusinessLogic(styleDA);
            IStyleClassDataAccess       styleClassDA   = new StyleClassDataAccess();
            IStyleClassBusinessLogic    styleClassBL   = new StyleClassBusinessLogic(styleClassDA, styleBL);
            IFormatDataAccess           formatDA       = new FormatDataAccess();
            IFormatBusinessLogic        formatBL       = new FormatBusinessLogic(formatDA, styleClassBL);
            FormatController            formatC        = new FormatController(formatBL, auth);

            formatC.Request = requestMessage;
            StyleClass  styleClassA  = Utils.CreateStyleClassInDataBaseForTest();
            Format      formatA      = Utils.CreateFormatForTest();
            FormatModel formatModelA = FormatModel.ToModel(formatA);

            formatC.Post(formatModelA);
            formatC.AddStyleClassToFormat(formatA.Id, StyleClassModel.ToModel(styleClassA));
            IHttpActionResult statusObtained = formatC.Get(formatA.Id);
            int a = 2;
        }
        public void CreateStyleBL_WithoutParameters_Ok()
        {
            IStyleBusinessLogic StyleBL = new StyleBusinessLogic();

            Assert.IsNotNull(StyleBL);
        }