Skip to content

Commit be7f273

Browse files
authored
test: Fix up xunit warnings (#237)
## This PR Supress ConfigureAwait for unit tests as its not relevant, cleanup warnings ![image](https://github.com/open-feature/dotnet-sdk/assets/2031163/6dd21810-3938-4f81-a226-ce785951984e) Signed-off-by: Benjamin Evenson <[email protected]>
1 parent fd0a541 commit be7f273

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

test/OpenFeature.Tests/Providers/Memory/InMemoryProviderTests.cs

+19-20
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
using System;
21
using System.Collections.Generic;
3-
using System.Collections.Immutable;
4-
using System.Threading;
2+
using System.Diagnostics.CodeAnalysis;
53
using OpenFeature.Constant;
64
using OpenFeature.Error;
75
using OpenFeature.Model;
86
using OpenFeature.Providers.Memory;
97
using Xunit;
108

11-
namespace OpenFeature.Tests
9+
namespace OpenFeature.Tests.Providers.Memory
1210
{
11+
[SuppressMessage("Reliability", "CA2007:Consider calling ConfigureAwait on the awaited task")]
1312
public class InMemoryProviderTests
1413
{
1514
private FeatureProvider commonProvider;
@@ -112,7 +111,7 @@ public InMemoryProviderTests()
112111
[Fact]
113112
public async void GetBoolean_ShouldEvaluateWithReasonAndVariant()
114113
{
115-
ResolutionDetails<bool> details = await this.commonProvider.ResolveBooleanValue("boolean-flag", false, EvaluationContext.Empty).ConfigureAwait(false);
114+
ResolutionDetails<bool> details = await this.commonProvider.ResolveBooleanValue("boolean-flag", false, EvaluationContext.Empty);
116115
Assert.True(details.Value);
117116
Assert.Equal(Reason.Static, details.Reason);
118117
Assert.Equal("on", details.Variant);
@@ -121,7 +120,7 @@ public async void GetBoolean_ShouldEvaluateWithReasonAndVariant()
121120
[Fact]
122121
public async void GetString_ShouldEvaluateWithReasonAndVariant()
123122
{
124-
ResolutionDetails<string> details = await this.commonProvider.ResolveStringValue("string-flag", "nope", EvaluationContext.Empty).ConfigureAwait(false);
123+
ResolutionDetails<string> details = await this.commonProvider.ResolveStringValue("string-flag", "nope", EvaluationContext.Empty);
125124
Assert.Equal("hi", details.Value);
126125
Assert.Equal(Reason.Static, details.Reason);
127126
Assert.Equal("greeting", details.Variant);
@@ -130,7 +129,7 @@ public async void GetString_ShouldEvaluateWithReasonAndVariant()
130129
[Fact]
131130
public async void GetInt_ShouldEvaluateWithReasonAndVariant()
132131
{
133-
ResolutionDetails<int> details = await this.commonProvider.ResolveIntegerValue("integer-flag", 13, EvaluationContext.Empty).ConfigureAwait(false);
132+
ResolutionDetails<int> details = await this.commonProvider.ResolveIntegerValue("integer-flag", 13, EvaluationContext.Empty);
134133
Assert.Equal(10, details.Value);
135134
Assert.Equal(Reason.Static, details.Reason);
136135
Assert.Equal("ten", details.Variant);
@@ -139,7 +138,7 @@ public async void GetInt_ShouldEvaluateWithReasonAndVariant()
139138
[Fact]
140139
public async void GetDouble_ShouldEvaluateWithReasonAndVariant()
141140
{
142-
ResolutionDetails<double> details = await this.commonProvider.ResolveDoubleValue("float-flag", 13, EvaluationContext.Empty).ConfigureAwait(false);
141+
ResolutionDetails<double> details = await this.commonProvider.ResolveDoubleValue("float-flag", 13, EvaluationContext.Empty);
143142
Assert.Equal(0.5, details.Value);
144143
Assert.Equal(Reason.Static, details.Reason);
145144
Assert.Equal("half", details.Variant);
@@ -148,7 +147,7 @@ public async void GetDouble_ShouldEvaluateWithReasonAndVariant()
148147
[Fact]
149148
public async void GetStruct_ShouldEvaluateWithReasonAndVariant()
150149
{
151-
ResolutionDetails<Value> details = await this.commonProvider.ResolveStructureValue("object-flag", new Value(), EvaluationContext.Empty).ConfigureAwait(false);
150+
ResolutionDetails<Value> details = await this.commonProvider.ResolveStructureValue("object-flag", new Value(), EvaluationContext.Empty);
152151
Assert.Equal(true, details.Value.AsStructure["showImages"].AsBoolean);
153152
Assert.Equal("Check out these pics!", details.Value.AsStructure["title"].AsString);
154153
Assert.Equal(100, details.Value.AsStructure["imagesPerPage"].AsInteger);
@@ -160,7 +159,7 @@ public async void GetStruct_ShouldEvaluateWithReasonAndVariant()
160159
public async void GetString_ContextSensitive_ShouldEvaluateWithReasonAndVariant()
161160
{
162161
EvaluationContext context = EvaluationContext.Builder().Set("email", "[email protected]").Build();
163-
ResolutionDetails<string> details = await this.commonProvider.ResolveStringValue("context-aware", "nope", context).ConfigureAwait(false);
162+
ResolutionDetails<string> details = await this.commonProvider.ResolveStringValue("context-aware", "nope", context);
164163
Assert.Equal("INTERNAL", details.Value);
165164
Assert.Equal(Reason.TargetingMatch, details.Reason);
166165
Assert.Equal("internal", details.Variant);
@@ -170,32 +169,32 @@ public async void GetString_ContextSensitive_ShouldEvaluateWithReasonAndVariant(
170169
public async void EmptyFlags_ShouldWork()
171170
{
172171
var provider = new InMemoryProvider();
173-
await provider.UpdateFlags().ConfigureAwait(false);
172+
await provider.UpdateFlags();
174173
Assert.Equal("InMemory", provider.GetMetadata().Name);
175174
}
176175

177176
[Fact]
178177
public async void MissingFlag_ShouldThrow()
179178
{
180-
await Assert.ThrowsAsync<FlagNotFoundException>(() => commonProvider.ResolveBooleanValue("missing-flag", false, EvaluationContext.Empty)).ConfigureAwait(false);
179+
await Assert.ThrowsAsync<FlagNotFoundException>(() => this.commonProvider.ResolveBooleanValue("missing-flag", false, EvaluationContext.Empty));
181180
}
182181

183182
[Fact]
184183
public async void MismatchedFlag_ShouldThrow()
185184
{
186-
await Assert.ThrowsAsync<TypeMismatchException>(() => commonProvider.ResolveStringValue("boolean-flag", "nope", EvaluationContext.Empty)).ConfigureAwait(false);
185+
await Assert.ThrowsAsync<TypeMismatchException>(() => this.commonProvider.ResolveStringValue("boolean-flag", "nope", EvaluationContext.Empty));
187186
}
188187

189188
[Fact]
190189
public async void MissingDefaultVariant_ShouldThrow()
191190
{
192-
await Assert.ThrowsAsync<GeneralException>(() => commonProvider.ResolveBooleanValue("invalid-flag", false, EvaluationContext.Empty)).ConfigureAwait(false);
191+
await Assert.ThrowsAsync<GeneralException>(() => this.commonProvider.ResolveBooleanValue("invalid-flag", false, EvaluationContext.Empty));
193192
}
194193

195194
[Fact]
196195
public async void MissingEvaluatedVariant_ShouldThrow()
197196
{
198-
await Assert.ThrowsAsync<GeneralException>(() => commonProvider.ResolveBooleanValue("invalid-evaluator-flag", false, EvaluationContext.Empty)).ConfigureAwait(false);
197+
await Assert.ThrowsAsync<GeneralException>(() => this.commonProvider.ResolveBooleanValue("invalid-evaluator-flag", false, EvaluationContext.Empty));
199198
}
200199

201200
[Fact]
@@ -212,7 +211,7 @@ public async void PutConfiguration_shouldUpdateConfigAndRunHandlers()
212211
)
213212
}});
214213

215-
ResolutionDetails<bool> details = await provider.ResolveBooleanValue("old-flag", false, EvaluationContext.Empty).ConfigureAwait(false);
214+
ResolutionDetails<bool> details = await provider.ResolveBooleanValue("old-flag", false, EvaluationContext.Empty);
216215
Assert.True(details.Value);
217216

218217
// update flags
@@ -225,15 +224,15 @@ await provider.UpdateFlags(new Dictionary<string, Flag>(){
225224
},
226225
defaultVariant: "greeting"
227226
)
228-
}}).ConfigureAwait(false);
227+
}});
229228

230-
var res = await provider.GetEventChannel().Reader.ReadAsync().ConfigureAwait(false) as ProviderEventPayload;
229+
var res = await provider.GetEventChannel().Reader.ReadAsync() as ProviderEventPayload;
231230
Assert.Equal(ProviderEventTypes.ProviderConfigurationChanged, res.Type);
232231

233-
await Assert.ThrowsAsync<FlagNotFoundException>(() => provider.ResolveBooleanValue("old-flag", false, EvaluationContext.Empty)).ConfigureAwait(false);
232+
await Assert.ThrowsAsync<FlagNotFoundException>(() => provider.ResolveBooleanValue("old-flag", false, EvaluationContext.Empty));
234233

235234
// new flag should be present, old gone (defaults), handler run.
236-
ResolutionDetails<string> detailsAfter = await provider.ResolveStringValue("new-flag", "nope", EvaluationContext.Empty).ConfigureAwait(false);
235+
ResolutionDetails<string> detailsAfter = await provider.ResolveStringValue("new-flag", "nope", EvaluationContext.Empty);
237236
Assert.True(details.Value);
238237
Assert.Equal("hi", detailsAfter.Value);
239238
}

0 commit comments

Comments
 (0)