public async Task DbSize_ReturnsValueCorrectly()
        {
            var underTest = LocalHostDefaultPort.CreateAndConnectClient();

            await underTest.Set(Key, Value);

            await underTest.Set(Key2, Value2);

            var result = await underTest.DbSize();

            result.Should().Be(2);
        }
        public async Task Exists_ReturnsValueCorrectly()
        {
            var underTest = LocalHostDefaultPort.CreateAndConnectClient();

            await underTest.Set(Key, Value);

            var result1 = await underTest.Exists(Key);

            var result2 = await underTest.Exists("NotPresentKey");

            result1.Should().BeTrue();
            result2.Should().BeFalse();
        }
        public async Task Del_DeletedSuccessfully()
        {
            var underTest = LocalHostDefaultPort.CreateAndConnectClient();

            await underTest.Set(Key, Value);

            var result1 = await underTest.Get(Key);

            await underTest.Del(Key);

            var result2 = await underTest.Get(Key);

            result1.Should().Be(Value);
            result2.Should().BeNull();
        }
        public async Task SwapWithWrongDbNumbers_ThrowsException()
        {
            Exception thrownException = null;
            var       underTest       = LocalHostDefaultPort.CreateAndConnectClient();

            try
            {
                await underTest.SwapDb(int.MaxValue, int.MaxValue - 1);
            }
            catch (Exception ex)
            {
                thrownException = ex;
            }

            thrownException.Should().NotBeNull().And.BeOfType <RedisException>();
        }
        public async Task FlushDb_DbFlushedSuccessfully()
        {
            var underTest = LocalHostDefaultPort.CreateAndConnectClient();

            await underTest.Set(Key, Value);

            await underTest.Set(Key2, Value2);

            await underTest.FlushDb();

            var result1 = await underTest.Get(Key);

            var result2 = await underTest.Get(Key2);

            result1.Should().BeNull();
            result2.Should().BeNull();
        }
        public async Task Select_ClientSelectsNewDb()
        {
            var underTest = LocalHostDefaultPort.CreateAndConnectClient();

            await underTest.Select(7);

            await underTest.Set(Key, Value);

            var result1 = await underTest.Get(Key);

            await underTest.Select(8);

            var result2 = await underTest.Get(Key);

            result1.Should().Be(Value);
            result2.Should().BeNull();
        }
        public async Task CallingClientAfterDispose_ThrowsException()
        {
            Exception thrownException = null;
            var       underTest       = LocalHostDefaultPort.CreateAndConnectClient();

            underTest.Dispose();

            try
            {
                await underTest.Set(Key, Value);
            }
            catch (Exception ex)
            {
                thrownException = ex;
            }

            thrownException.Should().NotBeNull().And.BeOfType <InvalidOperationException>();
        }
        public async Task SwapDb_ClientConnectedToCorrectDb()
        {
            var underTest = LocalHostDefaultPort.CreateAndConnectClient();

            await underTest.Select(0);

            await underTest.Set(Key, Value);

            await underTest.SwapDb(0, 7);

            var existsOnDb0 = await underTest.Exists(Key);

            await underTest.Select(7);

            var readValueFromDb7 = await underTest.Get(Key);

            existsOnDb0.Should().BeFalse();
            readValueFromDb7.Should().Be(Value);
        }