Skip to content

Commit

Permalink
Merge branch 'main' into ivan/bin-prefs
Browse files Browse the repository at this point in the history
# Conflicts:
#	Tests/BinaryStorageTests.cs
  • Loading branch information
imurashka committed Jun 22, 2024
2 parents 6e6d701 + d7bce60 commit 34fa951
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Tests/BinaryStorageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ public void WhenTypeMismatchBehaviorIsOverrideValueAndType_ThenValueAndTypeAreOv

// Assert
result.Should().BeTrue();
storage.TypeOf("key").Should().Be(typeof(string));
storage.Get<string>("key").Should().Be("value");
}

Expand All @@ -445,11 +446,12 @@ public void WhenTypeMismatchBehaviorIsIgnore_ThenValueAndTypeAreIgnored()

// Assert
result.Should().BeFalse();
storage.TypeOf("key").Should().Be(typeof(int));
storage.Get<int>("key").Should().Be(123);
}

[Test]
public void WhenTypeMismatchBehaviorOverrideIsSetInGetMethod_ThenBehaviorIsOverridden()
public void WhenTypeMismatchBehaviorOverride_ThenBehaviorIsOverridden()
{
// Arrange
using var storage = BinaryStorage.Construct(StoragePath)
Expand All @@ -460,12 +462,13 @@ public void WhenTypeMismatchBehaviorOverrideIsSetInGetMethod_ThenBehaviorIsOverr
storage.Set("key", 123);

// Act
var value = storage.Get("key", "defaultValue", MissingKeyBehavior.InitializeWithDefaultValue);
var result = storage.Set("key", "value", TypeMismatchBehaviour.OverrideValueAndType);

// Assert
value.Should().Be("defaultValue");
result.Should().BeTrue();
storage.Has("key").Should().BeTrue();
storage.Get<string>("key").Should().Be("defaultValue");
storage.TypeOf("key").Should().Be(typeof(string));
storage.Get<string>("key").Should().Be("value");
}

#endregion
Expand Down

0 comments on commit 34fa951

Please sign in to comment.