コード例 #1
0
        public void RepositoryTestsEnsureICanDeletePostById()
        {
            List <Posts> expected = new List <Posts>
            {
                new Posts {
                    PostsID = 1, Date = new DateTime(2015, 12, 2), Content = "What is the name of the game??"
                },
                new Posts {
                    PostsID = 2, Date = new DateTime(2015, 12, 5), Content = "Who??"
                },
                new Posts {
                    PostsID = 3, Date = new DateTime(2015, 12, 7, 10, 15, 00), Content = "Game Game"
                }
            };


            _postSet.Object.AddRange(expected);
            ConnectMocksToDataStore(expected);
            _postSet.Setup(o => o.Remove(It.IsAny <Posts>())).Callback((Posts p) => expected.Remove(p));

            bool actual   = _repo.DeletePostById(1);
            var  numPosts = _repo.GetAllPosts();

            Assert.IsTrue(actual);
            Assert.AreEqual(2, numPosts.Count);
        }