예제 #1
0
        public void MergeWith_returns_current_instance_if_other_is_same_or_null()
        {
            var annotation = new IndexAnnotation(new IndexAttribute());

            Assert.Same(annotation, annotation.MergeWith(annotation));
            Assert.Same(annotation, annotation.MergeWith(null));
        }
예제 #2
0
        public void MergeWith_throws_if_other_is_not_an_IndexAnnotation()
        {
            var annotation = new IndexAnnotation(new IndexAttribute());

            Assert.Equal(
                Strings.IncompatibleTypes("Random", "IndexAnnotation"),
                Assert.Throws <ArgumentException>(() => annotation.MergeWith(new Random())).Message);
        }
예제 #3
0
        public void MergeLists_throws_if_lists_are_not_compatible()
        {
            var annotation1 = new IndexAnnotation(
                new[]
            {
                new IndexAttribute(),
                new IndexAttribute("EekyBear"),
                new IndexAttribute("EekyBear")
                {
                    Order = 0, IsClustered = false, IsUnique = true
                }
            });

            var annotation2 = new IndexAnnotation(
                new[]
            {
                new IndexAttribute {
                    Order = 1
                },
                new IndexAttribute("EekyBear")
                {
                    Order = 1
                },
                new IndexAttribute {
                    IsClustered = true, IsUnique = false
                },
            });

            Assert.Equal(
                Strings.ConflictingIndexAttribute(
                    "EekyBear", Environment.NewLine + "\t" + Strings.ConflictingIndexAttributeProperty("Order", "1", "0")),
                Assert.Throws <InvalidOperationException>(
                    () => annotation1.MergeWith(annotation2)).Message);

            Assert.Equal(
                Strings.ConflictingIndexAttribute(
                    "EekyBear", Environment.NewLine + "\t" + Strings.ConflictingIndexAttributeProperty("Order", "0", "1")),
                Assert.Throws <InvalidOperationException>(
                    () => annotation2.MergeWith(annotation1)).Message);
        }
        public void MergeLists_throws_if_lists_are_not_compatible()
        {
            var annotation1 = new IndexAnnotation(
                new[]
                {
                    new IndexAttribute(),
                    new IndexAttribute("EekyBear"),
                    new IndexAttribute("EekyBear") { Order = 0, IsClustered = false, IsUnique = true }
                });

            var annotation2 = new IndexAnnotation(
                new[]
                {
                    new IndexAttribute { Order = 1 },
                    new IndexAttribute("EekyBear") { Order = 1 },
                    new IndexAttribute { IsClustered = true, IsUnique = false },
                });

            Assert.Equal(
                Strings.ConflictingIndexAttribute(
                    "EekyBear", Environment.NewLine + "\t" + Strings.ConflictingIndexAttributeProperty("Order", "1", "0")),
                Assert.Throws<InvalidOperationException>(
                    () => annotation1.MergeWith(annotation2)).Message);

            Assert.Equal(
                Strings.ConflictingIndexAttribute(
                    "EekyBear", Environment.NewLine + "\t" + Strings.ConflictingIndexAttributeProperty("Order", "0", "1")),
                Assert.Throws<InvalidOperationException>(
                    () => annotation2.MergeWith(annotation1)).Message);
        }
        public void MergeWith_merges_index_lists_from_both_annotations()
        {
            var annotation1 = new IndexAnnotation(
                new[]
                {
                    new IndexAttribute(),
                    new IndexAttribute("EekyBear"),
                    new IndexAttribute("EekyBear") { Order = 0, IsClustered = false, IsUnique = true }
                });

            var annotation2 = new IndexAnnotation(
                new[]
                {
                    new IndexAttribute { Order = 1 },
                    new IndexAttribute("EekyBear") { Order = 0 },
                    new IndexAttribute { IsClustered = true, IsUnique = false },
                });

            var attributes = ((IndexAnnotation)annotation1.MergeWith(annotation2)).Indexes.ToArray();
            Assert.Equal(2, attributes.Length);

            Assert.Equal("EekyBear", attributes[0].Name);
            Assert.Equal(0, attributes[0].Order);
            Assert.True(attributes[0].IsClusteredConfigured);
            Assert.False(attributes[0].IsClustered);
            Assert.True(attributes[0].IsUniqueConfigured);
            Assert.True(attributes[0].IsUnique);

            Assert.Null(attributes[1].Name);
            Assert.Equal(1, attributes[1].Order);
            Assert.True(attributes[1].IsClusteredConfigured);
            Assert.True(attributes[1].IsClustered);
            Assert.True(attributes[1].IsUniqueConfigured);
            Assert.False(attributes[1].IsUnique);

            attributes = ((IndexAnnotation)annotation2.MergeWith(annotation1)).Indexes.ToArray();
            Assert.Equal(2, attributes.Length);

            Assert.Null(attributes[0].Name);
            Assert.Equal(1, attributes[0].Order);
            Assert.True(attributes[0].IsClusteredConfigured);
            Assert.True(attributes[0].IsClustered);
            Assert.True(attributes[0].IsUniqueConfigured);
            Assert.False(attributes[0].IsUnique);

            Assert.Equal("EekyBear", attributes[1].Name);
            Assert.Equal(0, attributes[1].Order);
            Assert.True(attributes[1].IsClusteredConfigured);
            Assert.False(attributes[1].IsClustered);
            Assert.True(attributes[1].IsUniqueConfigured);
            Assert.True(attributes[1].IsUnique);
        }
 public void MergeWith_throws_if_other_is_not_an_IndexAnnotation()
 {
     var annotation = new IndexAnnotation(new IndexAttribute());
     Assert.Equal(
         Strings.IncompatibleTypes("Random", "IndexAnnotation"),
         Assert.Throws<ArgumentException>(() => annotation.MergeWith(new Random())).Message);
 }
 public void MergeWith_returns_current_instance_if_other_is_same_or_null()
 {
     var annotation = new IndexAnnotation(new IndexAttribute());
     Assert.Same(annotation, annotation.MergeWith(annotation));
     Assert.Same(annotation, annotation.MergeWith(null));
 }
