public void op_Verify_IRepository() { var key = AlphaDecimal.Random(); var obj = new RepositoryDeleteKey<RandomObject> { Record1 = { Key = key } }; var repository = new Mock<IRepository<RandomObject>>(); repository .Setup(x => x.Insert(obj.Record1)) .Returns(obj.Record1) .Verifiable(); repository .Setup(x => x.Delete(key)) .Returns(true) .Verifiable(); repository .Setup(x => x.Exists(key)) .Returns(false) .Verifiable(); obj.Verify(repository.Object); repository.VerifyAll(); }
public void op_Verify_IRepository_whenExists() { var key = AlphaDecimal.Random(); var obj = new RepositoryDeleteKey<RandomObject> { Record1 = { Key = key } }; var repository = new Mock<IRepository<RandomObject>>(); repository .Setup(x => x.Insert(obj.Record1)) .Returns(obj.Record1) .Verifiable(); repository .Setup(x => x.Delete(key)) .Returns(true) .Verifiable(); repository .Setup(x => x.Exists(key)) .Returns(true) .Verifiable(); Assert.Throws<RepositoryTestException>(() => obj.Verify(repository.Object)); repository.VerifyAll(); }
public void op_Verify_IRepository_whenInvalidOperationException() { var obj = new RepositoryDeleteKey<RandomObject>(); var repository = new Mock<IRepository<RandomObject>>(); repository .Setup(x => x.Insert(obj.Record1)) .Returns(obj.Record1) .Verifiable(); Assert.Throws<InvalidOperationException>(() => obj.Verify(repository.Object)); repository.VerifyAll(); }