示例#1
0
        public void CacheTest_StoreTwoPostsIntoNotEmptyCache()
        {
            // Arrange
            var storedPosts = new List <Post>
            {
                new Post {
                    Filename = "MyPost"
                },
                new Post {
                    Filename = "MySecondPost"
                },
                new Post {
                    Filename = "MyAnotherOnePost"
                }
            };
            var cache = new PostCache(new ConcurrentCache <Post>(storedPosts));
            var posts = new List <Post>
            {
                new Post {
                    Filename = "MyAwesomePost"
                },
                new Post {
                    Filename = "MySecondAwesomePost"
                }
            };

            // Act
            cache.Store(posts);

            // Assert
            cache.Posts.Count.Should().Be(5);
        }
示例#2
0
        public void CacheTest_StoreThreePostsWithCollisionsInCache()
        {
            // Arrange
            var storedPosts = new List <Post>
            {
                new Post {
                    Filename = "MyPost"
                },
                new Post {
                    Filename = "MySecondPost"
                },
                new Post {
                    Filename = "MyAnotherOnePost"
                }
            };
            var cache = new PostCache(new ConcurrentCache <Post>(storedPosts));
            var posts = new List <Post>
            {
                new Post {
                    Filename = "MyPost"
                },
                new Post {
                    Filename = "AwesomePost"
                },
            };

            // Act
            cache.Store(posts);

            // Assert
            cache.Posts.Count.Should().Be(4);
        }
示例#3
0
        public void CacheTest_StoreOnePostIntoEmptyCache()
        {
            // Arrange
            var cache = new PostCache(new ConcurrentCache <Post>());
            var post  = new Post {
                Filename = "MyPost"
            };

            // Act
            cache.Store(new List <Post> {
                post
            });

            // Assert
            cache.Posts.Count.Should().Be(1);
        }
示例#4
0
        public void CacheTest_StoreTwoPostsIntoEmptyCache()
        {
            // Arrange
            var cache = new PostCache(new ConcurrentCache <Post>());
            var posts = new List <Post>
            {
                new Post {
                    Filename = "MyPost"
                },
                new Post {
                    Filename = "MySecondPost"
                }
            };

            // Act
            cache.Store(posts);

            // Assert
            cache.Posts.Count.Should().Be(2);
        }