Пример #1
0
            public async Task <TResult> RawDeleteJsonAsync <TResult>(string url, object payload)
                where TResult : BlittableJsonReaderBase
            {
                using (var session = _store.OpenSession())
                {
                    var payloadJson = EntityToBlittable.ConvertCommandToBlittable(payload, session.Advanced.Context);

                    var command = new JsonCommandWithPayload <TResult>(url, HttpMethod.Delete, payloadJson);

                    await RequestExecutor.ExecuteAsync(command, Context);

                    return(command.Result);
                }
            }
Пример #2
0
            public override HttpRequestMessage CreateRequest(JsonOperationContext ctx, ServerNode node, out string url)
            {
                url = $"{node.Url}/admin/migrate/offline";

                return(new HttpRequestMessage
                {
                    Method = HttpMethod.Post,
                    Content = new BlittableJsonContent(stream =>
                    {
                        var config = EntityToBlittable.ConvertCommandToBlittable(_configuration, ctx);
                        ctx.Write(stream, config);
                    })
                });
            }
Пример #3
0
            private void PrepareRequestWithMultipleCounters(StringBuilder pathBuilder, HttpRequestMessage request, JsonOperationContext ctx)
            {
                var uniqueNames = GetOrderedUniqueNames(out int sumLength);

                // if it is too big, we drop to POST (note that means that we can't use the HTTP cache any longer)
                // we are fine with that, such requests are going to be rare
                if (sumLength < 1024)
                {
                    foreach (var counter in uniqueNames)
                    {
                        pathBuilder.Append("&counter=").Append(Uri.EscapeDataString(counter ?? string.Empty));
                    }
                }
                else
                {
                    request.Method = HttpMethod.Post;

                    var docOps = new DocumentCountersOperation
                    {
                        DocumentId = _docId,
                        Operations = new List <CounterOperation>()
                    };

                    foreach (var counter in uniqueNames)
                    {
                        docOps.Operations.Add(new CounterOperation
                        {
                            Type        = CounterOperationType.Get,
                            CounterName = counter
                        });
                    }

                    var batch = new CounterBatch
                    {
                        Documents = new List <DocumentCountersOperation>
                        {
                            docOps
                        },
                        ReplyWithAllNodesValues = _returnFullResults
                    };

                    request.Content = new BlittableJsonContent(stream =>
                    {
                        var config = EntityToBlittable.ConvertCommandToBlittable(batch, ctx);

                        ctx.Write(stream, config);
                    });
                }
            }
Пример #4
0
        public void SerializeAndDeserialize_MergedBatchPutCommandTest()
        {
            using (var database = CreateDocumentDatabase())
                using (database.DocumentsStorage.ContextPool.AllocateOperationContext(out DocumentsOperationContext context))
                {
                    //Arrange
                    var data     = new { ParentProperty = new { NestedProperty = "Some Value" } };
                    var expected = new DatabaseDestination.MergedBatchPutCommand(database, BuildVersionType.V4, null);
                    var document = new DocumentItem
                    {
                        Document = new Document
                        {
                            ChangeVector = "Some Change Vector",
                            Data         = EntityToBlittable.ConvertCommandToBlittable(data, context),
                            Id           = context.GetLazyString("Some Id")
                        }
                    };
                    expected.Add(document);

                    //Action
                    var jsonSerializer = GetJsonSerializer();
                    BlittableJsonReaderObject blitCommand;
                    using (var writer = new BlittableJsonWriter(context))
                    {
                        var dto = expected.ToDto(context);
                        jsonSerializer.Serialize(writer, dto);
                        writer.FinalizeDocument();

                        blitCommand = writer.CreateReader();
                    }
                    var fromStream = SerializeTestHelper.SimulateSavingToFileAndLoading(context, blitCommand);
                    DatabaseDestination.MergedBatchPutCommand actual;
                    using (var reader = new BlittableJsonReader(context))
                    {
                        reader.Init(fromStream);

                        var dto = jsonSerializer.Deserialize <DatabaseDestination.MergedBatchPutCommandDto>(reader);
                        actual = dto.ToCommand(context, database);
                    }

                    //Assert
                    var expectedDoc = expected.Documents[0].Document;
                    var actualDoc   = actual.Documents[0].Document;

                    Assert.Equal(expectedDoc.Id, actualDoc.Id);
                    Assert.Equal(expectedDoc.ChangeVector, actualDoc.ChangeVector);
                    Assert.Equal(expectedDoc.Data, actualDoc.Data);
                }
        }
