public void op_Verify_IRepository()
        {
            var key = AlphaDecimal.Random();

            var obj = new RepositorySelectKey <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.Select(key))
            .Returns(obj.Record1)
            .Verifiable();

            obj.Verify(repository.Object);

            repository.VerifyAll();
        }
        public void op_Verify_IRepository_whenNullIsReturned()
        {
            var key = AlphaDecimal.Random();

            var obj = new RepositorySelectKey <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.Select(key))
            .Returns(null as IRecord <RandomObject>)
            .Verifiable();

            Assert.Throws <RepositoryTestException>(() => obj.Verify(repository.Object));

            repository.VerifyAll();
        }
        public void op_Verify_IRepository_whenInvalidOperationException()
        {
            var obj = new RepositorySelectKey <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();
        }
        public void op_Verify_IRepository_whenValueIsDifferent()
        {
            var key = AlphaDecimal.Random();

            var obj = new RepositorySelectKey <RandomObject>
            {
                Record1 =
                {
                    Key = key
                }
            };

            var repository = new Mock <IRepository <RandomObject> >();

            repository
            .Setup(x => x.Insert(obj.Record1))
            .Returns(obj.Record1)
            .Verifiable();

            var record = new Mock <IRecord <RandomObject> >();

            record
            .SetupGet(x => x.Key)
            .Returns(obj.Record1.Key);
            record
            .SetupGet(x => x.Urn)
            .Returns(obj.Record1.Urn);
            record
            .SetupGet(x => x.Value)
            .Returns(new RandomObject(123));
            repository
            .Setup(x => x.Select(key))
            .Returns(record.Object)
            .Verifiable();

            Assert.Throws <RepositoryTestException>(() => obj.Verify(repository.Object));

            repository.VerifyAll();
        }