Example #1
0
        public void ExceptionMessageTest()
        {
            System.Diagnostics.Debug.WriteLine($"> {nameof(Dictionary)}.{nameof(Dictionary.KeyCollection)}.{nameof(ICollection<object>.Add)}(null)");
            try
            {
                var dictionary = new Dictionary();
                ((ICollection <object>)dictionary.Keys).Add(null);
            }
            catch (NotSupportedException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            System.Diagnostics.Debug.WriteLine(string.Empty);

            System.Diagnostics.Debug.WriteLine($"> {nameof(DataPropertyDictionary)}.{nameof(DataPropertyDictionary.KeyCollection)}.{nameof(ICollection<object>.Add)}(null)");
            try
            {
                var dictionary = new DataPropertyDictionary();
                ((ICollection <object>)dictionary.Keys).Add(null);
            }
            catch (NotSupportedException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            System.Diagnostics.Debug.WriteLine(string.Empty);
            System.Diagnostics.Debug.WriteLine(string.Empty);

            System.Diagnostics.Debug.WriteLine($"> {nameof(Dictionary)}.{nameof(Dictionary.KeyCollection)}.{nameof(Dictionary.KeyCollection.CopyTo)}(array, -1)");
            try
            {
                var dictionary = new Dictionary();
                dictionary.Keys.CopyTo(new object[] { }, -1);
            }
            catch (ArgumentOutOfRangeException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            System.Diagnostics.Debug.WriteLine(string.Empty);

            System.Diagnostics.Debug.WriteLine($"> {nameof(DataPropertyDictionary)}.{nameof(DataPropertyDictionary.KeyCollection)}.{nameof(DataPropertyDictionary.KeyCollection.CopyTo)}(array, -1)");
            try
            {
                var dictionary = new DataPropertyDictionary();
                dictionary.Keys.CopyTo(new object[] { }, -1);
            }
            catch (ArgumentOutOfRangeException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            System.Diagnostics.Debug.WriteLine(string.Empty);
            System.Diagnostics.Debug.WriteLine(string.Empty);

            System.Diagnostics.Debug.WriteLine($"> {nameof(Dictionary)}.{nameof(Dictionary.KeyCollection)}.{nameof(Dictionary.KeyCollection.CopyTo)}(shortArray, 0)");
            try
            {
                var dictionary = new Dictionary();
                dictionary.Add(1, 1);
                dictionary.Keys.CopyTo(new object[] { }, 0);
            }
            catch (ArgumentException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            System.Diagnostics.Debug.WriteLine(string.Empty);

            System.Diagnostics.Debug.WriteLine($"> {nameof(DataPropertyDictionary)}.{nameof(DataPropertyDictionary.KeyCollection)}.{nameof(DataPropertyDictionary.KeyCollection.CopyTo)}(shortArray, 0)");
            try
            {
                var dictionary = new DataPropertyDictionary();
                dictionary.Add(1, 1);
                dictionary.Keys.CopyTo(new object[] { }, 0);
            }
            catch (ArgumentException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            System.Diagnostics.Debug.WriteLine(string.Empty);
            System.Diagnostics.Debug.WriteLine(string.Empty);

            System.Diagnostics.Debug.WriteLine($"> {nameof(Dictionary)}.{nameof(Dictionary.KeyCollection)}.{nameof(Dictionary.KeyCollection.CopyTo)}(bottomedUpArray, 0)");
            try
            {
                var dictionary = new Dictionary();
                ((ICollection)dictionary.Keys).CopyTo(Array.CreateInstance(typeof(object), new int[] { 0, }, new int [] { 1, }), 0);
            }
            catch (ArgumentException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            System.Diagnostics.Debug.WriteLine(string.Empty);

            System.Diagnostics.Debug.WriteLine($"> {nameof(DataPropertyDictionary)}.{nameof(DataPropertyDictionary.KeyCollection)}.{nameof(DataPropertyDictionary.KeyCollection.CopyTo)}(bottomedUpArray, 0)");
            try
            {
                var dictionary = new DataPropertyDictionary();
                ((ICollection)dictionary.Keys).CopyTo(Array.CreateInstance(typeof(object), new int[] { 0, }, new int [] { 1, }), 0);
            }
            catch (ArgumentException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            System.Diagnostics.Debug.WriteLine(string.Empty);
            System.Diagnostics.Debug.WriteLine(string.Empty);

            System.Diagnostics.Debug.WriteLine($"> {nameof(Dictionary)}.{nameof(Dictionary.KeyCollection)}.{nameof(Dictionary.KeyCollection.CopyTo)}(rank2Array, 0)");
            try
            {
                var dictionary = new Dictionary();
                ((ICollection)dictionary.Keys).CopyTo(new object[, ] {
                }, 0);
            }
            catch (ArgumentException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            System.Diagnostics.Debug.WriteLine(string.Empty);

            System.Diagnostics.Debug.WriteLine($"> {nameof(DataPropertyDictionary)}.{nameof(DataPropertyDictionary.KeyCollection)}.{nameof(DataPropertyDictionary.KeyCollection.CopyTo)}(rank2Array, 0)");
            try
            {
                var dictionary = new DataPropertyDictionary();
                ((ICollection)dictionary.Keys).CopyTo(new object[, ] {
                }, 0);
            }
            catch (ArgumentException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            System.Diagnostics.Debug.WriteLine(string.Empty);
            System.Diagnostics.Debug.WriteLine(string.Empty);

            System.Diagnostics.Debug.WriteLine($"> {nameof(Dictionary)}.{nameof(Dictionary.KeyCollection)}.{nameof(Dictionary.KeyCollection.CopyTo)}(mismatchTypedArray, 0)");
            try
            {
                var dictionary = new Dictionary();
                ((ICollection)dictionary.Keys).CopyTo(new int[] { }, 0);
            }
            catch (ArgumentException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            System.Diagnostics.Debug.WriteLine(string.Empty);

            System.Diagnostics.Debug.WriteLine($"> {nameof(DataPropertyDictionary)}.{nameof(DataPropertyDictionary.KeyCollection)}.{nameof(DataPropertyDictionary.KeyCollection.CopyTo)}(mismatchTypedArray, 0)");
            try
            {
                var dictionary = new DataPropertyDictionary();
                ((ICollection)dictionary.Keys).CopyTo(new int[] { }, 0);
            }
            catch (ArgumentException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            System.Diagnostics.Debug.WriteLine(string.Empty);
            System.Diagnostics.Debug.WriteLine(string.Empty);

            System.Diagnostics.Debug.WriteLine($"> {nameof(Dictionary)}.{nameof(Dictionary.ValueCollection)}.{nameof(ICollection<object>.Add)}(null)");
            try
            {
                var dictionary = new Dictionary();
                ((ICollection <object>)dictionary.Values).Add(null);
            }
            catch (NotSupportedException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            System.Diagnostics.Debug.WriteLine(string.Empty);

            System.Diagnostics.Debug.WriteLine($"> {nameof(DataPropertyDictionary)}.{nameof(DataPropertyDictionary.ItemCollection)}.{nameof(ICollection<object>.Add)}(null)");
            try
            {
                var dictionary = new DataPropertyDictionary();
                ((ICollection <DataProperty <object> >)dictionary.Items).Add(null);
            }
            catch (NotSupportedException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            System.Diagnostics.Debug.WriteLine(string.Empty);
            System.Diagnostics.Debug.WriteLine(string.Empty);

            System.Diagnostics.Debug.WriteLine($"> {nameof(Dictionary)}.{nameof(Dictionary.Add)}(object, object) on iteration");
            try
            {
                var dictionary = new DataPropertyDictionary();
                dictionary.Add(new object(), new object());
                foreach (var item in dictionary)
                {
                    dictionary.Add(new object(), new object());
                }
            }
            catch (InvalidOperationException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            System.Diagnostics.Debug.WriteLine(string.Empty);

            System.Diagnostics.Debug.WriteLine($"> {nameof(DataPropertyPedigree)}.{nameof(DataPropertyPedigree.Add)}(object) on iteration");
            try
            {
                var pedigree = new DataPropertyPedigree();
                pedigree.Add(new object());
                foreach (var item in pedigree.Tree.Root.Children)
                {
                    pedigree.Add(new object());
                }
            }
            catch (InvalidOperationException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            System.Diagnostics.Debug.WriteLine(string.Empty);
            System.Diagnostics.Debug.WriteLine(string.Empty);
        }
 public DebugView(DataPropertyDictionary <TKey, TValue> target)
 {
     this.target = target;
 }