Пример #5
0
            public override HttpRequestMessage CreateRequest(JsonOperationContext ctx, ServerNode node, out string url)
            {
                url = $"{node.Url}/databases/{node.Database}/counters";

                return(new HttpRequestMessage
                {
                    Method = HttpMethod.Post,

                    Content = new BlittableJsonContent(stream =>
                    {
                        var config = EntityToBlittable.ConvertCommandToBlittable(_counterBatch, ctx);
                        ctx.Write(stream, config);
                    })
                });
            }
Пример #6
0
            public async Task ExecuteJsonAsync(string url, HttpMethod method, object payload)
            {
                using (var session = _store.OpenSession())
                {
                    BlittableJsonReaderObject payloadJson = null;
                    if (payload != null)
                    {
                        payloadJson = EntityToBlittable.ConvertCommandToBlittable(payload, session.Advanced.Context);
                    }

                    var command = new JsonCommandWithPayload <BlittableJsonReaderObject>(url, method, payloadJson);

                    await RequestExecutor.ExecuteAsync(command, Context);
                }
            }
Пример #7
0
        public void SerializeAndDeserialize_MergedInsertBulkCommandTest()
        {
            using (var database = CreateDocumentDatabase())
                using (database.DocumentsStorage.ContextPool.AllocateOperationContext(out DocumentsOperationContext context))
                {
                    //Arrange
                    var data     = new { ParentProperty = new { NestedProperty = "Some Value" } };
                    var commands = new[]
                    {
                        new BatchRequestParser.CommandData
                        {
                            Id           = "Some Id",
                            ChangeVector = context.GetLazyString("Some Lazy String"),
                            Document     = EntityToBlittable.ConvertCommandToBlittable(data, context),
                            Patch        = new PatchRequest("Some Script", PatchRequestType.None)
                        }
                    };
                    var expected = new BulkInsertHandler.MergedInsertBulkCommand
                    {
                        NumberOfCommands = commands.Length,
                        Commands         = commands
                    };

                    //Action
                    var jsonSerializer = GetJsonSerializer();
                    BlittableJsonReaderObject blitCommand;
                    using (var writer = new BlittableJsonWriter(context))
                    {
                        var dto = expected.ToDto(context);
                        jsonSerializer.Serialize(writer, dto);
                        writer.FinalizeDocument();

                        blitCommand = writer.CreateReader();
                    }
                    var fromStream = SerializeTestHelper.SimulateSavingToFileAndLoading(context, blitCommand);
                    BulkInsertHandler.MergedInsertBulkCommand actual;
                    using (var reader = new BlittableJsonReader(context))
                    {
                        reader.Init(fromStream);

                        var dto = jsonSerializer.Deserialize <MergedInsertBulkCommandDto>(reader);
                        actual = dto.ToCommand(context, database);
                    }

                    //Assert
                    Assert.Equal(expected, actual, new CustomComparer <BulkInsertHandler.MergedInsertBulkCommand>(context));
                }
        }
        public void Clone_WhenContainItemsOfDouble_ShouldBeEqualToOrigin()
        {
            //Arrange
            using (Server.ServerStore.ContextPool.AllocateOperationContext(out JsonOperationContext context))
            {
                var data         = new { Property = new[] { 1.1, 2.3 } };
                var readerObject = EntityToBlittable.ConvertCommandToBlittable(data, context);
                readerObject.TryGet(nameof(data.Property), out BlittableJsonReaderArray expected);

                //Action
                var actual = expected.Clone(context);

                //Assert
                Assert.Equal(expected, actual);
            }
        }
