public void IndexGetAndRetrieve() { dynamic d = new IndexableObject(); d[23] = 42; Assert.Equal(42, d[23]); d[1, 2] = "Hello"; Assert.Equal("Hello", d[1, 2]); Assert.Throws <KeyNotFoundException>(() => d[1]); Assert.Throws <KeyNotFoundException>(() => d[2, 3]); Assert.Throws <RuntimeBinderException>(() => d[2] = "Test"); Assert.Throws <RuntimeBinderException>(() => d[2, 4] = 1); Assert.Throws <RuntimeBinderException>(() => d["index"]); Assert.Throws <RuntimeBinderException>(() => d["index"] = 2); Assert.Throws <RuntimeBinderException>(() => { string val = d[23]; }); Assert.Throws <RuntimeBinderException>(() => { int val = d[1, 2]; }); Assert.Throws <RuntimeBinderException>(() => d[1, 2, 3]); }
public void IndexGetAndRetrieve() { dynamic d = new IndexableObject(); d[23] = 42; Assert.Equal(42, d[23]); d[1, 2] = "Hello"; Assert.Equal("Hello", d[1, 2]); Assert.Throws<KeyNotFoundException>(() => d[1]); Assert.Throws<KeyNotFoundException>(() => d[2, 3]); Assert.Throws<RuntimeBinderException>(() => d[2] = "Test"); Assert.Throws<RuntimeBinderException>(() => d[2, 4] = 1); Assert.Throws<RuntimeBinderException>(() => d["index"]); Assert.Throws<RuntimeBinderException>(() => d["index"] = 2); Assert.Throws<RuntimeBinderException>(() => { string val = d[23]; }); Assert.Throws<RuntimeBinderException>(() => { int val = d[1, 2]; }); Assert.Throws<RuntimeBinderException>(() => d[1, 2, 3]); }