Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }