Exemple #1
0
        PersistenceTestResult WithEqualityRule(IGetsEqualityResult <T> equalityRule)
        {
            if (equalityRule == null)
            {
                throw new ArgumentNullException(nameof(equalityRule));
            }

            var spec = new PersistenceTestSpec <T>(SessionProvider, Entity, equalityRule)
            {
                Setup = Setup
            };

            using (var tester = testerFactory(spec))
            {
                return(tester.GetTestResult());
            }
        }
        public void WithEqualityRule_uses_rule_in_spec(IGetsEqualityResult <SampleEntity> equalityRule,
                                                       IGetsSession sessionProvider,
                                                       [NoRecursion] SampleEntity entity,
                                                       ITestsPersistence <SampleEntity> tester)
        {
            Mock.Get(tester).Setup(x => x.GetTestResult()).Returns(() => null);
            PersistenceTestSpec <SampleEntity> specification = null;
            var builder = new PersistenceTestBuilder <SampleEntity>(sessionProvider, entity, null, spec =>
            {
                specification = spec;
                return(tester);
            });
            var sut = AsComparerChooser(builder);

            sut.WithEqualityRule(equalityRule);

            Assert.That(specification?.EqualityRule, Is.SameAs(equalityRule));
        }
Exemple #3
0
 PersistenceTestResult IConfiguresComparison <T> .WithEqualityRule(IGetsEqualityResult <T> equalityRule)
 {
     return(WithEqualityRule(equalityRule));
 }
Exemple #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PersistenceTestSpec{T}"/> class.
 /// </summary>
 /// <param name="sessionProvider">The session provider.</param>
 /// <param name="entity">The entity to be tested.</param>
 /// <param name="equalityRule">The equality rule.</param>
 public PersistenceTestSpec(IGetsSession sessionProvider, T entity, IGetsEqualityResult <T> equalityRule)
 {
     SessionProvider = sessionProvider ?? throw new ArgumentNullException(nameof(sessionProvider));
     Entity          = entity ?? throw new ArgumentNullException(nameof(entity));
     EqualityRule    = equalityRule ?? throw new ArgumentNullException(nameof(equalityRule));
 }