public void Update() { var mock = new Mock<IPopRepository>(); var target = new PopService(mock.Object); target.Update(new Pop()); mock.Verify(x => x.Update(It.IsAny<Pop>()), Times.Once()); }
public void GetAll() { var mock = new Mock<IPopRepository>(); mock.Setup(s => s.GetAll()).Returns( new List<Pop> { new Pop { Id = 1, Title = "Pop1" }, new Pop { Id = 2, Title = "Pop2" } } ); var target = new PopService(mock.Object); IEnumerable<Pop> pops = target.GetAll(); mock.Verify(x => x.GetAll(), Times.Once()); pops.Count().Should().Be(2); pops.Satisfy(s => s.FirstOrDefault(w => w.Id == 1) != null); pops.Satisfy(s => s.FirstOrDefault(w => w.Id == 2) != null); }