internal static IList <FormatModel> ConvertEntitiesToModels(IList <Format> formats) { IList <FormatModel> formatsModels = new List <FormatModel>(); foreach (Format format in formats) { formatsModels.Add(FormatModel.ToModel(format)); } return(formatsModels); }
public void TestInitialize() { styleClass = Utils.CreateStyleClassForTest(); format = Utils.CreateFormatForTest(); formatModel = FormatModel.ToModel(format); mockUserAuthorizationLogic = new Mock <IAuthorizationBusinessLogic>(); mockFormatsBusinessLogic = new Mock <IFormatBusinessLogic>(); formatController = new FormatController(mockFormatsBusinessLogic.Object, mockUserAuthorizationLogic.Object); InitializeToken(); }
public IHttpActionResult Get([FromUri] Guid id) { try { Utils.IsAValidToken(Request, AuthorizationBusinessLogic); Utils.HasAdminPermissions(Request, AuthorizationBusinessLogic); Format format = FormatBusinessLogic.Get(id); return(Ok(FormatModel.ToModel(format))); } 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); 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; }