Пример #1
0
        public void CreateSpecies_AddsSpecies()
        {
            var item = new Species
            {
                Id       = 1,
                Name     = "test1",
                IsActive = false
            };

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

            var service = new SpeciesService(mockContext.Object);

            service.CreateSpecies(item);

            mockContext.Verify(m => m.SetEntityStateAdded(It.IsAny <Species>()), Times.Once());
            mockContext.Verify(m => m.SaveChanges(), Times.Once());
        }