public void GenerateFluentApi_IIndex_works_with_includes()
        {
            var generator    = new SqlServerAnnotationCodeGenerator(new AnnotationCodeGeneratorDependencies());
            var modelBuilder = new ModelBuilder(SqlServerConventionSetBuilder.Build());

            modelBuilder.Entity(
                "Post",
                x =>
            {
                x.Property <int>("Id");
                x.Property <string>("FirstName");
                x.Property <string>("LastName");
                x.HasIndex("LastName").ForSqlServerInclude("FirstName");
            });
            var index      = modelBuilder.Model.FindEntityType("Post").GetIndexes().Single();
            var annotation = index.FindAnnotation(SqlServerAnnotationNames.Include);

            var result = generator.GenerateFluentApi(index, annotation);

            Assert.Equal("ForSqlServerInclude", result.Method);

            Assert.Equal(1, result.Arguments.Count);
            var properties = Assert.IsType <string[]>(result.Arguments[0]);

            Assert.Equal(new[] { "FirstName" }, properties.AsEnumerable());
        }
        public void GenerateFluentApi_IIndex_works_when_clustered(bool obsolete)
        {
            var generator    = new SqlServerAnnotationCodeGenerator(new AnnotationCodeGeneratorDependencies());
            var modelBuilder = new ModelBuilder(SqlServerConventionSetBuilder.Build());

            modelBuilder.Entity(
                "Post",
                x =>
            {
                x.Property <int>("Id");
                x.Property <string>("Name");
                if (obsolete)
                {
#pragma warning disable 618
                    x.HasIndex("Name").ForSqlServerIsClustered();
#pragma warning restore 618
                }
                else
                {
                    x.HasIndex("Name").IsClustered();
                }
            });
            var index      = modelBuilder.Model.FindEntityType("Post").GetIndexes().Single();
            var annotation = index.FindAnnotation(SqlServerAnnotationNames.Clustered);

            var result = generator.GenerateFluentApi(index, annotation);

            Assert.Equal("IsClustered", result.Method);

            Assert.Equal(0, result.Arguments.Count);
        }
        public void GenerateFluentApi_IKey_works_when_clustered()
        {
            var generator    = new SqlServerAnnotationCodeGenerator(new AnnotationCodeGeneratorDependencies());
            var modelBuilder = new ModelBuilder(SqlServerConventionSetBuilder.Build());

            modelBuilder.Entity(
                "Post",
                x =>
            {
                x.Property <int>("Id");
                x.HasKey("Id").ForSqlServerIsClustered();
            });
            var key        = modelBuilder.Model.FindEntityType("Post").GetKeys().Single();
            var annotation = key.FindAnnotation(SqlServerAnnotationNames.Clustered);

            var result = generator.GenerateFluentApi(key, annotation);

            Assert.Equal("ForSqlServerIsClustered", result.Method);

            Assert.Equal(0, result.Arguments.Count);
        }
        public void GenerateFluentApi_IIndex_works_with_fillfactor()
        {
            var generator    = new SqlServerAnnotationCodeGenerator(new AnnotationCodeGeneratorDependencies());
            var modelBuilder = new ModelBuilder(SqlServerConventionSetBuilder.Build());

            modelBuilder.Entity(
                "Post",
                x =>
            {
                x.Property <int>("Id");
                x.Property <string>("Name");
                x.HasIndex("Name").HasFillFactor(90);
            });

            var index      = modelBuilder.Model.FindEntityType("Post").GetIndexes().Single();
            var annotation = index.FindAnnotation(SqlServerAnnotationNames.FillFactor);
            var result     = generator.GenerateFluentApi(index, annotation);

            Assert.Equal("HasFillFactor", result.Method);
            Assert.Equal(1, result.Arguments.Count);
            Assert.Equal(90, result.Arguments[0]);
        }