Пример #9
0
            public override HttpRequestMessage CreateRequest(JsonOperationContext ctx, ServerNode node, out string url)
            {
                url = $"{node.Url}/databases/{node.Database}/admin/etl?id={_taskId}";

                var request = new HttpRequestMessage
                {
                    Method  = HttpMethod.Put,
                    Content = new BlittableJsonContent(stream =>
                    {
                        var config = EntityToBlittable.ConvertCommandToBlittable(_configuration, ctx);
                        ctx.Write(stream, config);
                    })
                };

                return(request);
            }
Пример #10
0
        public void SerializeAndDeserialize_PutResolvedConflictsCommand()
        {
            using (Server.ServerStore.ContextPool.AllocateOperationContext(out JsonOperationContext context))
                using (var database = CreateDocumentDatabase())
                {
                    //Arrange
                    var resolvedConflicts = new List <(DocumentConflict, long)>
                    {
                        (new DocumentConflict
                        {
                            Id = context.GetLazyString("Some id"),
                            LowerId = context.GetLazyString("Some lower id"),
                            Collection = context.GetLazyString("Some collection"),
                            Doc = EntityToBlittable.ConvertCommandToBlittable(new { SomeName = "Some Value" }, context)
                        }, 10)
                    };

                    var expected = new ResolveConflictOnReplicationConfigurationChange.PutResolvedConflictsCommand(
                        null, resolvedConflicts, null);
                    var expectedDto = expected.ToDto(context);

                    //Serialize
                    var jsonSerializer = GetJsonSerializer();
                    BlittableJsonReaderObject blitCommand;
                    using (var writer = new BlittableJsonWriter(context))
                    {
                        jsonSerializer.Serialize(writer, expectedDto);
                        writer.FinalizeDocument();

                        blitCommand = writer.CreateReader();
                    }

                    var fromStream = SerializeTestHelper.SimulateSavingToFileAndLoading(context, blitCommand);

                    //Deserialize
                    ResolveConflictOnReplicationConfigurationChange.PutResolvedConflictsCommand actual;
                    using (var reader = new BlittableJsonReader(context))
                    {
                        reader.Init(fromStream);

                        var actualDto = jsonSerializer.Deserialize <PutResolvedConflictsCommandDto>(reader);

                        //Assert
//                    Assert.Equal(expectedDto.)
                    }
                }
        }
Пример #11
0
        protected override void PersistMapFields(JsonOperationContext context, BlittableJsonTextWriter writer)
        {
            writer.WritePropertyName(nameof(MapFields));
            writer.WriteStartArray();
            var first = true;

            foreach (var field in MapFields.Values.Select(x => x.As <AutoIndexField>()))
            {
                if (first == false)
                {
                    writer.WriteComma();
                }

                writer.WriteStartObject();

                writer.WritePropertyName(nameof(field.Name));
                writer.WriteString(field.Name);
                writer.WriteComma();

                writer.WritePropertyName(nameof(field.Indexing));
                writer.WriteString(field.Indexing.ToString());
                writer.WriteComma();

                writer.WritePropertyName(nameof(field.Aggregation));
                writer.WriteInteger((int)field.Aggregation);
                writer.WriteComma();

                writer.WritePropertyName(nameof(field.Spatial));
                if (field.Spatial == null)
                {
                    writer.WriteNull();
                }
                else
                {
                    writer.WriteObject(EntityToBlittable.ConvertCommandToBlittable(field.Spatial, context));
                }
                writer.WriteComma();

                writer.WritePropertyName(nameof(field.HasSuggestions));
                writer.WriteBool(field.HasSuggestions);

                writer.WriteEndObject();

                first = false;
            }
            writer.WriteEndArray();
        }
Пример #12
0
            public CompactDatabaseCommand(DocumentConventions conventions, JsonOperationContext context, CompactSettings compactSettings)
            {
                if (conventions == null)
                {
                    throw new ArgumentNullException(nameof(conventions));
                }
                if (compactSettings == null)
                {
                    throw new ArgumentNullException(nameof(compactSettings));
                }
                if (context == null)
                {
                    throw new ArgumentNullException(nameof(context));
                }

                _compactSettings = EntityToBlittable.ConvertCommandToBlittable(compactSettings, context);
            }
