// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Dynamic;
namespace Microsoft.AspNetCore.JsonPatch.Internal
{
///
///
/// This class is used specifically to test that JSON patch "replace" operations are functionally equivalent to
/// "add" and "remove" operations applied sequentially using the same path.
///
///
/// This is done by asserting that no value exists for a particular key before setting its value. To replace the
/// value for a key, the key must first be removed, and then re-added with the new value.
///
///
/// See JsonPatch#110 for further details.
///
///
public class WriteOnceDynamicTestObject : DynamicObject
{
private Dictionary _dictionary = new Dictionary();
public object this[string key] { get => ((IDictionary)_dictionary)[key]; set => SetValueForKey(key, value); }
public ICollection Keys => ((IDictionary)_dictionary).Keys;
public ICollection