コード例 #1
0
ファイル: AdminTests.cs プロジェクト: mesutc/DotTree
        public void CanDeleteFamilyId()
        {
            // Arrange
            //  need extra Moq functionality so can't use the normal mock repo
            Family family = new Family{Id=2, FamilyName="Deer", Description="The Deer Family"};
            Mock<IFamilyRepository> mock = new Mock<IFamilyRepository>();
            mock.Setup(m => m.Families).Returns(new List<Family>
                {
                    new Family{Id=1, FamilyName="Doe", Description="The Doe Family"},
                    family,
                    new Family{Id=3, FamilyName="Doey", Description="The Doey Family"}
                });

            AdminController target = new AdminController(GetPersonRepository(), mock.Object);

            // Act
            target.DeleteFamily(family.Id);

            // Assertion
            // assert that the delete functionality was called with the correct ID
            mock.Verify(m => m.DeleteFamily(family.Id));
        }