Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions test/Airframe.Tests/Data/DuckGo/DuckDuckGoServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public void Should_Return_Query_Results()
{
FirstUrl = Guid.NewGuid().ToString(),
Result = "result one",
Text = "text"
}
}
Text = "text",
},
},
}));
DuckDuckGoService sut = new DuckDuckGoServiceFixture().WithClient(client);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,16 @@

namespace Airframe.Tests.Shiny.Settings
{
public sealed class SettingsTests
public sealed class SettingsProviderTests
{
private const string Key = "thing";

[Fact]
public void GivenDefaultValue_WhenGet_ThenReturnDefaultValue()
{
const int defaultValue = 1;

// Given
SettingsProvider sut = new SettingsProviderFixture();

// When
var result = sut.Get(Key, defaultValue);
var result = sut.Get(Key, DefaultValue);

// Then
result
Expand All @@ -31,26 +27,24 @@ public void GivenDefaultValue_WhenGet_ThenReturnDefaultValue()
result
.Value
.Should()
.Be(defaultValue);
.Be(DefaultValue);
}

[Fact]
public void GivenDefaultValue_WhenGet_ThenReturnValue()
{
const int defaultValue = 1;

// Given
SettingsProvider sut = new SettingsProviderFixture();
sut.Set(new Setting<int>(Key, 2));

// When
var result = sut.Get(Key, defaultValue);
var result = sut.Get(Key, DefaultValue);

// Then
result
.Value
.Should()
.NotBe(defaultValue);
.NotBe(DefaultValue);
}

[Fact]
Expand Down Expand Up @@ -117,5 +111,53 @@ public void GivenSetting_WhenChanged_ThenPersisted()
// Then
settings.Received(1).Set(Key, 10);
}

[Fact]
public void GivenSettings_WhenClear_ThenDoesNotContain()
{
// Given
var settings = Substitute.For<IKeyValueStore>();
SettingsProvider sut = new SettingsProviderFixture().WithSettings(settings);
sut.Get(Key, DefaultValue);

// When
sut.Clear();

// Then
settings.Contains(Key).Should().BeFalse();
}

[Fact]
public void GivenSettings_WhenContains_ThenContains()
{
// Given
var settings = Substitute.For<IKeyValueStore>();
SettingsProvider sut = new SettingsProviderFixture().WithSettings(settings);
sut.Get(Key, DefaultValue);

// When
var result = sut.Contains(Key);

// Then
result.Should().BeTrue();
}

[Fact]
public void GivenSettings_WhenRemoved_ThenRemoved()
{
// Given
var settings = Substitute.For<IKeyValueStore>();
SettingsProvider sut = new SettingsProviderFixture().WithSettings(settings);
sut.Get(Key, DefaultValue);

// When
sut.Remove(Key);

// Then
settings.Received().Remove(Key);
}

private const string Key = "thing";
private const int DefaultValue = 1;
}
}