public void op_Verify_IRepository() { var obj = new RepositoryQueryExpression<RandomObject>(); var records = new[] { obj.Record1, obj.Record2 }; var repository = new Mock<IRepository<RandomObject>>(); repository .Setup(x => x.Insert(obj.Record1)) .Returns(obj.Record1) .Verifiable(); repository .Setup(x => x.Insert(obj.Record2)) .Returns(obj.Record2) .Verifiable(); repository .Setup(x => x.Query(It.IsAny<XPathExpression>())) .Returns(records) .Verifiable(); obj.Verify(repository.Object); repository.VerifyAll(); }
public void op_Verify_IRepository_whenEmptyResults() { var obj = new RepositoryQueryExpression<RandomObject>(); var records = new List<IRecord<RandomObject>>(); var repository = new Mock<IRepository<RandomObject>>(); repository .Setup(x => x.Insert(obj.Record1)) .Returns(obj.Record1) .Verifiable(); repository .Setup(x => x.Insert(obj.Record2)) .Returns(obj.Record2) .Verifiable(); repository .Setup(x => x.Query(It.IsAny<XPathExpression>())) .Returns(records) .Verifiable(); Assert.Throws<RepositoryTestException>(() => obj.Verify(repository.Object)); repository.VerifyAll(); }