예제 #8
0
        public void MergeWith_merges_index_lists_from_both_annotations()
        {
            var annotation1 = new IndexAnnotation(
                new[]
            {
                new IndexAttribute(),
                new IndexAttribute("EekyBear"),
                new IndexAttribute("EekyBear")
                {
                    Order = 0, IsClustered = false, IsUnique = true
                }
            });

            var annotation2 = new IndexAnnotation(
                new[]
            {
                new IndexAttribute {
                    Order = 1
                },
                new IndexAttribute("EekyBear")
                {
                    Order = 0
                },
                new IndexAttribute {
                    IsClustered = true, IsUnique = false
                },
            });

            var attributes = ((IndexAnnotation)annotation1.MergeWith(annotation2)).Indexes.ToArray();

            Assert.Equal(2, attributes.Length);

            Assert.Equal("EekyBear", attributes[0].Name);
            Assert.Equal(0, attributes[0].Order);
            Assert.True(attributes[0].IsClusteredConfigured);
            Assert.False(attributes[0].IsClustered);
            Assert.True(attributes[0].IsUniqueConfigured);
            Assert.True(attributes[0].IsUnique);

            Assert.Null(attributes[1].Name);
            Assert.Equal(1, attributes[1].Order);
            Assert.True(attributes[1].IsClusteredConfigured);
            Assert.True(attributes[1].IsClustered);
            Assert.True(attributes[1].IsUniqueConfigured);
            Assert.False(attributes[1].IsUnique);

            attributes = ((IndexAnnotation)annotation2.MergeWith(annotation1)).Indexes.ToArray();
            Assert.Equal(2, attributes.Length);

            Assert.Null(attributes[0].Name);
            Assert.Equal(1, attributes[0].Order);
            Assert.True(attributes[0].IsClusteredConfigured);
            Assert.True(attributes[0].IsClustered);
            Assert.True(attributes[0].IsUniqueConfigured);
            Assert.False(attributes[0].IsUnique);

            Assert.Equal("EekyBear", attributes[1].Name);
            Assert.Equal(0, attributes[1].Order);
            Assert.True(attributes[1].IsClusteredConfigured);
            Assert.False(attributes[1].IsClustered);
            Assert.True(attributes[1].IsUniqueConfigured);
            Assert.True(attributes[1].IsUnique);
        }