public void ShouldReturnCorrectRangeValues() { ConsoleService.ClearDatabase(); // 1) "one" 2) "two" 3) "three" 4) "four" var command = $"zadd {PREFIX_KEY} 1 \"one\" 2 \"two\" 3 \"three\" 4 \"four\""; var result = ConsoleService.CommandExecute(command); result.Should().Be("4"); // 1) "one" 2) "two" var commandRange = $"zrange {PREFIX_KEY} 0 1"; var resultRange = ConsoleService.CommandExecute(commandRange); resultRange.Should().Be("1) \"one\"\r\n2) \"two\"\r\n"); // 1) "one" 2) "two" 3) "three" 4) "four" commandRange = $"zrange {PREFIX_KEY} 0 -1"; resultRange = ConsoleService.CommandExecute(commandRange); resultRange.Should().Be("1) \"one\"\r\n2) \"two\"\r\n3) \"three\"\r\n4) \"four\"\r\n"); // 1) "three" 2) "four" commandRange = $"zrange {PREFIX_KEY} -2 -1"; resultRange = ConsoleService.CommandExecute(commandRange); resultRange.Should().Be("1) \"three\"\r\n2) \"four\"\r\n"); }
public void ShouldIgnoreKeyNotFound() { ConsoleService.ClearDatabase(); for (int i = 0; i < 5; i++) { var commandSet = $"set {PREFIX_KEY}{i} {i}"; var resultSet = ConsoleService.CommandExecute(commandSet); resultSet.Should().Be("OK"); } // Shows that the value exists var commandGet = $"get {PREFIX_KEY}1"; var resultGet = ConsoleService.CommandExecute(commandGet); resultGet.Should().Be("1"); var commandDel = $"del {PREFIX_KEY}1 {PREFIX_KEY}2 {PREFIX_KEY}3 {PREFIX_KEY}10"; var resultDel = ConsoleService.CommandExecute(commandDel); resultDel.Should().Be("3"); // Shows that the value no longer exists commandGet = $"get {PREFIX_KEY}1"; resultGet = ConsoleService.CommandExecute(commandGet); resultGet.Should().Be("nil"); }
public void ShouldEnsureSafeThreadWithCommandIncr() { ConsoleService.ClearDatabase(); var workers = CreateThreadsWithCommandIncr(500); Task.WaitAll(workers); var command = $"get {PREFIX_KEY}_incr"; var result = ConsoleService.CommandExecute(command); }
public void ShouldReturnCountOfMembersOfKey() { ConsoleService.ClearDatabase(); var commandAdd = $"zadd {PREFIX_KEY} 1 \"one\" 2 \"two\""; var resultAdd = ConsoleService.CommandExecute(commandAdd); resultAdd.Should().Be("2"); var command = $"zcard {PREFIX_KEY}"; var result = ConsoleService.CommandExecute(command); result.Should().Be("2"); }
public void ShouldReturnCorrectIndex() { ConsoleService.ClearDatabase(); var commandAdd = $"zadd {PREFIX_KEY} 1 \"one\""; var resultAdd = ConsoleService.CommandExecute(commandAdd); resultAdd.Should().Be("1"); var command = $"zrank {PREFIX_KEY} \"one\""; var result = ConsoleService.CommandExecute(command); result.Should().Be("0"); }
public void ShouldReturnNilWhenMemberNotFound() { ConsoleService.ClearDatabase(); var commandAdd = $"zadd {PREFIX_KEY} 1 \"one\""; var resultAdd = ConsoleService.CommandExecute(commandAdd); resultAdd.Should().Be("1"); var command = $"zrank {PREFIX_KEY} test"; var result = ConsoleService.CommandExecute(command); result.Should().Be("nil"); }
public void ShouldReturnEmptyWhenStartGreaterThanStopOrCount() { ConsoleService.ClearDatabase(); // 1) "one" 2) "two" 3) "three" 4) "four" var command = $"zadd {PREFIX_KEY} 1 \"one\" 2 \"two\" 3 \"three\" 4 \"four\""; var result = ConsoleService.CommandExecute(command); result.Should().Be("4"); // 1) "one" 2) "two" 3) "three" 4) "four" var commandRange = $"zrange {PREFIX_KEY} 8 0"; var resultRange = ConsoleService.CommandExecute(commandRange); resultRange.Should().Be(""); // 1) "one" 2) "two" 3) "three" 4) "four" commandRange = $"zrange {PREFIX_KEY} 8 9"; resultRange = ConsoleService.CommandExecute(commandRange); resultRange.Should().Be(""); }