Skip to content

Commit 4828b84

Browse files
Update to mstest 4.0.0 and fix bug in config iterator. (#586)
* Fix most warnings in tests. * Update to mstest 4.0.0. * Fix more warnings. * Fix bug.
1 parent e00d126 commit 4828b84

18 files changed

+124
-213
lines changed

Directory.Packages.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
<PackageVersion Include="$(TileDBNativePackageName)" Version="$(TileDBNativePackageVersion)" />
2828
<PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1" />
2929
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
30-
<PackageVersion Include="MSTest.TestAdapter" Version="3.11.0" />
31-
<PackageVersion Include="MSTest.TestFramework" Version="3.11.0" />
30+
<PackageVersion Include="MSTest.TestAdapter" Version="4.0.0" />
31+
<PackageVersion Include="MSTest.TestFramework" Version="4.0.0" />
3232
<PackageVersion Include="coverlet.collector" Version="6.0.4" PrivateAssets="all" />
3333
<GlobalPackageReference Include="SonarAnalyzer.CSharp" Version="10.11.0.117924" />
3434
<GlobalPackageReference Include="DotNet.ReproducibleBuilds" Version="1.2.25" />

sources/TileDB.CSharp/Config.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ private sealed class Enumerator(Config config, string prefix) : IEnumerator<KeyV
206206

207207
public bool MoveNext()
208208
{
209-
if (!_iterator.Done())
209+
if (_iterator.Done())
210210
{
211211
return false;
212212
}

tests/TileDB.CSharp.Test/ArrayMetadataTest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void TestArrayMetadata()
2222
clearArrayMetadata(tmpArrayPath);
2323
}
2424

25-
private void createArrayMetadataArray(string tmpArrayPath)
25+
private static void createArrayMetadataArray(string tmpArrayPath)
2626
{
2727
var context = Context.GetDefault();
2828

@@ -57,7 +57,7 @@ private void createArrayMetadataArray(string tmpArrayPath)
5757
array.Create(array_schema);
5858
}
5959

60-
private void writeArrayMetadata(string tmpArrayPath)
60+
private static void writeArrayMetadata(string tmpArrayPath)
6161
{
6262
var context = Context.GetDefault();
6363

@@ -79,7 +79,7 @@ private void writeArrayMetadata(string tmpArrayPath)
7979
array.Close();
8080
}
8181

82-
private void readArrayMetadata(string tmpArrayPath)
82+
private static void readArrayMetadata(string tmpArrayPath)
8383
{
8484
var context = Context.GetDefault();
8585

@@ -113,12 +113,12 @@ private void readArrayMetadata(string tmpArrayPath)
113113
Assert.AreEqual("key4", arrayMetadata.key);
114114
Assert.AreEqual(4, arrayMetadata.key.Length);
115115

116-
Assert.AreEqual(4, arrayMetadata.data.Length);
116+
Assert.HasCount(4, arrayMetadata.data);
117117

118118
array.Close();
119119
}
120120

121-
private void clearArrayMetadata(string tmpArrayPath)
121+
private static void clearArrayMetadata(string tmpArrayPath)
122122
{
123123
var context = Context.GetDefault();
124124

tests/TileDB.CSharp.Test/ArraySchemaTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ public void TestArraySchemaInt32DenseHilbert()
179179
array_schema.SetDomain(domain);
180180

181181

182-
Assert.ThrowsException<TileDBException>(() => array_schema.SetCellOrder(LayoutType.Hilbert));
183-
Assert.ThrowsException<TileDBException>(() => array_schema.SetTileOrder(LayoutType.Hilbert));
182+
Assert.ThrowsExactly<TileDBException>(() => array_schema.SetCellOrder(LayoutType.Hilbert));
183+
Assert.ThrowsExactly<TileDBException>(() => array_schema.SetTileOrder(LayoutType.Hilbert));
184184
array_schema.SetCapacity(2);
185185
array_schema.Check();
186186
}

tests/TileDB.CSharp.Test/ArrayTest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void TestDenseArray()
3636

3737
array.Close();
3838

39-
var unixTimestamp = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
39+
var unixTimestamp = (int)DateTime.UtcNow.Subtract(DateTime.UnixEpoch).TotalSeconds;
4040
array.SetOpenTimestampStart((ulong)(unixTimestamp / 1000000));
4141

4242
array.Open(QueryType.Read);
@@ -88,7 +88,7 @@ public void TestSparseArray()
8888

8989
array.Close();
9090

91-
var unixTimestamp = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
91+
var unixTimestamp = (int)DateTime.UtcNow.Subtract(DateTime.UnixEpoch).TotalSeconds;
9292
array.SetOpenTimestampStart((ulong)(unixTimestamp / 1000000));
9393

9494
array.Open(QueryType.Read);
@@ -106,8 +106,8 @@ public void TestSparseArray()
106106
(_, _, isEmpty) = array.NonEmptyDomain<short>(0);
107107
Assert.IsTrue(isEmpty);
108108

109-
Assert.ThrowsException<ArgumentException>(()=>array.NonEmptyDomain<short>("dim2"));
110-
Assert.ThrowsException<ArgumentException>(()=>array.NonEmptyDomain<short>(1));
109+
Assert.ThrowsExactly<ArgumentException>(()=>array.NonEmptyDomain<short>("dim2"));
110+
Assert.ThrowsExactly<ArgumentException>(()=>array.NonEmptyDomain<short>(1));
111111

112112
(_, _, isEmpty) = array.NonEmptyDomain<float>("dim2");
113113
Assert.IsTrue(isEmpty);
@@ -261,7 +261,7 @@ public void TestUpgradeVersion()
261261

262262
using (var schema = Array.LoadArraySchema(context, uri))
263263
{
264-
Assert.IsTrue(schema.FormatVersion() >= 15u, "Array was not upgraded.");
264+
Assert.IsGreaterThanOrEqualTo(15u, schema.FormatVersion(), "Array was not upgraded.");
265265
}
266266
}
267267

