示例#1
0
        public async Task should_get_value_for_key()
        {
            var muxSubstitute = Substitute.For<IConnectionMultiplexer>();
            var databaseSubstitute = Substitute.For<IDatabase>();
            muxSubstitute.GetDatabase().Returns(databaseSubstitute);
            databaseSubstitute.StringGetAsync("lsd").Returns("high");

            RedisInstanceController controller = new RedisInstanceController(muxSubstitute);
            var value = await controller.Value("lsd");

            value.ToLower().Should().Be("high");  
        }
示例#2
0
        public async Task should_get_info()
        {
            var dummyValuesDict = new Dictionary<string, string>{ { "lsd", "high"} };
            var lstKeys = dummyValuesDict.ToArray();
            var dummyGrouping = lstKeys.GroupBy(x => x.Key).ToArray();
            var muxSubstitute = Substitute.For<IConnectionMultiplexer>();
            var muxServer = Substitute.For<IServer>();
            muxSubstitute.GetServer(Arg.Any<EndPoint>()).Returns(muxServer);
            muxSubstitute.GetEndPoints(Arg.Any<bool>()).Returns(x => new EndPoint[1]);
            muxServer.InfoAsync().Returns(dummyGrouping);

            RedisInstanceController controller = new RedisInstanceController(muxSubstitute);
            var info = await controller.Info();

            info.Should().ContainSingle(x => x.ContainsKey("lsd"));
        }
示例#3
0
        public async Task should_get_all_keys()
        {           
            var muxServer = Substitute.For<IServer>();
            muxServer.Keys().Returns(x => new List<RedisKey>()
                                                {
                                                    "lsd"
                                                });
            var muxSubstitute = Substitute.For<IConnectionMultiplexer>();
            muxSubstitute.GetServer(Arg.Any<EndPoint>()).Returns(x => muxServer);
            muxSubstitute.GetEndPoints(Arg.Any<bool>()).Returns(x => new EndPoint[1]);

            RedisInstanceController controller = new RedisInstanceController(muxSubstitute);
            var result = await controller.Keys();

            result.Should().Contain("lsd");
        }
示例#4
0
        public async Task should_get_server_config()
        {
           
            var muxServer = Substitute.For<IServer>();
            muxServer.ConfigGet().Returns(x => new[]
                                                {
                                                    new KeyValuePair<string, string>("lsd", "high")
                                                });
            var muxSubstitute = Substitute.For<IConnectionMultiplexer>();
            muxSubstitute.GetServer(Arg.Any<EndPoint>()).Returns(x => muxServer);
            muxSubstitute.GetEndPoints(Arg.Any<bool>()).Returns(x => new EndPoint[1]);
           
            RedisInstanceController controller = new RedisInstanceController(muxSubstitute);
            var config = await controller.Config();

            config.Should().ContainKey("lsd");
            config.Should().ContainValue("high");
        }
示例#5
0
        public void should_get_status()
        {
            var muxSubstitute = Substitute.For<IConnectionMultiplexer>();
            muxSubstitute.GetStatus().Returns("TestStatus");

            RedisInstanceController controller = new RedisInstanceController(muxSubstitute);
            var status = controller.Status();

            status.Should().Be("TestStatus");
        }