-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmbeddedModelMock.cs
More file actions
167 lines (149 loc) · 4.75 KB
/
EmbeddedModelMock.cs
File metadata and controls
167 lines (149 loc) · 4.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
using System.Collections.Generic;
using Contentstack.Utils.Enums;
using Contentstack.Utils.Interfaces;
namespace Contentstack.Utils.Tests.Mocks
{
public class EmbeddedModel : IEntryEmbedable
{
string rte;
public Dictionary<string, List<IEmbeddedObject>> embeddedItems { get; set; }
public EmbeddedModel(string rte, string embedContentUID = "uid", string contentTypeUid = "data-sys-content-type-uid", string embedAssetUID = "uid")
{
this.rte = rte;
embeddedItems = new Dictionary<string, List<IEmbeddedObject>>()
{
["rte"] = new List<IEmbeddedObject> {
new EmbeddedContentTypeUidModel { Uid = embedContentUID, ContentTypeUid = contentTypeUid },
new EmbeddedAssetModel { Uid = embedAssetUID }
}
};
}
}
class Embedded : IEmbeddedObject
{
public string Uid { get; set; }
public string ContentTypeUid { get; set; }
public string renderString(StyleType styleType, string text = null){
switch (styleType) {
case StyleType.Block:
return "<div><p>" + (this.Uid) + "</p><p>Content type: <span>" + this.ContentTypeUid + "</span></p></div>";
case StyleType.Inline:
return "<span>" + this.Uid + "</span>";
case StyleType.Link:
return "<a href=\"" + this.Uid + "\">" + (text ?? this.Uid) + "</a>";
case StyleType.Display:
return "<img src=\""+ this.Uid + "\" alt=\"" + this.Uid + "\" />";
case StyleType.Download:
return "<a href=\"" + this.Uid + "\">" + (text ?? this.Uid) + "</a>";
}
return "";
}
}
public class EmbeddedContentTypeUidModel: IEmbeddedObject
{
public string Uid { get; set; }
public string ContentTypeUid { get; set; }
public string renderString(StyleType styleType, string text = null)
{
switch (styleType)
{
case StyleType.Block:
return "<div><p>" + this.Uid + "</p><p>Content type: <span>" + this.ContentTypeUid + "</span></p></div>";
case StyleType.Inline:
return "<span>" + this.Uid + "</span>";
case StyleType.Link:
return "<a href=\"" + this.Uid + "\">" + (text ?? this.Uid) + "</a>";
default:
break;
}
return "";
}
}
public class EmbeddedEntryModel : IEmbeddedEntry
{
public string Uid { get; set; }
public string ContentTypeUid { get; set; }
public string Title
{
get
{
return "title";
}
set
{
}
}
public string renderString(StyleType styleType, string text = null)
{
switch (styleType)
{
case StyleType.Block:
return "<div><p>" + this.Uid + "</p><p>Content type: <span>" + this.Title + "</span></p></div>";
case StyleType.Inline:
return "<span>" + this.Title + "</span>";
case StyleType.Link:
return "<a href=\"" + this.Uid + "\">" + (text ?? this.Title) + "</a>";
default:
break;
}
return "";
}
}
public class EmbeddedAssetModel : IEmbeddedAsset
{
public string Title
{
get
{
return "title";
}
set
{
}
}
public string FileName
{
get
{
return "filename";
}
set
{
}
}
public string Url
{
get
{
return "url";
}
set
{
}
}
public string ContentTypeUid
{
get
{
return "sys_assets";
}
set
{
}
}
public string Uid { get; set; }
public string renderString(StyleType styleType, string text = null)
{
switch (styleType)
{
case StyleType.Display:
return "<img src=\"" + this.Url + "\" alt=\"" + this.Title + "\" />";
case StyleType.Download:
return "<a href=\"" + this.Url + "\">" + (text ?? this.Title) + "</a>";
default:
break;
}
return "";
}
}
}