public void TestBasicReadAndWriteOperationsWithCustomComparer() { var expected = new Dictionary <string, object>(); var actual = new AttributesTable(StringComparer.OrdinalIgnoreCase); // test everything after a serialize + deserialize round-trip ExpectedAndActual.RoundTrip(ref expected, ref actual); expected.Add("hello", "hi"); actual.Add("HELLO", "hi"); AssertEqual(expected, actual, ignoreCase: true); AttributesTable.AddAttributeWithIndexer = false; Assert.That(() => actual["Oh"] = 321, Throws.ArgumentException); AssertEqual(expected, actual, ignoreCase: true); AttributesTable.AddAttributeWithIndexer = true; expected["oh"] = 321; Assert.That(() => actual["oH"] = 321, Throws.Nothing); AssertEqual(expected, actual, ignoreCase: true); AssertEqual(expected, actual, ignoreCase: true); expected.Remove("hello"); actual.DeleteAttribute("hELlo"); AssertEqual(expected, actual, ignoreCase: true); Assert.That(() => actual.DeleteAttribute("heLLo"), Throws.ArgumentException); AssertEqual(expected, actual, ignoreCase: true); expected.Add("hello", new object()); actual.Add("hEllO", expected["hello"]); AssertEqual(expected, actual, ignoreCase: true); expected["hello"] = Guid.NewGuid(); actual["HelLo"] = expected["hello"]; AssertEqual(expected, actual, ignoreCase: true); Assert.That(() => actual.Add("hEllo", "oh, hi there"), Throws.ArgumentException); AssertEqual(expected, actual, ignoreCase: true); Assert.That(() => actual["a key that shouldn't exist"], Throws.ArgumentException); Assert.That(() => actual.GetType("a key that shouldn't exist"), Throws.InstanceOf <ArgumentOutOfRangeException>()); AssertEqual(expected, actual, ignoreCase: true); }