Пример #13
0
            public SetIndexPriorityCommand(DocumentConventions conventions, JsonOperationContext context, Parameters parameters)
            {
                if (conventions == null)
                {
                    throw new ArgumentNullException(nameof(conventions));
                }
                if (context == null)
                {
                    throw new ArgumentNullException(nameof(context));
                }
                if (parameters == null)
                {
                    throw new ArgumentNullException(nameof(parameters));
                }

                _parameters = EntityToBlittable.ConvertCommandToBlittable(parameters, context);
            }
Пример #14
0
            public PutClientConfigurationCommand(DocumentConventions conventions, JsonOperationContext context, ClientConfiguration configuration)
            {
                if (conventions == null)
                {
                    throw new ArgumentNullException(nameof(conventions));
                }
                if (configuration == null)
                {
                    throw new ArgumentNullException(nameof(configuration));
                }
                if (context == null)
                {
                    throw new ArgumentNullException(nameof(context));
                }

                _configuration = EntityToBlittable.ConvertCommandToBlittable(configuration, context);
            }
Пример #15
0
                public DeleteRevisionsCommand(DocumentConventions conventions, JsonOperationContext context, AdminRevisionsHandler.Parameters parameters)
                {
                    if (conventions == null)
                    {
                        throw new ArgumentNullException(nameof(conventions));
                    }
                    if (context == null)
                    {
                        throw new ArgumentNullException(nameof(context));
                    }
                    if (parameters == null)
                    {
                        throw new ArgumentNullException(nameof(parameters));
                    }

                    _parameters = EntityToBlittable.ConvertCommandToBlittable(parameters, context);
                }
Пример #16
0
        public void SerializeAndDeserialize_PatchDocumentCommandTest()
        {
            using (var database = CreateDocumentDatabase())
                using (database.DocumentsStorage.ContextPool.AllocateOperationContext(out DocumentsOperationContext context))
                {
                    //Arrange
                    var data         = new { ParentProperty = new { NestedProperty = "Some Value" } };
                    var arg          = EntityToBlittable.ConvertCommandToBlittable(data, context);
                    var patchRequest = new PatchRequest("", PatchRequestType.None);

                    var expected = new PatchDocumentCommand(
                        context,
                        "Some Id",
                        context.GetLazyString("Some Lazy String"),
                        false,
                        (patchRequest, arg),
                        (null, null),
                        database,
                        false, false, false, false);

                    //Action
                    var jsonSerializer = GetJsonSerializer();
                    BlittableJsonReaderObject blitCommand;
                    using (var writer = new BlittableJsonWriter(context))
                    {
                        var dto = expected.ToDto(context);
                        jsonSerializer.Serialize(writer, dto);
                        writer.FinalizeDocument();

                        blitCommand = writer.CreateReader();
                    }
                    var fromStream = SerializeTestHelper.SimulateSavingToFileAndLoading(context, blitCommand);
                    PatchDocumentCommand actual;
                    using (var reader = new BlittableJsonReader(context))
                    {
                        reader.Init(fromStream);

                        var dto = jsonSerializer.Deserialize <PatchDocumentCommandDto>(reader);
                        actual = dto.ToCommand(context, database);
                    }

                    //Assert
                    Assert.Equal(expected, actual, new CustomComparer <PatchDocumentCommand>(context));
                }
        }
