public async Task InitializeAsync() { var collectionLink = await Client.GetOrCreateCollectionAsync(Configuration.Collection, Configuration.CollectionTier); storedProcedureLink = await Client.CreateStoredProcedureAsync(collectionLink, Configuration.StoredProcName, Configuration.StoredProcBody); buffer = new FastForwardBuffer <BulkItemSurrogate>(); surrogate = new LengthCappedEnumerableSurrogate(buffer, Configuration.BatchSize, Configuration.MaxScriptSize); activeBulkItems = new ConcurrentDictionary <int, TaskCompletionSource <object> >(); flushSemaphore = new SemaphoreSlim(1, 1); }
public void SerializeLongCollection_CapedAfterSpecifiedLimit() { var data = new[] { new { Field1 = "Hello", Field2 = "World!" }, new { Field1 = "Next", Field2 = "Item" }, new { Field1 = "Should", Field2 = "cap" } }; var cappable = new LengthCappedEnumerableSurrogate(data, 10, 80); var serialized = JsonConvert.SerializeObject(cappable, new LengthCappedEnumerableJsonConverter()); Assert.AreEqual("[{\"Field1\":\"Hello\",\"Field2\":\"World!\"},{\"Field1\":\"Next\",\"Field2\":\"Item\"}]", serialized, TestResources.InvalidCappedEnumerableSerialization); }