public void WhenNoGenericCollectionThenNoMatch() { var orm = new Mock<IDomainInspector>(); var pattern = new CollectionOfElementsKeyColumnApplier(orm.Object); var path = new PropertyPath(null, ForClass<MyClass>.Property(p => p.Something)); pattern.Match(path).Should().Be.False(); }
public void WhenNoGenericCollectionThenNoMatch() { var orm = new Mock <IDomainInspector>(); var pattern = new CollectionOfElementsKeyColumnApplier(orm.Object); var path = new PropertyPath(null, ForClass <MyClass> .Property(p => p.Something)); pattern.Match(path).Should().Be.False(); }
public void WhenNoRelationWithComponentThenMatch() { var orm = new Mock <IDomainInspector>(); var pattern = new CollectionOfElementsKeyColumnApplier(orm.Object); var pathCollection = new PropertyPath(null, ForClass <MyComponent> .Property(p => p.Strings)); pattern.Match(pathCollection).Should().Be.True(); }
public void WhenNoRelationWithComponentThenMatch() { var orm = new Mock<IDomainInspector>(); var pattern = new CollectionOfElementsKeyColumnApplier(orm.Object); var pathCollection = new PropertyPath(null, ForClass<MyComponent>.Property(p => p.Strings)); pattern.Match(pathCollection).Should().Be.True(); }
public void WhenRelationIsOneToManyForMapKeyThenNoMatch() { var orm = new Mock<IDomainInspector>(); var pattern = new CollectionOfElementsKeyColumnApplier(orm.Object); orm.Setup(x => x.IsManyToMany(It.Is<Type>(t => t == typeof(MyClass)), It.Is<Type>(t => t == typeof(MyRelated)))).Returns(true); var path = new PropertyPath(null, ForClass<MyClass>.Property(p => p.MapRelationOnKey)); pattern.Match(path).Should().Be.False(); }
public void WhenRelationIsManyToManyThenNoMatch() { var orm = new Mock <IDomainInspector>(); var pattern = new CollectionOfElementsKeyColumnApplier(orm.Object); orm.Setup(x => x.IsManyToMany(It.Is <Type>(t => t == typeof(MyClass)), It.Is <Type>(t => t == typeof(MyRelated)))).Returns(true); var path = new PropertyPath(null, ForClass <MyClass> .Property(p => p.Relateds)); pattern.Match(path).Should().Be.False(); }
public void WhenRelationIsInPlainEntityThenApplyClassNameId() { var orm = new Mock<IDomainInspector>(); var pattern = new CollectionOfElementsKeyColumnApplier(orm.Object); var mapper = new Mock<ICollectionPropertiesMapper>(); var keyMapper = new Mock<IKeyMapper>(); mapper.Setup(x => x.Key(It.IsAny<Action<IKeyMapper>>())).Callback<Action<IKeyMapper>>( x => x.Invoke(keyMapper.Object)); var path = new PropertyPath(null, ForClass<MyClass>.Property(p => p.Strings)); pattern.Apply(path, mapper.Object); keyMapper.Verify(km => km.Column(It.Is<string>(s => s == "MyClassId"))); }
public void WhenRelationIsInPlainEntityThenApplyClassNameId() { var orm = new Mock <IDomainInspector>(); var pattern = new CollectionOfElementsKeyColumnApplier(orm.Object); var mapper = new Mock <ICollectionPropertiesMapper>(); var keyMapper = new Mock <IKeyMapper>(); mapper.Setup(x => x.Key(It.IsAny <Action <IKeyMapper> >())).Callback <Action <IKeyMapper> >( x => x.Invoke(keyMapper.Object)); var path = new PropertyPath(null, ForClass <MyClass> .Property(p => p.Strings)); pattern.Apply(path, mapper.Object); keyMapper.Verify(km => km.Column(It.Is <string>(s => s == "MyClassId"))); }