tests/TileDB.CSharp.Test/AttributeTest.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void TestNullableAttribute()
6969

7070
attribute.SetNullable(true);
7171

72-
Assert.AreEqual(true, attribute.Nullable());
72+
Assert.IsTrue(attribute.Nullable());
7373
Assert.AreEqual(DataType.Int32, attribute.Type());
7474

7575
// Set and get compressor
@@ -97,7 +97,7 @@ public void TestNullableAttribute()
9797
attribute.SetFillValueNullable(12, true);
9898
var fill_value = attribute.FillValueNullable<int>();
9999
Assert.AreEqual(12, fill_value.Item1[0]);
100-
Assert.AreEqual(true, fill_value.Item2);
100+
Assert.IsTrue(fill_value.Item2);
101101
}
102102

103103
[TestMethod]
@@ -128,7 +128,7 @@ public void TestBoolAttribute()
128128
bool fill_value = true;
129129
attribute.SetFillValue(fill_value);
130130
var value_size = attribute.FillValue<bool>();
131-
Assert.AreEqual(true, value_size[0]);
131+
Assert.IsTrue(value_size[0]);
132132
}
133133

134134
[TestMethod]
@@ -155,7 +155,7 @@ public void TestVarLengthAttribute()
155155
readVarLengthAttributeArray();
156156
}
157157

158-
private void createVarLengthAttributeArray()
158+
private static void createVarLengthAttributeArray()
159159
{
160160
var tmpArrayPath = TestUtil.MakeTestPath("varlength_attributes_array");
161161
if (Directory.Exists(tmpArrayPath))
@@ -197,7 +197,7 @@ private void createVarLengthAttributeArray()
197197
Array.Create(context, tmpArrayPath, array_schema);
198198
}
199199

200-
private void writeVarLengthAttributeArray()
200+
private static void writeVarLengthAttributeArray()
201201
{
202202
var tmpArrayPath = TestUtil.MakeTestPath("varlength_attributes_array");
203203
var context = Context.GetDefault();
@@ -235,7 +235,7 @@ private void writeVarLengthAttributeArray()
235235
array_write.Close();
236236
}
237237

