private static void ValidateOperations <T>(PatchOperation patchOperation, PatchOperationType operationType, T value) { Assert.AreEqual(operationType, patchOperation.OperationType); Assert.AreEqual(path, patchOperation.Path); if (!operationType.Equals(PatchOperationType.Remove)) { string expected; CosmosSerializer cosmosSerializer = new CosmosJsonDotNetSerializer(); using (Stream stream = cosmosSerializer.ToStream(value)) { using (StreamReader streamReader = new StreamReader(stream)) { expected = streamReader.ReadToEnd(); } } Assert.IsTrue(patchOperation.TrySerializeValueParameter(new CustomSerializer(), out Stream valueParam)); string actual; using (valueParam) { using (StreamReader streamReader = new StreamReader(valueParam)) { actual = streamReader.ReadToEnd(); } } Assert.AreEqual(expected, actual); } }