Пример #17
0
            private void PrepareRequestWithMultipleCounters(StringBuilder pathBuilder, HttpRequestMessage request, JsonOperationContext ctx)
            {
                var uniqueNames = new HashSet <string>(_counters);

                // if it is too big, we drop to POST (note that means that we can't use the HTTP cache any longer)
                // we are fine with that, requests to load more than 1024 counters are going to be rare
                if (uniqueNames.Sum(x => x?.Length ?? 0) < 1024)
                {
                    uniqueNames.ApplyIfNotNull(counter => pathBuilder.Append("&counter=").Append(Uri.EscapeDataString(counter ?? string.Empty)));
                }
                else
                {
                    request.Method = HttpMethod.Post;

                    var docOps = new DocumentCountersOperation
                    {
                        DocumentId = _docId,
                        Operations = new List <CounterOperation>()
                    };

                    foreach (var counter in uniqueNames)
                    {
                        docOps.Operations.Add(new CounterOperation
                        {
                            Type        = CounterOperationType.Get,
                            CounterName = counter
                        });
                    }

                    var batch = new CounterBatch
                    {
                        Documents = new List <DocumentCountersOperation>
                        {
                            docOps
                        }
                    };

                    request.Content = new BlittableJsonContent(stream =>
                    {
                        var config = EntityToBlittable.ConvertCommandToBlittable(batch, ctx);

                        ctx.Write(stream, config);
                    });
                }
            }
Пример #18
0
 public ImportCommand(DocumentConventions conventions, JsonOperationContext context, DatabaseSmugglerImportOptions options, Stream stream, long operationId)
 {
     _stream = stream ?? throw new ArgumentNullException(nameof(stream));
     if (conventions == null)
     {
         throw new ArgumentNullException(nameof(conventions));
     }
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     if (context == null)
     {
         throw new ArgumentNullException(nameof(context));
     }
     _options     = EntityToBlittable.ConvertCommandToBlittable(options, context);
     _operationId = operationId;
 }
Пример #19
0
 public ExportCommand(DocumentConventions conventions, JsonOperationContext context, DatabaseSmugglerExportOptions options, Func <Stream, Task> handleStreamResponse, long operationId)
 {
     if (conventions == null)
     {
         throw new ArgumentNullException(nameof(conventions));
     }
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     if (context == null)
     {
         throw new ArgumentNullException(nameof(context));
     }
     _handleStreamResponse = handleStreamResponse ?? throw new ArgumentNullException(nameof(handleStreamResponse));
     _options     = EntityToBlittable.ConvertCommandToBlittable(options, context);
     _operationId = operationId;
 }
            public ToggleDatabaseStateCommand(DocumentConventions conventions, JsonOperationContext context, Parameters parameters, bool disable)
            {
                if (conventions == null)
                {
                    throw new ArgumentNullException(nameof(conventions));
                }
                if (context == null)
                {
                    throw new ArgumentNullException(nameof(context));
                }
                if (parameters == null)
                {
                    throw new ArgumentNullException(nameof(parameters));
                }

                _disable    = disable;
                _parameters = EntityToBlittable.ConvertCommandToBlittable(parameters, context);
            }
Пример #21
0
            public override HttpRequestMessage CreateRequest(JsonOperationContext ctx, ServerNode node, out string url)
            {
                url = $"{node.Url}/admin/databases?name={_databaseName}";

                url += "&replicationFactor=" + _replicationFactor;
                var databaseDocument = EntityToBlittable.ConvertCommandToBlittable(_databaseRecord, ctx);

                var request = new HttpRequestMessage
                {
                    Method  = HttpMethod.Put,
                    Content = new BlittableJsonContent(stream =>
                    {
                        ctx.Write(stream, databaseDocument);
                    })
                };

                return(request);
            }
Пример #22
0
        public void IncrementCounter_WhenDocumentHasNoMetadata_ShouldWork()
        {
            //Arrange
            var user = new User {
                Name = "August"
            };
            const string id = "users/A-1";

            using (var store = GetDocumentStore())
                using (var context = JsonOperationContext.ShortTermSingleUse())
                {
                    var requestExecuter = store.GetRequestExecutor();
                    var blitUser        = EntityToBlittable.ConvertCommandToBlittable(user, context);
                    requestExecuter.Execute(new PutDocumentCommand(id, null, blitUser), context);

                    //Action
                    store.Operations.Send(new CounterBatchOperation(new CounterBatch
                    {
                        Documents = new List <DocumentCountersOperation>
                        {
                            new DocumentCountersOperation
                            {
                                DocumentId = id,
                                Operations = new List <CounterOperation>
                                {
                                    new CounterOperation
                                    {
                                        Type        = CounterOperationType.Increment,
                                        CounterName = "likes",
                                        Delta       = 54
                                    }
                                }
                            }
                        }
                    }));

                    //Assert
                    using (var session = store.OpenSession())
                    {
                        var counters = session.CountersFor(id);
                        Assert.Equal(54, counters.Get("likes"));
                    }
                }
        }
