コード例 #1
0
        public void UpdateCommandText_compiles_inserts()
        {
            var entry = CreateEntry(EntityState.Added);

            var command = CreateModificationCommand("T1", null, new ParameterNameGenerator().GenerateNext, true, null);

            command.AddEntry(entry, true);

            var fakeSqlGenerator = new FakeSqlGenerator(
                RelationalTestHelpers.Instance.CreateContextServices().GetRequiredService <UpdateSqlGeneratorDependencies>());
            var batch = new ModificationCommandBatchFake(fakeSqlGenerator);

            batch.AddCommand(command);

            batch.UpdateCachedCommandTextBase(0);

            Assert.Equal(1, fakeSqlGenerator.AppendBatchHeaderCalls);
            Assert.Equal(1, fakeSqlGenerator.AppendInsertOperationCalls);
        }
コード例 #2
0
        public void UpdateCommandText_compiles_multiple_commands()
        {
            var stateEntry = CreateStateEntry(EntityState.Added);

            var command = new ModificationCommand(new SchemaQualifiedName("T1"), new ParameterNameGenerator(), p => p.Relational());

            command.AddStateEntry(stateEntry);

            var fakeSqlGenerator = new FakeSqlGenerator();

            fakeSqlGenerator.AppendInsertOperationCallback = (sb, c) =>
                                                             sb.Append(c.SchemaQualifiedName.ToString());
            var batch = new ModificationCommandBatchFake(fakeSqlGenerator);

            batch.AddCommand(command);
            batch.AddCommand(command);

            Assert.Equal("..", batch.CommandText);

            Assert.Equal(1, fakeSqlGenerator.AppendBatchHeaderCalls);
        }
        public void UpdateCommandText_compiles_multiple_commands()
        {
            var entry = CreateEntry(EntityState.Added);

            var command = new ModificationCommand("T1", null, new ParameterNameGenerator(), p => p.TestProvider(), new TypedValueBufferFactoryFactory());
            command.AddEntry(entry);

            var fakeSqlGenerator = new FakeSqlGenerator();
            var batch = new ModificationCommandBatchFake(fakeSqlGenerator);
            batch.AddCommand(command);
            batch.AddCommand(command);

            Assert.Equal("..", batch.CommandText);

            Assert.Equal(1, fakeSqlGenerator.AppendBatchHeaderCalls);
        }