示例#1
0
        public void DeleteSpecies_DeletesItem_InAllCases()
        {
            var data = new List <Species>
            {
                new Species
                {
                    Id       = 1,
                    Name     = "test1",
                    IsActive = false
                }
            };

            var mockSet     = new MoqDbSet <Species>(data);
            var mockContext = new MoqContext <Species>(mockSet, m => m.SpeciesList);

            var service = new SpeciesService(mockContext.Object);
            var item    = new Species
            {
                Id       = 1,
                Name     = "test1",
                IsActive = true
            };

            service.DeleteSpecies(item);

            mockContext.Verify(m => m.SetEntityStateDeleted(item), Times.Once);
            mockContext.Verify(m => m.SaveChanges(), Times.Once);
        }