Пример #23
0
        public override HttpRequestMessage CreateRequest(JsonOperationContext ctx, ServerNode node, out string url)
        {
            url = $"{node.Url}/databases/{node.Database}/subscriptions";
            if (_id != null)
            {
                url += "?id=" + _id;
            }
            var request = new HttpRequestMessage
            {
                Method  = HttpMethod.Put,
                Content = new BlittableJsonContent(stream =>
                {
                    ctx.Write(stream,
                              EntityToBlittable.ConvertCommandToBlittable(_options, ctx));
                })
            };

            return(request);
        }
Пример #24
0
        public async Task DeleteDocumentWithoutResolvedFlagAfterEnableRevisions()
        {
            using (var store = GetDocumentStore())
            {
                using (var session = store.OpenSession())
                {
                    session.Store(new User {
                        Name = "Toli"
                    }, "users/1");
                    session.SaveChanges();
                }

                var configuration = new RevisionsConfiguration
                {
                    Default = new RevisionsCollectionConfiguration
                    {
                        Disabled = false,
                        MinimumRevisionsToKeep = 5
                    }
                };
                var database = await GetDatabase(store.Database);

                using (var context = JsonOperationContext.ShortTermSingleUse())
                {
                    var configurationJson = EntityToBlittable.ConvertCommandToBlittable(configuration, context);
                    var(index, _) = await database.ServerStore.ModifyDatabaseRevisions(context, store.Database, configurationJson, Guid.NewGuid().ToString());

                    await database.RachisLogIndexNotifications.WaitForIndexNotification(index, database.ServerStore.Engine.OperationTimeout);
                }
                using (var session = store.OpenSession())
                {
                    session.Delete("users/1");
                    session.SaveChanges();
                }

                using (database.DocumentsStorage.ContextPool.AllocateOperationContext(out DocumentsOperationContext context))
                {
                    context.OpenReadTransaction();
                    var count = database.DocumentsStorage.RevisionsStorage.GetNumberOfRevisionDocuments(context);
                    Assert.Equal(2, count);
                }
            }
        }
Пример #25
0
            public override HttpRequestMessage CreateRequest(JsonOperationContext ctx, ServerNode node, out string url)
            {
                url = $"{node.Url}/admin/certificates/edit";

                var definition = new CertificateDefinition
                {
                    Thumbprint        = _thumbprint,
                    Permissions       = _permissions,
                    SecurityClearance = _clearance,
                    Name = _name
                };
                var request = new HttpRequestMessage
                {
                    Method  = HttpMethod.Post,
                    Content = new BlittableJsonContent(stream => ctx.Write(stream, EntityToBlittable.ConvertCommandToBlittable(definition, ctx)))
                };

                return(request);
            }
