Exemplo n.º 1
0
        public void ListSync()
        {
            var testModels = Enumerable.Range(0, 10).Select(p => TestModelFactory.CreateTestModel()).ToList();

            Assert.Equal(testModels.Count, _client.ListLeftPushRange("ListSync", testModels));
            Assert.Equal(testModels.Count, _client.ListLength("ListSync"));
            for (var i = 0; i < testModels.Count; i++)
            {
                Assert.Equal(testModels[i],
                             _client.ListGetByIndex <TestModel>("ListSync", testModels.Count - 1 - i));
            }

            var testLeftModels = Enumerable.Range(0, 10).Select(p => TestModelFactory.CreateTestModel()).ToList();

            Assert.Equal(testLeftModels.Count + testModels.Count, _client.ListLeftPushRange("ListSync", testLeftModels));
            Assert.Equal(testLeftModels.Count + testModels.Count, _client.ListLength("ListSync"));
            for (var i = 0; i < testLeftModels.Count; i++)
            {
                Assert.Equal(testLeftModels[i],
                             _client.ListGetByIndex <TestModel>("ListSync", testLeftModels.Count - 1 - i));
            }

            var testRightModels = Enumerable.Range(0, 10).Select(p => TestModelFactory.CreateTestModel()).ToList();

            Assert.Equal(testLeftModels.Count + testModels.Count + testRightModels.Count,
                         _client.ListRightPushRange("ListSync", testRightModels));
            Assert.Equal(testLeftModels.Count + testModels.Count + testRightModels.Count,
                         _client.ListLength("ListSync"));
            for (var i = 0; i < testRightModels.Count; i++)
            {
                Assert.Equal(testRightModels[i],
                             _client.ListGetByIndex <TestModel>("ListSync",
                                                                testLeftModels.Count + testModels.Count + i));
            }

            _client.Delete("ListSync");
        }