public void WhenEntityIsTablePerHierarchyThenMatch()
 {
     var orm = new Mock<IDomainInspector>();
     orm.Setup(x => x.IsTablePerClassHierarchy(typeof(Item))).Returns(true);
     IPatternApplier<Type, IClassAttributesMapper> applier = new ClassDiscriminatorValueAsEnumValueApplier<Item, EntitiesTypes>(orm.Object);
     applier.Match(typeof(Item)).Should().Be.True();
 }
Beispiel #2
0
        public void WhenTheNameNoMatchThenThrows()
        {
            var orm     = new Mock <IDomainInspector>();
            var applier = new ClassDiscriminatorValueAsEnumValueApplier <Item, EntitiesTypesFixed>(orm.Object);
            var mapper  = new Mock <IClassAttributesMapper>();

            applier.Executing(a => a.Apply(typeof(Gallery), mapper.Object)).Throws <ArgumentException>();
        }
 public void WhenEntityIsTablePerHierarchyButOutsideTheDefinedHierarchyThenNoMatch()
 {
     var orm = new Mock<IDomainInspector>();
     orm.Setup(x => x.IsTablePerClassHierarchy(typeof(Item))).Returns(true);
     orm.Setup(x => x.IsTablePerClassHierarchy(typeof(SomethingOutOfHierarchy))).Returns(true);
     var applier = new ClassDiscriminatorValueAsEnumValueApplier<Item, EntitiesTypes>(orm.Object);
     applier.Match(typeof(SomethingOutOfHierarchy)).Should().Be.False();
 }
Beispiel #4
0
        public void WhenEntityIsTablePerHierarchyThenMatch()
        {
            var orm = new Mock <IDomainInspector>();

            orm.Setup(x => x.IsTablePerClassHierarchy(typeof(Item))).Returns(true);
            IPatternApplier <Type, IClassAttributesMapper> applier = new ClassDiscriminatorValueAsEnumValueApplier <Item, EntitiesTypes>(orm.Object);

            applier.Match(typeof(Item)).Should().Be.True();
        }
Beispiel #5
0
        public void WhenEntityIsTablePerHierarchyButOutsideTheDefinedHierarchyThenNoMatch()
        {
            var orm = new Mock <IDomainInspector>();

            orm.Setup(x => x.IsTablePerClassHierarchy(typeof(Item))).Returns(true);
            orm.Setup(x => x.IsTablePerClassHierarchy(typeof(SomethingOutOfHierarchy))).Returns(true);
            var applier = new ClassDiscriminatorValueAsEnumValueApplier <Item, EntitiesTypes>(orm.Object);

            applier.Match(typeof(SomethingOutOfHierarchy)).Should().Be.False();
        }
Beispiel #6
0
        public void WhenTheNameNoMatchAndEnumCotainsUnknowThenApplyUnknowEnumValue()
        {
            var orm     = new Mock <IDomainInspector>();
            var applier = new ClassDiscriminatorValueAsEnumValueApplier <Item, EntitiesTypes>(orm.Object);

            var mapper = new Mock <IClassAttributesMapper>();

            applier.Apply(typeof(Gallery), mapper.Object);

            mapper.Verify(cm => cm.DiscriminatorValue(It.Is <int>(n => ((int)EntitiesTypes.Unknown).Equals(n))));
        }
Beispiel #7
0
        public void WhenTheNameMatchThenApplyEnumValue()
        {
            var orm     = new Mock <IDomainInspector>();
            var applier = new ClassDiscriminatorValueAsEnumValueApplier <Item, EntitiesTypes>(orm.Object);

            var mapper = new Mock <IClassAttributesMapper>();

            applier.Apply(typeof(Contribute), mapper.Object);

            mapper.Verify(cm => cm.DiscriminatorValue(It.Is <int>(n => ((int)EntitiesTypes.Contribute).Equals(n))));
        }
        public void WhenTheNameMatchThenApplyEnumValue()
        {
            var orm = new Mock<IDomainInspector>();
            var applier = new ClassDiscriminatorValueAsEnumValueApplier<Item, EntitiesTypes>(orm.Object);

            var mapper = new Mock<IClassAttributesMapper>();

            applier.Apply(typeof(Contribute), mapper.Object);

            mapper.Verify(cm => cm.DiscriminatorValue(It.Is<int>(n => ((int)EntitiesTypes.Contribute).Equals(n))));
        }
        public void WhenTheNameNoMatchThenThrows()
        {
            var orm = new Mock<IDomainInspector>();
            var applier = new ClassDiscriminatorValueAsEnumValueApplier<Item, EntitiesTypesFixed>(orm.Object);
            var mapper = new Mock<IClassAttributesMapper>();

            applier.Executing(a => a.Apply(typeof(Gallery), mapper.Object)).Throws<ArgumentException>();
        }
        public void WhenTheNameNoMatchAndEnumCotainsUnknowThenApplyUnknowEnumValue()
        {
            var orm = new Mock<IDomainInspector>();
            var applier = new ClassDiscriminatorValueAsEnumValueApplier<Item, EntitiesTypes>(orm.Object);

            var mapper = new Mock<IClassAttributesMapper>();

            applier.Apply(typeof(Gallery), mapper.Object);

            mapper.Verify(cm => cm.DiscriminatorValue(It.Is<int>(n => ((int)EntitiesTypes.Unknown).Equals(n))));
        }