public async Task BulkRequestWithDeleteOperations_ObjectInitializer_SerializesCorrectly()
        {
            var settings = new ElasticsearchClientSettings();

            settings.DefaultMappingFor <Inferrable>(m => m.IdProperty(p => p.Name).RoutingProperty(r => r.Name).IndexName("test-index"));

            var ms = new MemoryStream();

            var request = new BulkRequest("index-from-request")
            {
                Operations = new BulkOperationsCollection
                {
                    new BulkDeleteOperation("123"),
                    new BulkDeleteOperation("123")
                    {
                        Routing      = "ConfiguredRoute",
                        Index        = "configured-index",
                        RequireAlias = false,
                        Version      = 1,
                        VersionType  = VersionType.External
                    },
                    new BulkDeleteOperation <Inferrable>(Inferrable.Instance),
                    new BulkDeleteOperation <Inferrable>(Inferrable.Instance)
                    {
                        Id               = "OverriddenId",
                        Routing          = "OverriddenRoute",
                        Index            = "overridden-index",
                        IfPrimaryTerm    = 100,
                        IfSequenceNumber = 10,
                        RequireAlias     = false,
                    }
                }
            };

            await request.SerializeAsync(ms, settings);

            ms.Position = 0;
            var reader = new StreamReader(ms);
            var ndjson = reader.ReadToEnd();

            await Verifier.Verify(ndjson, _verifySettings);

            ms = new MemoryStream();
            request.Serialize(ms, settings);

            ms.Position = 0;
            reader      = new StreamReader(ms);
            ndjson      = reader.ReadToEnd();

            await Verifier.Verify(ndjson, _verifySettings);
        }
        public async Task BulkRequestWithUpdateOperations_ObjectInitializer_SerializesCorrectly()
        {
            var settings = new ElasticsearchClientSettings();

            settings.DefaultMappingFor <Inferrable>(m => m.IdProperty(p => p.Name).RoutingProperty(r => r.Name).IndexName("test-index"));

            var ms = new MemoryStream();

            var request = new BulkRequest("index-from-request")
            {
                Operations = new BulkOperationsCollection
                {
                    BulkUpdateOperationFactory.WithScript("123", "test-index", new StoredScriptId("my-script-id")
                    {
                        Params = new Dictionary <string, object> {
                            { "param1", "paramvalue1" }
                        }
                    }),
                    BulkUpdateOperationFactory.WithScript("123", new InlineScript("ctx._source.counter += params.param1")
                    {
                        Language = ScriptLanguage.Painless,
                        Params   = new Dictionary <string, object> {
                            { "param1", 1 }
                        },
                        Options = new Dictionary <string, string> {
                            { "option1", "optionvalue1" }
                        }
                    }),
                    BulkUpdateOperationFactory.WithScript("123", new InlineScript("ctx._source.counter += params.param1")
                    {
                        Language = ScriptLanguage.Painless,
                        Params   = new Dictionary <string, object> {
                            { "param1", 1 }
                        },
                        Options = new Dictionary <string, string> {
                            { "option1", "optionvalue1" }
                        }
                    }, Inferrable.Instance),
                    BulkUpdateOperationFactory.WithScript("123", "configured-index", new InlineScript("ctx._source.counter += params.param1")
                    {
                        Language = ScriptLanguage.Painless,
                        Params   = new Dictionary <string, object> {
                            { "param1", 1 }
                        },
                        Options = new Dictionary <string, string> {
                            { "option1", "optionvalue1" }
                        }
                    }, Inferrable.Instance),
                    // TODO - Partial
                    // TODO - Full operation
                }
            };

            await request.SerializeAsync(ms, settings);

            ms.Position = 0;
            var reader = new StreamReader(ms);
            var ndjson = reader.ReadToEnd();

            await Verifier.Verify(ndjson, _verifySettings);

            ms = new MemoryStream();
            request.Serialize(ms, settings);

            ms.Position = 0;
            reader      = new StreamReader(ms);
            ndjson      = reader.ReadToEnd();

            await Verifier.Verify(ndjson, _verifySettings);
        }