DataSharp/Mathematics/FunctionalityTest.cs
/// <summary>
/// Functionality test method for the SetHelper.GetComplement() method.
/// </summary>
Functionality test method for the SetHelper.GetComplement() method.
Functionality test method for the SetHelper . GetComplement () method .
public static void ComplementDemo()
        {
            string[] strings = { "123", "456", "789", "111", "222", "333" };
            SortedSet<string> complete = new SortedSet<string>(strings);
            Console.WriteLine("The contents in the complete set:");
            foreach (string s in complete)
                Console.Write(s + " ");
            Console.WriteLine();
            SortedSet<string> wrongSubset = new SortedSet<string> { "qwe" };
            Console.WriteLine("The contents in the wrong subset: qwe.");
            try
            {
                ISet<string> wrongComplement = SetHelper.GetComplement(complete, wrongSubset);
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine("Wrong subset error catched: " + ex.Message);
            }
            SortedSet<string> correctSubset = new SortedSet<string>();
            for (int i = 0; i < 3; i++)
                correctSubset.Add(strings[i]);
            ISet<string> complement = SetHelper.GetComplement(complete, correctSubset);
            Console.Write("The contents in the correct subset:");
            foreach (string s in correctSubset)
                Console.Write(s + " ");
            Console.WriteLine();
            Console.Write("The contents in the complement:");
            foreach (string s in complement)
                Console.Write(s + " ");
            Console.WriteLine();
        }
public static void ComplementDemo ( ) { string [ ] strings = { " " , " " , " " , " " , " " , " " } ; SortedSet < string > complete = new SortedSet < string > ( strings ) ; Console . WriteLine ( " " ) ; foreach ( string s in complete ) Console . Write ( s + " " ) ; Console . WriteLine ( ) ; SortedSet < string > wrongSubset = new SortedSet < string > { " " } ; Console . WriteLine ( " " ) ; try { ISet < string > wrongComplement = SetHelper . GetComplement ( complete , wrongSubset ) ; } catch ( ArgumentException ex ) { Console . WriteLine ( " " + ex . Message ) ; } SortedSet < string > correctSubset = new SortedSet < string > ( ) ; for ( int i = 0 ; i < 3 ; i ++ ) correctSubset . Add ( strings [ i ] ) ; ISet < string > complement = SetHelper . GetComplement ( complete , correctSubset ) ; Console . Write ( " " ) ; foreach ( string s in correctSubset ) Console . Write ( s + " " ) ; Console . WriteLine ( ) ; Console . Write ( " " ) ; foreach ( string s in complement ) Console . Write ( s + " " ) ; Console . WriteLine ( ) ; }
Functionality test method for the SetHelper.GetComplement() method.
Functionality test method for the SetHelper . GetComplement () method .