Пример #26
0
        public async Task DeleteDocumentWithResolvedFlagAfterEnableRevisions()
        {
            using (var store = GetDocumentStore())
            {
                using (var stream = GetDump("RavenDB_15898.1.ravendbdump"))
                {
                    var operation = await store.Smuggler.ImportAsync(new DatabaseSmugglerImportOptions(), stream);

                    await operation.WaitForCompletionAsync(TimeSpan.FromMinutes(1));
                }
                var configuration = new RevisionsConfiguration
                {
                    Default = new RevisionsCollectionConfiguration
                    {
                        Disabled = false,
                        MinimumRevisionsToKeep = 5
                    }
                };
                var database = await GetDatabase(store.Database);

                using (var context = JsonOperationContext.ShortTermSingleUse())
                {
                    var configurationJson = EntityToBlittable.ConvertCommandToBlittable(configuration, context);
                    var(index, _) = await database.ServerStore.ModifyDatabaseRevisions(context, store.Database, configurationJson, Guid.NewGuid().ToString());

                    await database.RachisLogIndexNotifications.WaitForIndexNotification(index, database.ServerStore.Engine.OperationTimeout);
                }

                using (var session = store.OpenSession())
                {
                    session.Delete("users/1");
                    session.SaveChanges();
                }

                using (database.DocumentsStorage.ContextPool.AllocateOperationContext(out DocumentsOperationContext context))
                {
                    context.OpenReadTransaction();
                    var count = database.DocumentsStorage.RevisionsStorage.GetNumberOfRevisionDocuments(context);
                    Assert.Equal(2, count);
                }
            }
        }
Пример #27
0
 public IndexHasChangedCommand(DocumentConventions conventions, JsonOperationContext context, IndexDefinition definition)
 {
     if (conventions == null)
     {
         throw new ArgumentNullException(nameof(conventions));
     }
     if (definition == null)
     {
         throw new ArgumentNullException(nameof(definition));
     }
     if (string.IsNullOrWhiteSpace(definition.Name))
     {
         throw new ArgumentNullException(nameof(definition.Name));
     }
     if (context == null)
     {
         throw new ArgumentNullException(nameof(context));
     }
     _definition = EntityToBlittable.ConvertCommandToBlittable(definition, context);
 }
        public void Clone_WhenContainItemsOfObjects_AndOriginAndCloneOnDifferentContext_ShouldBeEqualToOrigin()
        {
            //Arrange
            using (Server.ServerStore.ContextPool.AllocateOperationContext(out JsonOperationContext originContext))
                using (Server.ServerStore.ContextPool.AllocateOperationContext(out JsonOperationContext cloneContext))
                {
                    var data = new
                    {
                        Property = new[] { new { Prop = "Value1" }, new { Prop = "Value2" } }
                    };
                    var readerObject = EntityToBlittable.ConvertCommandToBlittable(data, originContext);
                    readerObject.TryGet(nameof(data.Property), out BlittableJsonReaderArray expected);

                    //Action
                    var actual = expected.Clone(cloneContext);

                    //Assert
                    Assert.Equal(expected, actual);
                }
        }
Пример #29
0
 public ExportCommand(DocumentConventions conventions, JsonOperationContext context, DatabaseSmugglerExportOptions options, Func <Stream, Task> handleStreamResponse, long operationId, TaskCompletionSource <object> tcs, string nodeTag)
 {
     if (conventions == null)
     {
         throw new ArgumentNullException(nameof(conventions));
     }
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     if (context == null)
     {
         throw new ArgumentNullException(nameof(context));
     }
     _handleStreamResponse = handleStreamResponse ?? throw new ArgumentNullException(nameof(handleStreamResponse));
     _options        = EntityToBlittable.ConvertCommandToBlittable(options, context);
     _operationId    = operationId;
     _tcs            = tcs ?? throw new ArgumentNullException(nameof(tcs));
     SelectedNodeTag = nodeTag;
 }
Пример #30
0
 public ImportCommand(DocumentConventions conventions, JsonOperationContext context, DatabaseSmugglerImportOptions options, Stream stream, long operationId, TaskCompletionSource <object> tcs, DatabaseSmuggler parent)
 {
     _stream = stream ?? throw new ArgumentNullException(nameof(stream));
     if (conventions == null)
     {
         throw new ArgumentNullException(nameof(conventions));
     }
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     if (context == null)
     {
         throw new ArgumentNullException(nameof(context));
     }
     _options     = EntityToBlittable.ConvertCommandToBlittable(options, context);
     _operationId = operationId;
     _tcs         = tcs ?? throw new ArgumentNullException(nameof(tcs));
     _parent      = parent ?? throw new ArgumentNullException(nameof(parent));
 }