Skip to content

Commit e366720

Browse files
committed
test: ✅ Adds Entry test for adding entry with JSON rte field
1 parent 45bcf4a commit e366720

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Contentstack.Management.Core.Models;
4+
using Contentstack.Management.Core.Utils;
5+
using Contentstack.Management.Core.Tests.Model;
6+
using Microsoft.VisualStudio.TestTools.UnitTesting;
7+
using Newtonsoft.Json;
8+
9+
10+
namespace Contentstack.Management.Core.Tests.IntegrationTest
11+
{
12+
[TestClass]
13+
public class Contentstack007_EntryTest
14+
{
15+
private Stack _stack;
16+
17+
[TestInitialize]
18+
public void Initialize()
19+
{
20+
StackResponse response = StackResponse.getStack(Contentstack.Client.serializer);
21+
_stack = Contentstack.Client.Stack(response.Stack.APIKey);
22+
}
23+
24+
[TestMethod]
25+
[DoNotParallelize]
26+
public async System.Threading.Tasks.Task Test001_Should_Create_Entry()
27+
{
28+
PageJSONRTE pg = new PageJSONRTE()
29+
{
30+
Title = "My First JSON-Rte Entry",
31+
RteData = new Node
32+
{
33+
type = "doc",
34+
children = new List<Node>
35+
{
36+
new Node
37+
{
38+
type = "p",
39+
attrs = new Dictionary<string, object>
40+
{
41+
{"style", new Object() },
42+
{"redactor-attributes", new Object() },
43+
{"dir", "ltr" }
44+
},
45+
children = new List<Node>
46+
{
47+
new TextNode
48+
{
49+
text = "My new text",
50+
attrs = null,
51+
type = "text"
52+
}
53+
}
54+
}
55+
},
56+
attrs = null
57+
}
58+
59+
};
60+
//JsonSerializer js = new JsonSerializer();
61+
//js.Converters.Add(new NodeJsonConverter);
62+
//js.Serialize();
63+
64+
try
65+
{
66+
ContentstackResponse response = await _stack.ContentType("page_json_rte").Entry().CreateAsync(pg);
67+
Assert.AreEqual(System.Net.HttpStatusCode.Created, response.StatusCode);
68+
}catch (Exception e)
69+
{
70+
Assert.Fail(e.Data+ e.Message);
71+
}
72+
}
73+
74+
}
75+
}

0 commit comments

Comments
 (0)