private void Reset() { _command?.Dispose(); _command = new BatchHandler.MergedBatchCommand(_context.DocumentDatabase) { AttachmentStreamsTempFile = _context.DocumentDatabase.DocumentsStorage.AttachmentsStorage.GetTempFile("put") }; _commands.Clear(); _attachmentStreams.Clear(); }
private void Reset() { _rowsRead = SqlReader.RowsRead; _time.Restart(); _command?.Dispose(); _command = new BatchHandler.MergedBatchCommand { Database = _context.DocumentDatabase, AttachmentStreamsTempFile = _context.DocumentDatabase.DocumentsStorage.AttachmentsStorage.GetTempFile("put") }; _commands.Clear(); _attachmentStreams.Clear(); }
public async Task SerializeAndDeserialize_MergedBatchCommandCommandTest() { using (Server.ServerStore.ContextPool.AllocateOperationContext(out JsonOperationContext 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 = DocumentConventions.Default.Serialization.DefaultConverter.ToBlittable(data, context), Patch = new PatchRequest("Some Script", PatchRequestType.None) } }; var expected = new BatchHandler.MergedBatchCommand(null) { ParsedCommands = 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 = await SerializeTestHelper.SimulateSavingToFileAndLoadingAsync(context, blitCommand); BatchHandler.MergedBatchCommand actual; using (var reader = new BlittableJsonReader(context)) { reader.Initialize(fromStream); var dto = jsonSerializer.Deserialize <MergedBatchCommandDto>(reader); actual = dto.ToCommand(null, null); } //Assert Assert.Equal(expected, actual, new CustomComparer <BatchHandler.MergedBatchCommand>(context)); } }