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)); }
public void WithEqualityRule_can_configure_a_rule(IEqualityComparer <string> comparer, 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(b => b.ForProperty(x => x.StringProperty, c => c.UsingComparer(comparer))); specification?.EqualityRule?.GetEqualityResult(entity, entity); Mock.Get(comparer) .Verify(x => x.Equals(entity.StringProperty, entity.StringProperty), Times.Once); }
public void WithEqualityComparer_uses_comparer_in_spec(IEqualityComparer <SampleEntity> comparer, 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); // Select the comparer and then execute the rule from the spec // so that the comparer should be executed with it sut.WithEqualityComparer(comparer); specification?.EqualityRule?.GetEqualityResult(entity, entity); Mock.Get(comparer) .Verify(x => x.Equals(entity, entity), Times.Once); }