public void PostTextMargin_BadRequest_Exception() { mockMarginBusinessLogic.Setup(b1 => b1.SetText(margin.Id, text)).Throws(new Exception()); IHttpActionResult statusObtained = marginController.Put(margin.Id, TextModel.ToModel(text)); Assert.IsNull(statusObtained as OkNegotiatedContentResult <TextModel>); }
public void PostTextMargin_ExpectedParameters_Ok() { mockMarginBusinessLogic.Setup(b1 => b1.SetText(margin.Id, text)); mockMarginBusinessLogic.Setup(b1 => b1.GetMargin(margin.Id)).Returns(new Margin() { DocumentId = Guid.NewGuid() }); IHttpActionResult statusObtained = marginController.Put(margin.Id, TextModel.ToModel(text)); Assert.IsNotNull(statusObtained as CreatedAtRouteNegotiatedContentResult <TextModel>); }
public void TestInitialize() { text = Utils.CreateTextForTest(); textModel = TextModel.ToModel(text); mockTextAuthorizationLogic = new Mock <IAuthorizationBusinessLogic>(); mockTextBusinessLogic = new Mock <ITextBusinessLogic>(); mockAuditLogBusinessLogic = new Mock <IAuditLogBussinesLogic>(); user = Utils.CreateUserForTest(); userModel = UserModel.ToModel(user); textController = new TextController(mockTextBusinessLogic.Object, mockTextAuthorizationLogic.Object, mockAuditLogBusinessLogic.Object); InitializeToken(); }
public IHttpActionResult Get([FromUri] Guid id) { try { Utils.IsAValidToken(Request, AuthorizationBusinessLogic); var text = TextBusinessLogic.GetText(id); return(Ok(TextModel.ToModel(text))); } catch (Exception e) { return(BadRequest(e.Message)); } }
public IHttpActionResult Get([FromUri] Guid paragraphId, [FromUri] int position) { try { Utils.IsAValidToken(Request, AuthorizationBusinessLogic); var texts = ParagraphBusinessLogic.GetTextAt(paragraphId, position); return(Ok(TextModel.ToModel(texts))); } catch (Exception e) { return(BadRequest(e.Message)); } }
public void TestInitialize() { paragraph = Utils.CreateParagraphForTest(); paragraphModel = ParagraphModel.ToModel(paragraph); text = Utils.CreateTextForTest(); textModel = TextModel.ToModel(text); user = Utils.CreateUserForTest(); userModel = UserModel.ToModel(user); mockParagraphAuthorizationLogic = new Mock <IAuthorizationBusinessLogic>(); mockParagraphBusinessLogic = new Mock <IParagraphBusinessLogic>(); mockAuditLogBusinessLogic = new Mock <IAuditLogBussinesLogic>(); paragraphController = new ParagraphController(mockParagraphBusinessLogic.Object, mockParagraphAuthorizationLogic.Object, mockAuditLogBusinessLogic.Object); InitializeToken(); }
public void TestInitialize() { margin = Utils.CreateMarginForTest(); marginModel = MarginModel.ToModel(margin); text = Utils.CreateTextForTest(); textModel = TextModel.ToModel(text); user = Utils.CreateUserForTest(); userModel = UserModel.ToModel(user); mockMarginAuthorizationLogic = new Mock <IAuthorizationBusinessLogic>(); mockMarginBusinessLogic = new Mock <IMarginBusinessLogic>(); mockAuditLogBusinessLogic = new Mock <IAuditLogBussinesLogic>(); marginController = new MarginController(mockMarginBusinessLogic.Object, mockMarginAuthorizationLogic.Object, mockAuditLogBusinessLogic.Object); InitializeToken(); }
public IHttpActionResult Get() { try { Utils.IsAValidToken(Request, AuthorizationBusinessLogic); var texts = TextBusinessLogic.GetTexts(); IList <TextModel> textsModel = TextModel.ToModel(texts).ToList(); return(Ok(textsModel)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public void IntegrationTest_ExpectedParameters_Ok() { var requestMessage = new HttpRequestMessage(); ITextBusinessLogic textBL = new TextBusinessLogic(new TextDataAccess()); IUserDataAccess userDa = new UserDataAccess(); IAuthorizationBusinessLogic auth = new AuthorizationBusinessLogic(userDa); IAuditLogBussinesLogic audit = new AuditLogBussinesLogic(); TextController textC = new TextController(textBL, auth, audit); textC.Request = requestMessage; TextModel text2 = TextModel.ToModel(Utils.CreateTextForTest()); textC.Post(textModel); textC.Post(text2); text2.TextContent = "modified"; textC.Put(text2.Id, text2); textC.Delete(textModel.Id); IHttpActionResult statusObtained = textC.Get(); }