예제 #1
0
        public void ReadOnlyValues()
        {
            StringContainer stringContainer = new StringContainer();

            Assert.IsTrue(ReferenceEquals(stringContainer.ReadOnlyExplicitProperty, stringContainer.ExplicitProperty));
            Assert.IsTrue(ReferenceEquals(stringContainer.ReadOnlyExplicitProperty, stringContainer.ImplicitProperty));
        }
예제 #2
0
        private static void AddListString(List <string> list)
        {
            StringContainer stringContainer = new StringContainer(list.Count);

            list.Add(stringContainer.ReadOnlyExplicitProperty);

            string testArticle;

            testArticle = list[list.Count - 1]; //this is getting the value
            Assert.IsTrue(ReferenceEquals(testArticle, stringContainer.ReadOnlyExplicitProperty));

            string[] array = list.ToArray();
            testArticle = array[list.Count - 1];
            Assert.IsTrue(ReferenceEquals(testArticle, stringContainer.ReadOnlyExplicitProperty));
        }
예제 #3
0
        private static void AddDictionaryString(Dictionary <string, string> dictionary)
        {
            StringContainer stringContainer = new StringContainer(dictionary.Count);

            dictionary.Add(stringContainer.ReadOnlyExplicitProperty, stringContainer.ReadOnlyExplicitProperty);

            string testArticle;

            testArticle = dictionary[stringContainer.ReadOnlyExplicitProperty]; //this is getting the value
            Assert.IsTrue(ReferenceEquals(testArticle, stringContainer.ReadOnlyExplicitProperty));

            dictionary.TryGetValue(stringContainer.ReadOnlyExplicitProperty, out testArticle);
            Assert.IsTrue(ReferenceEquals(testArticle, stringContainer.ReadOnlyExplicitProperty));

            foreach (KeyValuePair <string, string> keyValuePair in dictionary)
            {
                if (keyValuePair.Key.Equals(stringContainer.ReadOnlyExplicitProperty))
                {
                    Assert.IsTrue(ReferenceEquals(keyValuePair.Key, stringContainer.ReadOnlyExplicitProperty));
                    Assert.IsTrue(ReferenceEquals(keyValuePair.Value, stringContainer.ReadOnlyExplicitProperty));
                }
            }
        }