public void WhenManyToManyCollectionWithOutMasterThenApplyTableAlphabetical()
        {
            var orm = new Mock<IDomainInspector>();
            orm.Setup(x => x.IsManyToMany(It.Is<Type>(t => t == typeof(MyClass)), It.Is<Type>(t => t == typeof(MyBidirect)))).Returns(true);
            orm.Setup(x => x.IsManyToMany(It.Is<Type>(t => t == typeof(MyBidirect)), It.Is<Type>(t => t == typeof(MyClass)))).Returns(true);

            var pattern = new ManyToManyInCollectionTableApplier(orm.Object);
            var path = new PropertyPath(null, ForClass<MyClass>.Property(x => x.MyBidirects));
            var collectionMapper = new Mock<ICollectionPropertiesMapper>();

            pattern.Match(path).Should().Be.True();
            pattern.Apply(path, collectionMapper.Object);

            collectionMapper.Verify(x => x.Table(It.Is<string>(tableName => tableName == "MyBidirectToMyClass")));

            var bipath = new PropertyPath(null, ForClass<MyBidirect>.Property(x => x.MyClasses));
            var bicollectionMapper = new Mock<ICollectionPropertiesMapper>();

            pattern.Match(path).Should().Be.True();
            pattern.Apply(bipath, bicollectionMapper.Object);

            bicollectionMapper.Verify(x => x.Table(It.Is<string>(tableName => tableName == "MyBidirectToMyClass")));
        }
        public void WhenManyToManyCollectionInsideComponentThenApplyFromEntityToEntity()
        {
            var orm = new Mock<IDomainInspector>();
            orm.Setup(x => x.IsManyToMany(It.Is<Type>(t => t == typeof(MyComponent)), It.Is<Type>(t => t == typeof(MyBidirect)))).Returns(true);
            orm.Setup(x => x.IsMasterManyToMany(It.Is<Type>(t => t == typeof(MyComponent)), It.Is<Type>(t => t == typeof(MyBidirect)))).Returns(true);

            var pattern = new ManyToManyInCollectionTableApplier(orm.Object);

            var pathEntity = new PropertyPath(null, ForClass<MyClass>.Property(x => x.MyComponent));
            var path = new PropertyPath(pathEntity, ForClass<MyComponent>.Property(x => x.MyBidirects));
            var collectionMapper = new Mock<ICollectionPropertiesMapper>();

            pattern.Match(path).Should().Be.True();
            pattern.Apply(path, collectionMapper.Object);

            collectionMapper.Verify(x => x.Table(It.Is<string>(tableName => tableName == "MyClassToMyBidirect")));
        }
        public void WhenRelationDeclaredAsManyToManyForDictionaryKeyThenMatch()
        {
            var orm = new Mock<IDomainInspector>();
            orm.Setup(x => x.IsManyToMany(It.Is<Type>(t => t == typeof(MyClass)), It.Is<Type>(t => t == typeof(MyBidirect)))).Returns(true);
            var path = new PropertyPath(null, ForClass<MyClass>.Property(x => x.MapKey));

            var pattern = new ManyToManyInCollectionTableApplier(orm.Object);
            pattern.Match(path).Should().Be.False();
        }