public void PreviewComment_Add_Empty() { var comments = PreviewCommentActions.AddPreviewComment(null, "user", 1, 1, 1, null, out var comment); Assert.IsNull(comments.Single()["text"].Value <string>()); Assert.IsNull(comment.Text); }
public void PreviewComment_Add_Order() { const string commentsValue = "[{ \"id\": \"abc\", \"page\": 1, \"x\": 100, \"y\": 100, \"creationDate\": \"2019.02.28. 8:00:00\" }, " + " { \"id\": \"def\", \"page\": 2, \"x\": 30.5, \"y\": 30.5, \"creationDate\": \"2019.02.28. 9:00:00\" }," + " { \"id\": \"ghi\", \"page\": 2, \"x\": 70.5, \"y\": 70.5, \"creationDate\": \"2019.02.28. 5:00:00\" }," + " { \"id\": \"jkl\", \"page\": 2, \"x\": 70, \"y\": 70, \"creationDate\": \"2019.02.28. 6:00:00\" }," + " { \"id\": \"mno\", \"page\": 3, \"x\": 70, \"y\": 70, \"creationDate\": \"2010.01.01. 1:00:00\" }," + "]"; AssertCommentOrder(2, 20, 20, 1); AssertCommentOrder(2, 20, 30, 1); AssertCommentOrder(2, 30.5, 30.5, 2); AssertCommentOrder(2, 30.7, 30.7, 2); AssertCommentOrder(2, 50, 50, 2); AssertCommentOrder(2, 70.8, 90, 4); void AssertCommentOrder(int page, double x, double y, int expectedIndex) { var comments = PreviewCommentActions.AddPreviewComment(commentsValue, "user", page, x, y, "commentx", out _); Assert.AreEqual(6, comments.Count); Assert.AreEqual("commentx", comments[expectedIndex]?["text"]?.Value <string>() ?? string.Empty, $"Incorrect index. Expected: {expectedIndex}."); } }
public void PreviewComment_Add_Long() { // add a comment that contains more characters than it is allowed var comments = PreviewCommentActions.AddPreviewComment(null, "user", 1, 1, 1, new string('*', 501), out var comment); Assert.AreEqual(500, comments.Single()["text"].Value <string>().Length); Assert.AreEqual(500, comment.Text.Length); Assert.IsTrue(comment.Text.StartsWith("*************")); }
public void PreviewComment_Add_New() { var comments = PreviewCommentActions.AddPreviewComment("[{ \"id\": \"abc\" }]", "user", 11, 12, 13, "def", out var comment); Assert.AreEqual(2, comments.Count); Assert.AreEqual("def", comments.Last()["text"].Value <string>()); Assert.AreEqual("def", comment.Text); Assert.AreEqual("user", comment.CreatedBy); Assert.AreEqual(11, comment.Page); Assert.AreEqual(12, comment.X); Assert.AreEqual(13, comment.Y); }
public void PreviewComment_Add_PageError() { PreviewCommentActions.AddPreviewComment(null, "user", -1, -1, -1, null, out var _); }
public void PreviewComment_Add_UserError() { PreviewCommentActions.AddPreviewComment(null, null, 1, 1, 1, null, out var _); }