コード例 #1
0
ファイル: DataAccessTest.cs プロジェクト: rpetz/FakeDbSet
        public void Setup_fake_dbset_returns_expected()
        {
            // Arrange
            var entities = new BookStoreEntities();
            var book = new Book { Title = "title" };

            // Act
            entities.SetupFakeDbSet(x => x.Books).Add(book);

            // Assert
            Assert.That(entities.Books.Count(), Is.EqualTo(1));
            Assert.That(entities.Books.First().Title, Is.EqualTo("title"));
        }
コード例 #2
0
ファイル: DataAccessTest.cs プロジェクト: rpetz/FakeDbSet
        public void Setup_fake_dbset_with_add_many_returns_expected()
        {
            // Arrange
            var entities = new BookStoreEntities();
            var book1 = new Book { Title = "title 1" };
            var book2 = new Book { Title = "title 2" };

            // Act
            entities.SetupFakeDbSet(x => x.Books).Add(book1, book2);

            // Assert
            Assert.That(entities.Books.Count(), Is.EqualTo(2));
            Assert.That(entities.Books.First().Title, Is.EqualTo("title 1"));
            Assert.That(entities.Books.Last().Title, Is.EqualTo("title 2"));
        }