public void GetReturnsClone() {
     var table = new InMemoryTable<Post, int>(new TestConfiguration());
     var post = new Post { Title = "Foo" };
     table.Insert(post);
     var returnedPost = table.Get(1);
     Assert.NotNull(returnedPost);
     Assert.Equal("Foo", returnedPost.Title);
     Assert.False(post == returnedPost);
     Assert.True(post.Equals(returnedPost));
 }
 public void QueryWorks() {
     var table = new InMemoryTable<Post, int>(new TestConfiguration());
     var post1 = new Post() { Title = "Foo" };
     var post2 = new Post() { Title = "Bar" };
     table.Insert(post1);
     table.Insert(post2);
     var posts = table.Query().ToArray();
     Assert.Equal(2, posts.Length);
     Assert.True(post1.Equals(posts[0]));
     Assert.True(post2.Equals(posts[1]));
 }
Esempio n. 3
0
        public void CloneWorks() {
            var cloner = new EntityCloner<Post>(new TestConfiguration());
            var post = new Post() { PostId = 1, Title = "Foo", Blog = new Blog { BlogId = 1, Title = "My Blog" }};
            var clone = cloner.Clone(post);

            Assert.False(post == clone);
            Assert.True(post.Equals(clone));
            Assert.False(ReferenceEquals(post.Title, clone.Title));
            Assert.Equal(post.PostId, clone.PostId);
            Assert.True(post.Blog.Equals(clone.Blog));
            Assert.False(post.Blog == clone.Blog);
            Assert.Null(clone.Blog.Title);
            Assert.Equal("My Blog", post.Blog.Title);
        }
 public void UpdateWorks() {
     var table = new InMemoryTable<Post, int>(new TestConfiguration());
     var post1 = new Post() { Title = "Foo" };
     table.Insert(post1);
     post1.Title = "Bar";
     table.Update(post1);
     var updatedPost = table.Get(1);
     Assert.False(post1 == updatedPost);
     Assert.True(post1.Equals(updatedPost));
     Assert.Equal("Bar", updatedPost.Title);
 }