Skip to content

Commit 80fc5c9

Browse files
committed
test: Fixed tests.
1 parent 305ca8b commit 80fc5c9

File tree

2 files changed

+33
-37
lines changed

2 files changed

+33
-37
lines changed

src/libs/AutoSDK/Helpers/Box.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
namespace AutoSDK.Helpers;
22

3-
public static class BoxEtensions
3+
public static class BoxExtensions
44
{
55
public static T Unbox<T>(this Box box)
66
{
77
return (T)box.Value;
88
}
9-
public static Box Box<T>(this T tobox)
9+
public static Box Box<T>(this T value) where T : notnull
1010
{
11-
return new Box() { Value = tobox };
11+
return new Box { Value = value };
1212
}
1313
}
1414

@@ -21,12 +21,7 @@ public static Box Box<T>(this T tobox)
2121
/// </summary>
2222
public struct Box : IEquatable<Box>
2323
{
24-
private object _value;
25-
public object Value
26-
{
27-
get => _value;
28-
set => _value = value;
29-
}
24+
public object Value { get; set; }
3025

3126
public override bool Equals(object? obj)
3227
{

src/tests/AutoSDK.UnitTests/JsonTests.JsonSerializerContextTypes.cs

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Immutable;
2+
using AutoSDK.Helpers;
23
using AutoSDK.Models;
34
using static AutoSDK.Serialization.Json.SystemTextJsonSerializer;
45

@@ -15,7 +16,7 @@ public void ContextTypes()
1516
CSharpTypeRaw = "global::System.Collections.Generic.IList<string>",
1617
IsArray = true,
1718
SubTypes = ImmutableArray.Create([
18-
TypeData.Default with { CSharpTypeRaw = "string" }
19+
(TypeData.Default with { CSharpTypeRaw = "string" }).Box(),
1920
]),
2021
}, makeNullableRootIfValueType: true).Should().Be("IListString");
2122

@@ -24,8 +25,8 @@ public void ContextTypes()
2425
Namespace = "System.Collections.Generic",
2526
CSharpTypeRaw = "global::System.Collections.Generic.Dictionary<string, int>",
2627
SubTypes = ImmutableArray.Create([
27-
TypeData.Default with { CSharpTypeRaw = "string" },
28-
TypeData.Default with { CSharpTypeRaw = "int" }
28+
(TypeData.Default with { CSharpTypeRaw = "string" }).Box(),
29+
(TypeData.Default with { CSharpTypeRaw = "int" }).Box()
2930
]),
3031
}, makeNullableRootIfValueType: true).Should().Be("DictionaryStringInt32");
3132

@@ -35,14 +36,14 @@ public void ContextTypes()
3536
CSharpTypeRaw = "global::System.Collections.Generic.IList<global::System.Collections.Generic.IList<string>>",
3637
IsArray = true,
3738
SubTypes = ImmutableArray.Create([
38-
TypeData.Default with
39+
(TypeData.Default with
3940
{
4041
CSharpTypeRaw = "global::System.Collections.Generic.IList<string>",
4142
IsArray = true,
4243
SubTypes = ImmutableArray.Create([
43-
TypeData.Default with { CSharpTypeRaw = "string" }
44+
(TypeData.Default with { CSharpTypeRaw = "string" }).Box()
4445
]),
45-
}
46+
}).Box()
4647
]),
4748
}, makeNullableRootIfValueType: true).Should().Be("IListIListString");
4849

@@ -52,9 +53,9 @@ TypeData.Default with
5253
CSharpTypeRaw = "global::System.Collections.Generic.IList<global::System.Guid>",
5354
IsArray = true,
5455
SubTypes = ImmutableArray.Create([
55-
TypeData.Default with {
56+
(TypeData.Default with {
5657
Namespace = "System",
57-
CSharpTypeRaw = "global::System.Guid" }
58+
CSharpTypeRaw = "global::System.Guid" }).Box()
5859
]),
5960
}, makeNullableRootIfValueType: true).Should().Be("IListGuid");
6061

@@ -63,7 +64,7 @@ TypeData.Default with {
6364
CSharpTypeRaw = "byte[]",
6465
IsBinary = true,
6566
SubTypes = ImmutableArray.Create([
66-
TypeData.Default with { CSharpTypeRaw = "byte" }
67+
(TypeData.Default with { CSharpTypeRaw = "byte" }).Box()
6768
]),
6869
}, makeNullableRootIfValueType: true).Should().Be("ByteArray");
6970

