|
1 | 1 | using System;
|
| 2 | +using System.Collections.Generic; |
2 | 3 | using System.Collections.Immutable;
|
3 | 4 | using System.Diagnostics.CodeAnalysis;
|
4 | 5 | using System.Linq;
|
|
11 | 12 | using NSubstitute.ExceptionExtensions;
|
12 | 13 | using OpenFeature.Constant;
|
13 | 14 | using OpenFeature.Error;
|
| 15 | +using OpenFeature.Extension; |
14 | 16 | using OpenFeature.Model;
|
15 | 17 | using OpenFeature.Tests.Internal;
|
16 | 18 | using Xunit;
|
@@ -480,5 +482,27 @@ public void Should_Get_And_Set_Context()
|
480 | 482 | client.SetContext(new EvaluationContextBuilder().Set(KEY, VAL).Build());
|
481 | 483 | Assert.Equal(VAL, client.GetContext().GetValue(KEY).AsInteger);
|
482 | 484 | }
|
| 485 | + |
| 486 | + |
| 487 | + [Fact] |
| 488 | + public void ToFlagEvaluationDetails_Should_Convert_All_Properties() |
| 489 | + { |
| 490 | + var fixture = new Fixture(); |
| 491 | + var flagName = fixture.Create<string>(); |
| 492 | + var boolValue = fixture.Create<bool>(); |
| 493 | + var errorType = fixture.Create<ErrorType>(); |
| 494 | + var reason = fixture.Create<string>(); |
| 495 | + var variant = fixture.Create<string>(); |
| 496 | + var errorMessage = fixture.Create<string>(); |
| 497 | + var flagData = fixture |
| 498 | + .CreateMany<KeyValuePair<string, object>>(10) |
| 499 | + .ToDictionary(x => x.Key, x => x.Value); |
| 500 | + var flagMetadata = new ImmutableMetadata(flagData); |
| 501 | + |
| 502 | + var expected = new ResolutionDetails<bool>(flagName, boolValue, errorType, reason, variant, errorMessage, flagMetadata); |
| 503 | + var result = expected.ToFlagEvaluationDetails(); |
| 504 | + |
| 505 | + result.Should().BeEquivalentTo(expected); |
| 506 | + } |
483 | 507 | }
|
484 | 508 | }
|
0 commit comments