public void ReadOnlyValues() { StringContainer stringContainer = new StringContainer(); Assert.IsTrue(ReferenceEquals(stringContainer.ReadOnlyExplicitProperty, stringContainer.ExplicitProperty)); Assert.IsTrue(ReferenceEquals(stringContainer.ReadOnlyExplicitProperty, stringContainer.ImplicitProperty)); }
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)); }
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)); } } }