Exemplo n.º 1
0
        public void DifferentIndexAccessorTypes()
        {
            var testClass = new TestClass(new Dictionary<string, int>
            {
                { "a", 1 },
                { "b", 2 },
                { "c", 3 }
            });

            Assert.AreEqual(2, testClass["b"]);
            Assert.AreEqual("b", testClass[2]);
        }
Exemplo n.º 2
0
        public void MultipleIndexAccessors()
        {
            var testClass = new TestClass(new Dictionary<string, int>
            {
                { "a", 1 },
                { "b", 2 },
                { "c", 3 }
            });

            Assert.AreEqual(2, testClass["b"]);

            var actual = testClass["b", "c"];
            CollectionAssert.AreEqual(new[] { 2, 3 }, actual.ToArray());
        }
Exemplo n.º 3
0
        public void StringInterningByDefault()
        {
            var test = new TestClass();
            var internedStaticString = string.IsInterned(TestClass.StaticString);
            var internedConstString = string.IsInterned(TestClass.ConstString);
            var internedInstanceString = string.IsInterned(test.InstanceString);

            Assert.IsTrue(ReferenceEquals(internedStaticString, "remembered"));
            Assert.IsTrue(ReferenceEquals(internedStaticString, internedConstString));
            Assert.IsTrue(ReferenceEquals(internedStaticString, internedInstanceString));
            Assert.IsTrue(ReferenceEquals(internedConstString, internedInstanceString));

            Assert.IsFalse(ReferenceEquals(internedStaticString, "different!"));
        }