238-
private void readVarLengthAttributeArray()
238+
private static void readVarLengthAttributeArray()
239239
{
240240
var tmpArrayPath = TestUtil.MakeTestPath("varlength_attributes_array");
241241
var context = Context.GetDefault();

tests/TileDB.CSharp.Test/ConfigTest.cs

Lines changed: 6 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -84,112 +84,15 @@ public void ConfigCompare()
8484
[TestMethod]
8585
public void ConfigIterator()
8686
{
87+
const string Prefix = "vfs.s3.";
8788
var config = new Config();
89+
bool sawItem = false;
8890

89-
foreach (var config_entry_pair in config.EnumerateOptions("vfs.s3."))
91+
foreach (var config_entry_pair in config.EnumerateOptions(Prefix))
9092
{
91-
switch (config_entry_pair.Key)
92-
{
93-
case "aws_access_key_id":
94-
Assert.AreEqual("", config_entry_pair.Value);
95-
break;
96-
case "aws_external_id":
97-
Assert.AreEqual("", config_entry_pair.Value);
98-
break;
99-
case "aws_load_frequency":
100-
Assert.AreEqual("", config_entry_pair.Value);
101-
break;
102-
case "aws_role_arn":
103-
Assert.AreEqual("", config_entry_pair.Value);
104-
break;
105-
case "aws_secret_access_key":
106-
Assert.AreEqual("", config_entry_pair.Value);
107-
break;
108-
case "aws_session_name":
109-
Assert.AreEqual("", config_entry_pair.Value);
110-
break;
111-
case "aws_session_token":
112-
Assert.AreEqual("", config_entry_pair.Value);
113-
break;
114-
case "bucket_canned_acl":
115-
Assert.AreEqual("NOT_SET", config_entry_pair.Value);
116-
break;
117-
case "ca_file":
118-
Assert.AreEqual("", config_entry_pair.Value);
119-
break;
120-
case "ca_path":
121-
Assert.AreEqual("", config_entry_pair.Value);
122-
break;
123-
case "connect_max_tries":
124-
Assert.AreEqual("5", config_entry_pair.Value);
125-
break;
126-
case "connect_scale_factor":
127-
Assert.AreEqual("25", config_entry_pair.Value);
128-
break;
129-
case "connect_timeout_ms":
130-
Assert.AreEqual("10800", config_entry_pair.Value);
131-
break;
132-
case "endpoint_override":
133-
Assert.AreEqual("", config_entry_pair.Value);
134-
break;
135-
case "logging_level":
136-
Assert.AreEqual("Off", config_entry_pair.Value);
137-
break;
138-
case "max_parallel_ops":
139-
Assert.AreEqual(Environment.ProcessorCount.ToString(), config_entry_pair.Value);
140-
break;
141-
case "multipart_part_size":
142-
Assert.AreEqual("5242880", config_entry_pair.Value);
143-
break;
144-
case "object_canned_acl":
145-
Assert.AreEqual("NOT_SET", config_entry_pair.Value);
146-
break;
147-
case "proxy_host":
148-
Assert.AreEqual("", config_entry_pair.Value);
149-
break;
150-
case "proxy_password":
151-
Assert.AreEqual("", config_entry_pair.Value);
152-
break;
153-
case "proxy_port":
154-
Assert.AreEqual("0", config_entry_pair.Value);
155-
break;
156-
case "proxy_scheme":
157-
Assert.AreEqual("http", config_entry_pair.Value);
158-
break;
159-
case "proxy_username":
160-
Assert.AreEqual("", config_entry_pair.Value);
161-
break;
162-
case "region":
163-
Assert.AreEqual("us-east-1", config_entry_pair.Value);
164-
break;
165-
case "request_timeout_ms":
166-
Assert.AreEqual("3000", config_entry_pair.Value);
167-
break;
168-
case "requester_pays":
169-
Assert.AreEqual("false", config_entry_pair.Value);
170-
break;
171-
case "scheme":
172-
Assert.AreEqual("https", config_entry_pair.Value);
173-
break;
174-
case "skip_init":
175-
Assert.AreEqual("false", config_entry_pair.Value);
176-
break;
177-
case "sse":
178-
Assert.AreEqual("", config_entry_pair.Value);
179-
break;
180-
case "sse_kms_key_id":
181-
Assert.AreEqual("", config_entry_pair.Value);
182-
break;
183-
case "use_multipart_upload":
184-
Assert.AreEqual("true", config_entry_pair.Value);
185-
break;
186-
case "use_virtual_addressing":
187-
Assert.AreEqual("true", config_entry_pair.Value);
188-
break;
189-
case "verify_ssl":
190-
Assert.AreEqual("true", config_entry_pair.Value);
191-
break;
192-
}
93+
sawItem = true;
94+
Assert.AreEqual(config_entry_pair.Value, config.Get(Prefix + config_entry_pair.Key));
19395
}
96+
Assert.IsTrue(sawItem);
19497
}
19598
}

tests/TileDB.CSharp.Test/ContextTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ public void TestGetChildObjects()
9797
Group.Create(ctx, groupUri);
9898
CreateArray(ctx, arrayUri2);
9999

100-
Assert.AreEqual(2, ctx.GetChildObjects(path, null).Count);
101-
Assert.AreEqual(3, ctx.GetChildObjects(path, WalkOrderType.PreOrder).Count);
102-
Assert.AreEqual(3, ctx.GetChildObjects(path, WalkOrderType.PostOrder).Count);
100+
Assert.HasCount(2, ctx.GetChildObjects(path, null));
101+
Assert.HasCount(3, ctx.GetChildObjects(path, WalkOrderType.PreOrder));
102+
Assert.HasCount(3, ctx.GetChildObjects(path, WalkOrderType.PostOrder));
103103
}
104104

105105
private static void CreateArray(Context ctx, string arrayUri)

0 commit comments

Comments
 (0)