@@ -72,14 +73,14 @@ TypeData.Default with {
7273
CSharpTypeRaw = "byte[][]",
7374
IsBinary = true,
7475
SubTypes = ImmutableArray.Create([
75-
TypeData.Default with
76+
(TypeData.Default with
7677
{
7778
CSharpTypeRaw = "byte[]",
7879
IsBinary = true,
7980
SubTypes = ImmutableArray.Create([
80-
TypeData.Default with { CSharpTypeRaw = "byte" }
81+
(TypeData.Default with { CSharpTypeRaw = "byte" }).Box()
8182
]),
82-
}
83+
}).Box()
8384
]),
8485
}, makeNullableRootIfValueType: true).Should().Be("ByteArrayArray");
8586

@@ -88,14 +89,14 @@ TypeData.Default with
8889
CSharpTypeRaw = "global::System.Collections.Generic.IList<byte[]>",
8990
IsArray = true,
9091
SubTypes = ImmutableArray.Create([
91-
TypeData.Default with
92+
(TypeData.Default with
9293
{
9394
CSharpTypeRaw = "byte[]",
9495
IsBinary = true,
9596
SubTypes = ImmutableArray.Create([
96-
TypeData.Default with { CSharpTypeRaw = "byte" }
97+
(TypeData.Default with { CSharpTypeRaw = "byte" }).Box()
9798
]),
98-
}
99+
}).Box()
99100
]),
100101
}, makeNullableRootIfValueType: true).Should().Be("IListByteArray");
101102

@@ -105,15 +106,15 @@ TypeData.Default with
105106
IsValueType = true,
106107
CSharpTypeRaw = "global::G.AllOf<Integration?, AppsCreateFromManifestResponse>",
107108
SubTypes = ImmutableArray.Create([
108-
TypeData.Default with
109+
(TypeData.Default with
109110
{
110111
CSharpTypeRaw = "Integration",
111112
CSharpTypeNullability = true,
112-
},
113-
TypeData.Default with
113+
}).Box(),
114+
(TypeData.Default with
114115
{
115116
CSharpTypeRaw = "AppsCreateFromManifestResponse"
116-
},
117+
}).Box(),
117118
]),
118119
}, makeNullableRootIfValueType: true).Should().Be("NullableAllOfIntegrationAppsCreateFromManifestResponse");
119120

@@ -123,18 +124,18 @@ TypeData.Default with
123124
IsValueType = true,
124125
CSharpTypeRaw = "global::Cohere.OneOf<global::Cohere.NonStreamedChatResponse, global::Cohere.StreamedChatResponse?>",
125126
SubTypes = ImmutableArray.Create([
126-
TypeData.Default with
127+
(TypeData.Default with
127128
{
128129
Namespace = "Cohere",
129130
CSharpTypeRaw = "global::Cohere.NonStreamedChatResponse"
130-
},
131-
TypeData.Default with
131+
}).Box(),
132+
(TypeData.Default with
132133
{
133134
Namespace = "Cohere",
134135
CSharpTypeRaw = "global::Cohere.StreamedChatResponse",
135136
CSharpTypeNullability = true,
136137
IsValueType = true,
137-
}
138+
}).Box()
138139
]),
139140
}, makeNullableRootIfValueType: true).Should().Be("NullableOneOfNonStreamedChatResponseNullableStreamedChatResponse");
140141

@@ -149,21 +150,21 @@ TypeData.Default with
149150
CSharpTypeRaw = "global::System.Collections.Generic.IList<byte[][]>",
150151
IsArray = true,
151152
SubTypes = ImmutableArray.Create([
152-
TypeData.Default with
153+
(TypeData.Default with
153154
{
154155
CSharpTypeRaw = "byte[][]",
155156
IsBinary = true,
156157
SubTypes = ImmutableArray.Create([
157-
TypeData.Default with
158+
(TypeData.Default with
158159
{
159160
CSharpTypeRaw = "byte[]",
160161
IsBinary = true,
161162
SubTypes = ImmutableArray.Create([
162-
TypeData.Default with { CSharpTypeRaw = "byte" }
163+
(TypeData.Default with { CSharpTypeRaw = "byte" }).Box()
163164
]),
164-
}
165+
}).Box()
165166
]),
166-
}
167+
}).Box()
167168
]),
168169
}, makeNullableRootIfValueType: true).Should().Be("IListByteArrayArray");
169170
}

0 commit comments

Comments
 (0)