Skip to content

Commit

Permalink
fix warnings/messages & rename thing
Browse files Browse the repository at this point in the history
  • Loading branch information
SirJosh3917 committed Jun 12, 2019
1 parent a577d53 commit 49a3088
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 41 deletions.
4 changes: 2 additions & 2 deletions examples/01_GettingStarted/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ namespace _01_GettingStarted
{
// Just an extremely simple example using the StringDatabase helper

internal class Program
internal static class Program
{
private static void Main(string[] args)
private static void Main()
{
// this is the most simplest way to use StringDB
// this creates a database in RAM
Expand Down
2 changes: 2 additions & 0 deletions src/StringDB.PerformanceNumbers/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ private static void Main()
new SingleInsertFileSize().Run();
new InsertRangeFileSize().Run();

Console.WriteLine(summary);

Console.ReadLine();
}

Expand Down
6 changes: 1 addition & 5 deletions src/StringDB.PerformanceNumbers/YieldOrLinq.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,10 @@ public IEnumerable<int> UseLinq()

public class CustomEnumerator : IEnumerator<int>, IEnumerable<int>
{
private readonly IEnumerable<(int, int)> _enumerateOver;
private readonly IEnumerator<(int, int)> _enumerator;

public CustomEnumerator(IEnumerable<(int, int)> enumerateOver)
{
_enumerateOver = enumerateOver;
_enumerator = enumerateOver.GetEnumerator();
}
=> _enumerator = enumerateOver.GetEnumerator();

public bool MoveNext()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ private uint ReadVariableLength()
private void WriteVariableLength(uint value)
{
var currentValue = value;
var bufferIndex = 0;

do
{
Expand Down
5 changes: 1 addition & 4 deletions src/StringDB/IO/StreamCacheMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,7 @@ public override long Position
}
}

public override void Close()
{
InnerStream.Close();
}
public override void Close() => InnerStream.Close();

public void UpdateCache()
{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ namespace StringDB.Tests.QueryingTests
{
public class QueryManagerExtensionsTests
{
private Mock<IQueryManager<string, int>> _queryManager = new Mock<IQueryManager<string, int>>();
private readonly Mock<IQueryManager<string, int>> _queryManager = new Mock<IQueryManager<string, int>>();

[Fact]
public async Task CancellationToken_IsPassed_ToQueryManager()
{
var cancellationRequestedShouldBe = false;
const bool cancellationRequestedShouldBe = false;

var request = new Mock<IRequest<int>>();
request.Setup(x => x.Request()).Returns(Task.FromResult(1));
Expand Down Expand Up @@ -54,11 +54,12 @@ public async Task CancellationToken_IsPassed_ToQueryManager()
public async Task ExecutingQuery_IsFalse_ReturnsNull()
{
_queryManager.Setup(x => x.ExecuteQuery(It.IsAny<IQuery<string, int>>()))
.Returns<IQuery<string, int>>(async query => false)
.Returns<IQuery<string, int>>(_ => Task.FromResult(false))
.Verifiable();

var result = await _queryManager.Object
.Find(x => x == "str");
.Find(x => x == "str")
.ConfigureAwait(false);

result.Should().BeNull();

Expand Down
2 changes: 1 addition & 1 deletion tests/StringDB.Tests/QueryingTests/QueryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void Process_InvokesDelegate_And_Parameters_ArePassed()
p2 = _2;

invoked = true;
return null;
return Task.FromResult(QueryAcceptance.Continue);
});

_query.Process(13, mock.Object);
Expand Down
8 changes: 4 additions & 4 deletions tests/StringDB.Tests/StoneVaultIODeviceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void InsertWorks()
.Should()
.BeEquivalentTo(TestKeyValue().Concat(TestAA()).Concat(DataBad()));

IEnumerable<byte> TestKeyValue()
static IEnumerable<byte> TestKeyValue()
{
return new byte[]
{
Expand All @@ -67,7 +67,7 @@ IEnumerable<byte> TestKeyValue()
.Concat(Encoding.UTF8.GetBytes("value"));
}

IEnumerable<byte> TestAA()
static IEnumerable<byte> TestAA()
{
return new byte[]
{
Expand All @@ -83,7 +83,7 @@ IEnumerable<byte> TestAA()
.Concat(Encoding.UTF8.GetBytes("a"));
}

IEnumerable<byte> DataBad()
static IEnumerable<byte> DataBad()
{
return new byte[]
{
Expand Down Expand Up @@ -145,7 +145,7 @@ public void CanRead()
_sviod.ReadNext()
.Should().BeEquivalentTo(keys[1]);

byte[] Bytes(string str) => Encoding.UTF8.GetBytes(str);
static byte[] Bytes(string str) => Encoding.UTF8.GetBytes(str);
}
}
}
38 changes: 18 additions & 20 deletions tests/StringDB.Tests/StringDB10_0_0Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public class Index
[Fact]
public void ReadsIndexOk()
{
var (ms, io) = Generate();
var (_, io) = Generate();

io.WriteIndex(Encoding.UTF8.GetBytes("key"), 1337);

Expand All @@ -273,7 +273,7 @@ public class Value
[Fact]
public void ReadsValueOk()
{
var (ms, io) = Generate();
var (_, io) = Generate();

const int len = 12345;

Expand Down Expand Up @@ -314,7 +314,7 @@ public class Jump
[Fact]
public void PeeksJumpFine()
{
var (ms, io) = Generate();
var (_, io) = Generate();

io.WriteJump(1337);
io.Reset();
Expand Down Expand Up @@ -401,33 +401,31 @@ public void JumpOffsetSize()
[Fact]
public void ReadsLongPrefix()
{
using (var ms = new MemoryStream())
using (var io = new StringDB10_0_0LowlevelDatabaseIODevice(ms))
using (var curMs = new MemoryStream())
using (var curIo = new StringDB10_0_0LowlevelDatabaseIODevice(curMs))
{
io.JumpPos
curIo.JumpPos
.Should()
.Be(0);

ms.Length
curMs.Length
.Should()
.Be(8);
}

using (var ms = new MemoryStream())
{
ms.Write(new byte[8] { 123, 0, 0, 0, 0, 0, 0, 0 });
using var ms = new MemoryStream();

using (var io = new StringDB10_0_0LowlevelDatabaseIODevice(ms))
{
io.JumpPos
.Should()
.Be(123);
ms.Write(new byte[8] { 123, 0, 0, 0, 0, 0, 0, 0 });

ms.Length
.Should()
.Be(8);
}
}
using var io = new StringDB10_0_0LowlevelDatabaseIODevice(ms);

io.JumpPos
.Should()
.Be(123);

ms.Length
.Should()
.Be(8);
}

[Fact]
Expand Down

0 comments on commit 49a3088

Please sign in to comment.