Skip to content

Commit edf48f2

Browse files
authored
Move tests to use raw string literals (#34035)
1 parent 3e5e4e4 commit edf48f2

File tree

9 files changed

+530
-448
lines changed

9 files changed

+530
-448
lines changed

sdk/core/Azure.Core.Experimental/tests/DynamicJsonTests.cs

Lines changed: 63 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ public class DynamicJsonTests
1212
[Test]
1313
public void CanGetIntProperty()
1414
{
15-
dynamic jsonData = GetDynamicJson(@"
15+
dynamic jsonData = GetDynamicJson("""
1616
{
17-
""Foo"" : 1
18-
}");
17+
"Foo" : 1
18+
}
19+
""");
1920

2021
int value = jsonData.Foo;
2122

@@ -25,12 +26,13 @@ public void CanGetIntProperty()
2526
[Test]
2627
public void CanGetNestedIntProperty()
2728
{
28-
dynamic jsonData = GetDynamicJson(@"
29+
dynamic jsonData = GetDynamicJson("""
2930
{
30-
""Foo"" : {
31-
""Bar"" : 1
31+
"Foo" : {
32+
"Bar" : 1
3233
}
33-
}");
34+
}
35+
""");
3436

3537
int value = jsonData.Foo.Bar;
3638

@@ -40,10 +42,11 @@ public void CanGetNestedIntProperty()
4042
[Test]
4143
public void CanSetIntProperty()
4244
{
43-
dynamic jsonData = GetDynamicJson(@"
45+
dynamic jsonData = GetDynamicJson("""
4446
{
45-
""Foo"" : 1
46-
}");
47+
"Foo" : 1
48+
}
49+
""");
4750

4851
jsonData.Foo = 2;
4952

@@ -53,12 +56,13 @@ public void CanSetIntProperty()
5356
[Test]
5457
public void CanSetNestedIntProperty()
5558
{
56-
dynamic jsonData = GetDynamicJson(@"
59+
dynamic jsonData = GetDynamicJson("""
5760
{
58-
""Foo"" : {
59-
""Bar"" : 1
61+
"Foo" : {
62+
"Bar" : 1
6063
}
61-
}");
64+
}
65+
""");
6266

6367
jsonData.Foo.Bar = 2;
6468

@@ -68,7 +72,7 @@ public void CanSetNestedIntProperty()
6872
[Test]
6973
public void CanGetArrayValue()
7074
{
71-
dynamic jsonData = GetDynamicJson(@"[0, 1, 2]");
75+
dynamic jsonData = GetDynamicJson("""[0, 1, 2]""");
7276

7377
Assert.AreEqual(0, (int)jsonData[0]);
7478
Assert.AreEqual(1, (int)jsonData[1]);
@@ -78,10 +82,11 @@ public void CanGetArrayValue()
7882
[Test]
7983
public void CanGetNestedArrayValue()
8084
{
81-
dynamic jsonData = GetDynamicJson(@"
85+
dynamic jsonData = GetDynamicJson("""
8286
{
83-
""Foo"": [0, 1, 2]
84-
}");
87+
"Foo": [0, 1, 2]
88+
}
89+
""");
8590

8691
Assert.AreEqual(0, (int)jsonData.Foo[0]);
8792
Assert.AreEqual(1, (int)jsonData.Foo[1]);
@@ -91,31 +96,33 @@ public void CanGetNestedArrayValue()
9196
[Test]
9297
public void CanGetPropertyViaIndexer()
9398
{
94-
dynamic jsonData = GetDynamicJson(@"
99+
dynamic jsonData = GetDynamicJson("""
95100
{
96-
""Foo"" : 1
97-
}");
101+
"Foo" : 1
102+
}
103+
""");
98104

99105
Assert.AreEqual(1, (int)jsonData["Foo"]);
100106
}
101107

102108
[Test]
103109
public void CanGetNestedPropertyViaIndexer()
104110
{
105-
dynamic jsonData = GetDynamicJson(@"
111+
dynamic jsonData = GetDynamicJson("""
106112
{
107-
""Foo"" : {
108-
""Bar"" : 1
113+
"Foo" : {
114+
"Bar" : 1
109115
}
110-
}");
116+
}
117+
""");
111118

112119
Assert.AreEqual(1, (int)jsonData.Foo["Bar"]);
113120
}
114121

115122
[Test]
116123
public void CanSetArrayValues()
117124
{
118-
dynamic jsonData = GetDynamicJson(@"[0, 1, 2]");
125+
dynamic jsonData = GetDynamicJson("""[0, 1, 2]""");
119126

120127
jsonData[0] = 4;
121128
jsonData[1] = 5;
@@ -129,10 +136,11 @@ public void CanSetArrayValues()
129136
[Test]
130137
public void CanSetNestedArrayValues()
131138
{
132-
dynamic jsonData = GetDynamicJson(@"
139+
dynamic jsonData = GetDynamicJson("""
133140
{
134-
""Foo"": [0, 1, 2]
135-
}");
141+
"Foo": [0, 1, 2]
142+
}
143+
""");
136144

137145
jsonData.Foo[0] = 4;
138146
jsonData.Foo[1] = 5;
@@ -146,7 +154,7 @@ public void CanSetNestedArrayValues()
146154
[Test]
147155
public void CanSetArrayValuesToDifferentTypes()
148156
{
149-
dynamic jsonData = GetDynamicJson(@"[0, 1, 2, 3]");
157+
dynamic jsonData = GetDynamicJson("""[0, 1, 2, 3]""");
150158

151159
jsonData[1] = 4;
152160
jsonData[2] = true;
@@ -161,10 +169,11 @@ public void CanSetArrayValuesToDifferentTypes()
161169
[Test]
162170
public void CanSetNestedArrayValuesToDifferentTypes()
163171
{
164-
dynamic jsonData = GetDynamicJson(@"
172+
dynamic jsonData = GetDynamicJson("""
165173
{
166-
""Foo"": [0, 1, 2, 3]
167-
}");
174+
"Foo": [0, 1, 2, 3]
175+
}
176+
""");
168177

169178
jsonData.Foo[1] = 4;
170179
jsonData.Foo[2] = true;
@@ -179,7 +188,7 @@ public void CanSetNestedArrayValuesToDifferentTypes()
179188
[Test]
180189
public void CanGetNullPropertyValue()
181190
{
182-
dynamic jsonData = GetDynamicJson(@"{ ""Foo"" : null }");
191+
dynamic jsonData = GetDynamicJson("""{ "Foo" : null }""");
183192

184193
Assert.IsNull((CustomType)jsonData.Foo);
185194
Assert.IsNull((int?)jsonData.Foo);
@@ -188,7 +197,7 @@ public void CanGetNullPropertyValue()
188197
[Test]
189198
public void CanGetNullArrayValue()
190199
{
191-
dynamic jsonData = GetDynamicJson(@"[ null ]");
200+
dynamic jsonData = GetDynamicJson("""[ null ]""");
192201

193202
Assert.IsNull((CustomType)jsonData[0]);
194203
Assert.IsNull((int?)jsonData[0]);
@@ -197,7 +206,7 @@ public void CanGetNullArrayValue()
197206
[Test]
198207
public void CanSetPropertyValueToNull()
199208
{
200-
dynamic jsonData = GetDynamicJson(@"{ ""Foo"" : null }");
209+
dynamic jsonData = GetDynamicJson("""{ "Foo" : null }""");
201210

202211
jsonData.Foo = null;
203212

@@ -208,7 +217,7 @@ public void CanSetPropertyValueToNull()
208217
[Test]
209218
public void CanSetArrayValueToNull()
210219
{
211-
dynamic jsonData = GetDynamicJson(@"[0]");
220+
dynamic jsonData = GetDynamicJson("""[0]""");
212221

213222
jsonData[0] = null;
214223

@@ -219,10 +228,11 @@ public void CanSetArrayValueToNull()
219228
[Test]
220229
public void CanSetPropertyViaIndexer()
221230
{
222-
dynamic jsonData = GetDynamicJson(@"
231+
dynamic jsonData = GetDynamicJson("""
223232
{
224-
""Foo"" : 1
225-
}");
233+
"Foo" : 1
234+
}
235+
""");
226236

227237
jsonData["Foo"] = 4;
228238

@@ -232,12 +242,13 @@ public void CanSetPropertyViaIndexer()
232242
[Test]
233243
public void CanSetNestedPropertyViaIndexer()
234244
{
235-
dynamic jsonData = GetDynamicJson(@"
245+
dynamic jsonData = GetDynamicJson("""
236246
{
237-
""Foo"" : {
238-
""Bar"" : 1
247+
"Foo" : {
248+
"Bar" : 1
239249
}
240-
}");
250+
}
251+
""");
241252

242253
jsonData["Foo"]["Bar"] = 4;
243254

@@ -247,10 +258,11 @@ public void CanSetNestedPropertyViaIndexer()
247258
[Test]
248259
public void CanAddNewProperty()
249260
{
250-
dynamic jsonData = GetDynamicJson(@"
261+
dynamic jsonData = GetDynamicJson("""
251262
{
252-
""Foo"" : 1
253-
}");
263+
"Foo" : 1
264+
}
265+
""");
254266

255267
jsonData.Bar = 2;
256268

@@ -261,10 +273,11 @@ public void CanAddNewProperty()
261273
[Test]
262274
public void CanMakeChangesAndAddNewProperty()
263275
{
264-
dynamic jsonData = GetDynamicJson(@"
276+
dynamic jsonData = GetDynamicJson("""
265277
{
266-
""Foo"" : 1
267-
}");
278+
"Foo" : 1
279+
}
280+
""");
268281

269282
Assert.AreEqual(1, (int)jsonData.Foo);
270283

sdk/core/Azure.Core.Experimental/tests/JsonDataTests.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,14 @@ public void DynamicCanConvertToIEnumerableInt()
9494
[Test]
9595
public void CanAccessProperties()
9696
{
97-
dynamic jsonData = DynamicJsonTests.GetDynamicJson(@"
97+
dynamic jsonData = DynamicJsonTests.GetDynamicJson("""
9898
{
99-
""primitive"" : ""Hello"",
100-
""nested"" : {
101-
""nestedPrimitive"": true
99+
"primitive" : "Hello",
100+
"nested" : {
101+
"nestedPrimitive": true
102102
}
103-
}");
103+
}
104+
""");
104105

105106
Assert.AreEqual("Hello", (string)jsonData.primitive);
106107
Assert.AreEqual(true, (bool)jsonData.nested.nestedPrimitive);

0 commit comments

Comments
 (0)