Exemple #1
0
        public void AllWithDeleted_ShouldReturn_DbSet()
        {
            //Arrange
            var posts = new List <Post>
            {
                new Post()
                {
                    Id = 1, Title = "post", Content = "content"
                },
                new Post()
                {
                    Id = 2, Title = "post", Content = "content"
                }
            };

            var mockedDbContext = new Mock <MsSqlDbContext>();
            var mockedPostSet   = QueryableDbSetMock.GetQueryableMockDbSet <Post>(posts);

            mockedDbContext.Setup(c => c.Set <Post>()).Returns(mockedPostSet);
            mockedDbContext.Setup(c => c.Posts).Returns(mockedPostSet);

            var repositoryUnderTest = new EfRepository <Post>(mockedDbContext.Object);

            //Act
            var result = repositoryUnderTest.AllWithDeleted();

            //Assert
            Assert.AreEqual(result, mockedPostSet);
        }