Skip to content

Commit

Permalink
chore: ensuring disposals in tests (#233)
Browse files Browse the repository at this point in the history
cleaning up variable names
  • Loading branch information
RLittlesII authored Dec 2, 2023
1 parent cfdde7c commit 0f85558
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/Core/Geofence/GeofenceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Rocket.Surgery.Airframe
/// </summary>
public class GeofenceService : IGeofenceService, IGeofenceStore
{
private SourceCache<GeofenceRegion, string> _store = new SourceCache<GeofenceRegion, string>(x => x.Identifier);
private readonly SourceCache<GeofenceRegion, string> _store = new SourceCache<GeofenceRegion, string>(region => region.Identifier);

/// <inheritdoc/>
public IObservable<GeoLocation> Location { get; }
Expand Down
31 changes: 15 additions & 16 deletions test/Data.Tests/DuckGo/DuckDuckGoFunctionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@
using System.Reactive.Linq;
using Xunit;

namespace Airframe.Data.Tests.DuckGo
namespace Rocket.Surgery.Airframe.Data.Tests.DuckGo
{
public class DuckDuckGoFunctionTests
{
[Fact]
public void Should_Return_ChangeSet()
{
// Given
var sourceCache = new SourceCache<RelatedTopic, string>(x => x.FirstUrl);
using var sourceCache = new SourceCache<RelatedTopic, string>(topic => topic.FirstUrl);

// When
Observable.Return(
using var disposable =
Observable.Return(
new List<RelatedTopic>
{
new()
Expand All @@ -26,8 +27,7 @@ public void Should_Return_ChangeSet()
Result = "result",
Text = "text",
},
}
)
})
.Cache(sourceCache, true)
.Bind(out var result)
.Subscribe();
Expand All @@ -42,19 +42,19 @@ public void Should_Return_ChangeSet()
public void Should_Return_Cached()
{
// Given
var sourceCache = new SourceCache<RelatedTopic, string>(x => x.FirstUrl);
using var sourceCache = new SourceCache<RelatedTopic, string>(topic => topic.FirstUrl);
var firstResultGuid = Guid.NewGuid().ToString();
sourceCache.AddOrUpdate(
new RelatedTopic
{
FirstUrl = firstResultGuid,
Result = "result one",
Text = "text",
}
);
});

// When
Observable.Return(
using var disposable =
Observable.Return(
new List<RelatedTopic>
{
new()
Expand All @@ -69,8 +69,7 @@ public void Should_Return_Cached()
Result = "result two",
Text = "text",
},
}
)
})
.Cache(sourceCache, true)
.Bind(out var result)
.Subscribe();
Expand All @@ -85,7 +84,7 @@ public void Should_Return_Cached()
public void Should_Clear_Cached()
{
// Given
var sourceCache = new SourceCache<RelatedTopic, string>(x => x.FirstUrl);
using var sourceCache = new SourceCache<RelatedTopic, string>(topic => topic.FirstUrl);
sourceCache.AddOrUpdate(
new RelatedTopic
{
Expand All @@ -95,7 +94,8 @@ public void Should_Clear_Cached()
});

// When
Observable.Return(
using var disposable =
Observable.Return(
new List<RelatedTopic>
{
new()
Expand All @@ -104,16 +104,15 @@ public void Should_Clear_Cached()
Result = "result two",
Text = "text",
},
}
)
})
.Cache(sourceCache, true)
.Bind(out var result)
.Subscribe();

// Then
result
.Should()
.ContainSingle(x => x.Result == "result two");
.ContainSingle(topic => topic.Result == "result two");
}
}
}
2 changes: 1 addition & 1 deletion test/Data.Tests/DuckGo/DuckDuckGoServiceFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Rocket.Surgery.Airframe.Data.DuckDuckGo;
using Rocket.Surgery.Extensions.Testing.Fixtures;

namespace Airframe.Data.Tests.DuckGo
namespace Rocket.Surgery.Airframe.Data.Tests.DuckGo
{
internal class DuckDuckGoServiceFixture : ITestFixtureBuilder
{
Expand Down
2 changes: 1 addition & 1 deletion test/Data.Tests/DuckGo/DuckDuckGoServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Reactive.Linq;
using Xunit;

namespace Airframe.Data.Tests.DuckGo
namespace Rocket.Surgery.Airframe.Data.Tests.DuckGo
{
public class DuckDuckGoServiceTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using Rocket.Surgery.Airframe.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Linq;
using System.Reactive.Subjects;

namespace Airframe.Data.Tests.Jokes.ChuckNorris
namespace Rocket.Surgery.Airframe.Data.Tests.Jokes.ChuckNorris
{
public class ChuckNorrisJokeApiClientMock : IChuckNorrisJokeApiClient
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using FluentAssertions;
using NSubstitute;
using Rocket.Surgery.Airframe.Data;
using Rocket.Surgery.Extensions.Testing.Fixtures;
using System;
using System.Collections;
Expand All @@ -9,7 +8,7 @@
using System.Linq;
using Xunit;

namespace Airframe.Data.Tests.Jokes.ChuckNorris
namespace Rocket.Surgery.Airframe.Data.Tests.Jokes.ChuckNorris
{
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1312:Variable names should begin with lower-case letter", Justification = "Discarded variable.")]
public class ChuckNorrisJokeServiceTests
Expand Down Expand Up @@ -113,11 +112,13 @@ internal class CategoryTests : IEnumerable<object[]>
private readonly IEnumerable<string> _exclude = new[] { "One Fish", "Two Fish" };
private readonly IEnumerable<string> _include = new[] { "Red Fish", "Blue Fish" };

/// <inheritdoc/>
public IEnumerator<object[]> GetEnumerator()
{
yield return new object[] { _include, _exclude };
}

/// <inheritdoc/>
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
}

0 comments on commit 0f85558

Please sign in to comment.