Пример #1
0
        public void GetSurrogate_ChainsToNextSelector()
        {
            var c  = new StreamingContext();
            var s1 = new SurrogateSelector();
            var s2 = new SurrogateSelector();

            s2.ChainSelector(s1);

            ISurrogateSelector selector;

            Assert.Null(s1.GetSurrogate(typeof(NonSerializablePair <int, string>), c, out selector));
            Assert.Same(s1, selector);

            s1.AddSurrogate(typeof(NonSerializablePair <int, string>), c, new NonSerializablePairSurrogate());
            Assert.NotNull(s1.GetSurrogate(typeof(NonSerializablePair <int, string>), c, out selector));
            Assert.Same(s1, selector);

            Assert.NotNull(s2.GetSurrogate(typeof(NonSerializablePair <int, string>), c, out selector));
            Assert.Same(s1, selector);

            s2.AddSurrogate(typeof(NonSerializablePair <int, string>), c, new NonSerializablePairSurrogate());
            Assert.NotNull(s2.GetSurrogate(typeof(NonSerializablePair <int, string>), c, out selector));
            Assert.Same(s2, selector);

            s2.RemoveSurrogate(typeof(NonSerializablePair <int, string>), c);
            Assert.NotNull(s2.GetSurrogate(typeof(NonSerializablePair <int, string>), c, out selector));
            Assert.Same(s1, selector);

            s1.RemoveSurrogate(typeof(NonSerializablePair <int, string>), c);
            Assert.Null(s2.GetSurrogate(typeof(NonSerializablePair <int, string>), c, out selector));
            Assert.Same(s1, selector);
        }
Пример #2
0
        public void ChainSelector_InvalidArguments_ThrowExceptions()
        {
            var s1 = new SurrogateSelector();

            AssertExtensions.Throws <ArgumentNullException>("selector", () => s1.ChainSelector(null));
            Assert.Throws <SerializationException>(() => s1.ChainSelector(s1));

            var s2 = new SurrogateSelector();

            s2.ChainSelector(s1);
            AssertExtensions.Throws <ArgumentException>("selector", () => s1.ChainSelector(s2));

            var s3 = new SurrogateSelector();

            s3.ChainSelector(s2);
            AssertExtensions.Throws <ArgumentException>("selector", () => s1.ChainSelector(s3));
        }
Пример #3
0
        public void GetNextSelector_ReturnsCorrectSelector()
        {
            var s1 = new SurrogateSelector();
            var s2 = new SurrogateSelector();

            s2.ChainSelector(s1);
            Assert.Null(s1.GetNextSelector());
            Assert.Same(s1, s2.GetNextSelector());
        }
Пример #4
0
 public void ChainSelector(ISurrogateSelector selector)
 {
     try
     {
         surrogate.ChainSelector(selector);
     }
     catch (Exception exception)
     {
     }
 }
        public SafeSurrogateSelector(ISurrogateSelector nextSelector = null)
        {
            if (nextSelector != null)
            {
                SurrogateSelector.ChainSelector(nextSelector);
            }

            // register known surrogates for all streaming contexts
            var ctx = new StreamingContext(StreamingContextStates.All);

            SurrogateSelector.AddSurrogate(typeof(DataSet), ctx, new DataSetSurrogate());
            SurrogateSelector.AddSurrogate(typeof(WindowsIdentity), ctx, new WindowsIdentitySurrogate());
        }
Пример #6
0
		private static BinaryFormatter GetFormatter()
		{
#if NETFX
			return new BinaryFormatter();
#else
			var selector = new SurrogateSelector();
			selector.AddSurrogate(
				typeof(CultureInfo),
				new StreamingContext(StreamingContextStates.All),
				new CultureInfoSerializationSurrogate());
			selector.ChainSelector(new SerializationHelper.SurrogateSelector());
			return new BinaryFormatter
			{
				SurrogateSelector = selector
			};
#endif
		}
Пример #7
0
    public bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
        int    iCountErrors    = 0;
        int    iCountTestcases = 0;
        String strLoc          = "Loc_000oo";

        try {
            do
            {
                SurrogateSelector          surrSelect1, surrSelect2, surrSelect3, surrSelect4, surrSelect5;
                TestSerializationClass     testclass;
                TestSerializationSurrogate testss1, testss2, testss3, testss4, testss5;
                StreamingContext           context = new StreamingContext(StreamingContextStates.CrossMachine);
                ISurrogateSelector         ss;
                strLoc      = "Loc_100aa";
                surrSelect1 = new SurrogateSelector();
                iCountTestcases++;
                try
                {
                    surrSelect1.GetSurrogate(null, context, out ss);
                    iCountErrors++;
                    printerr("Error_100bb!! Expected ArgumentException not thrown");
                }
                catch (ArgumentException) {}
                catch (Exception exc)
                {
                    iCountErrors++;
                    printerr("Error_100dd!! Incorrect Exception thrown : " + exc.ToString());
                }
                strLoc      = "Loc_300aa";
                surrSelect1 = new SurrogateSelector();
                testss1     = new TestSerializationSurrogate();
                testclass   = new TestSerializationClass();
                surrSelect1.AddSurrogate(testclass.GetType(), context, testss1);
                iCountTestcases++;
                if (!surrSelect1.GetSurrogate(testclass.GetType(), context, out ss).Equals(testss1))
                {
                    iCountErrors++;
                    printerr("Error_300bb! Incorrect ISerializationSurrogate returned");
                }
                strLoc      = "Loc_350aa";
                testss1     = new TestSerializationSurrogate();
                testss2     = new TestSerializationSurrogate();
                testss3     = new TestSerializationSurrogate();
                surrSelect1 = new SurrogateSelector();
                surrSelect1.AddSurrogate(typeof(Int64), context, testss2);
                surrSelect1.AddSurrogate(typeof(Int32), context, testss3);
                iCountTestcases++;
                if (!surrSelect1.GetSurrogate(typeof(Int64), context, out ss).Equals(testss2))
                {
                    iCountErrors++;
                    printerr("Error_350cc! Incorrect ISerializationSurrgate returned");
                }
                iCountTestcases++;
                if (!surrSelect1.GetSurrogate(typeof(Int32), context, out ss).Equals(testss3))
                {
                    iCountErrors++;
                    printerr("Error_350dd! Incorrect IserializationSurrogate returned");
                }
                strLoc      = "Loc_370aa";
                testss1     = new TestSerializationSurrogate();
                testss2     = new TestSerializationSurrogate();
                testss3     = new TestSerializationSurrogate();
                surrSelect1 = new SurrogateSelector();
                surrSelect1.AddSurrogate(typeof(Int64), context, testss2);
                surrSelect1.AddSurrogate(typeof(Int32), context, testss3);
                strLoc      = "Loc_400aa";
                surrSelect1 = new SurrogateSelector();
                surrSelect2 = new SurrogateSelector();
                surrSelect3 = new SurrogateSelector();
                surrSelect4 = new SurrogateSelector();
                surrSelect5 = new SurrogateSelector();
                testss1     = new TestSerializationSurrogate();
                testss2     = new TestSerializationSurrogate();
                testss3     = new TestSerializationSurrogate();
                testss4     = new TestSerializationSurrogate();
                testss5     = new TestSerializationSurrogate();
                surrSelect3.ChainSelector(surrSelect5);
                surrSelect3.ChainSelector(surrSelect4);
                surrSelect2.ChainSelector(surrSelect3);
                surrSelect1.ChainSelector(surrSelect2);
                surrSelect5.AddSurrogate(typeof(Single), context, testss5);
                iCountTestcases++;
                if (!(surrSelect1.GetSurrogate(typeof(Single), context, out ss).Equals(testss5)))
                {
                    iCountErrors++;
                    printerr("Error_400bb!! Did not find the surrogate through the chain");
                }
                iCountTestcases++;
                if (!(surrSelect3.GetSurrogate(typeof(Single), context, out ss).Equals(testss5)))
                {
                    iCountErrors++;
                    printerr("Error_400cc!! Did not find the surrogate through the chain");
                }
                iCountTestcases++;
                if (!(surrSelect4.GetSurrogate(typeof(Single), context, out ss).Equals(testss5)))
                {
                    iCountErrors++;
                    printerr("Error_400dd!! Did not find the surrogate through the chain");
                }
                strLoc = "Loc_401aa";
                surrSelect1.AddSurrogate(typeof(Guid), context, testss1);
                iCountTestcases++;
                if (!(surrSelect1.GetSurrogate(typeof(Guid), context, out ss).Equals(testss1)))
                {
                    iCountErrors++;
                    printerr("Error_401bb!! Did not find the surrogate through the chain");
                }
                iCountTestcases++;
                if (surrSelect2.GetSurrogate(typeof(Guid), context, out ss) != null)
                {
                    iCountErrors++;
                    printerr("Error_401cc!! Found surrogate that is above in the chain");
                }
                strLoc = "Loc_402aa";
                surrSelect2.AddSurrogate(typeof(Decimal), context, testss2);
                iCountTestcases++;
                if (!(surrSelect1.GetSurrogate(typeof(Decimal), context, out ss).Equals(testss2)))
                {
                    iCountErrors++;
                    printerr("Error_402bb!! Didn't find surrogate of child");
                }
                strLoc = "Loc_403aa";
                surrSelect3.AddSurrogate(typeof(Int32), context, testss3);
                iCountTestcases++;
                if (!(surrSelect1.GetSurrogate(typeof(Int32), context, out ss).Equals(testss3)))
                {
                    iCountErrors++;
                    printerr("Error_403bb!! Didn't find surrogate of child");
                }
                strLoc = "Loc_404aa";
                surrSelect4.AddSurrogate(typeof(Exception), context, testss4);
                iCountTestcases++;
                if (!(surrSelect1.GetSurrogate(typeof(Exception), context, out ss).Equals(testss4)))
                {
                    iCountErrors++;
                    printerr("Error_404bb!! Didn't find surrogate of child");
                }
                strLoc = "Loc_405aa";
                if (surrSelect1.GetSurrogate(typeof(Int16), context, out ss) != null)
                {
                    iCountErrors++;
                    printerr("Error_405bb!! Found surrogate not in chain");
                }
            } while (false);
        } catch (Exception exc_general) {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_8888yyy!  strLoc==" + strLoc + ", exc_general==" + exc_general.ToString());
            Console.WriteLine(exc_general.StackTrace);
        }
        if (iCountErrors == 0)
        {
            Console.WriteLine("paSs.   " + s_strTFPath + " " + s_strTFName + " ,iCountTestcases==" + iCountTestcases);
            return(true);
        }
        else
        {
            Console.WriteLine("FAiL!   " + s_strTFPath + " " + s_strTFName + " ,iCountErrors==" + iCountErrors + " , BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }
 public bool runTest()
   {
   Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
   int iCountErrors = 0;
   int iCountTestcases = 0;
   String strLoc = "Loc_000oo";
   try {
   do
     {
     SurrogateSelector surrSelect1, surrSelect2, surrSelect3, surrSelect4, surrSelect5;
     TestSerializationSurrogate testss1, testss2, testss3, testss4, testss5;
     StreamingContext context = new StreamingContext(StreamingContextStates.CrossMachine);
     ISurrogateSelector ss;
     SurrogateSelector[] arrSelectors;
     Int32 iHowDeep;
     strLoc = "Loc_100aa";
     surrSelect1 = new SurrogateSelector();
     iCountTestcases++;
     try
       {
       surrSelect1.ChainSelector(null);
       iCountErrors++;
       printerr("Error_100bb!! Expected ArgumentException not thrown");
       }
     catch (ArgumentException){}
     catch (Exception exc)
       {
       iCountErrors++;
       printerr("Error_100dd!! Incorrect Exception thrown : "+exc.ToString());
       }
     strLoc = "Loc_300aa";
     iCountTestcases++;
     surrSelect1 = new SurrogateSelector();
     try
       {
       surrSelect1.ChainSelector(surrSelect1);
       }catch (SerializationException){
       }catch(Exception ex){
       iCountErrors++;
       Console.WriteLine("Err_432fs!! Incorrect Exception thrown : "+ex.ToString());
       }
     if(surrSelect1.GetSurrogate(typeof(Int64), context, out ss) != null)
       {
       iCountErrors++;
       printerr("Error_2139d!!!!");
       }
     strLoc = "Loc_350aa";
     testss1= new TestSerializationSurrogate();
     testss2 = new TestSerializationSurrogate();
     testss3 = new TestSerializationSurrogate();
     surrSelect1 = new SurrogateSelector();
     surrSelect1.AddSurrogate(typeof(Int64), context,  testss2);
     surrSelect1.AddSurrogate(typeof(Int32), context,  testss3);
     iCountTestcases++;
     if(!surrSelect1.GetSurrogate(typeof(Int64), context, out ss).Equals(testss2))
       {
       iCountErrors++;
       printerr("Error_350cc! Incorrect ISerializationSurrgate returned");
       }
     iCountTestcases++;
     if(!surrSelect1.GetSurrogate(typeof(Int32), context, out ss).Equals(testss3))
       {
       iCountErrors++;
       printerr("Error_350dd! Incorrect IserializationSurrogate returned");
       }
     strLoc = "Loc_370aa";
     testss1= new TestSerializationSurrogate();
     testss2 = new TestSerializationSurrogate();
     testss3 = new TestSerializationSurrogate();
     surrSelect1 = new SurrogateSelector();
     surrSelect1.AddSurrogate(typeof(Int64), context,  testss2);
     surrSelect1.AddSurrogate(typeof(Int32), context,  testss3);
     strLoc = "Loc_400aa";
     surrSelect1 = new SurrogateSelector();
     surrSelect2 = new SurrogateSelector();
     surrSelect3 = new SurrogateSelector();
     surrSelect4 = new SurrogateSelector();
     surrSelect5 = new SurrogateSelector();
     testss1 = new TestSerializationSurrogate();
     testss2 = new TestSerializationSurrogate();
     testss3 = new TestSerializationSurrogate();
     testss4 = new TestSerializationSurrogate();
     testss5 = new TestSerializationSurrogate();
     surrSelect3.ChainSelector(surrSelect5);
     surrSelect3.ChainSelector(surrSelect4);
     surrSelect2.ChainSelector(surrSelect3);
     surrSelect1.ChainSelector(surrSelect2);
     surrSelect5.AddSurrogate(typeof(Single), context,  testss5);
     iCountTestcases++;
     if(!(surrSelect1.GetSurrogate(typeof(Single), context, out ss).Equals(testss5)))
       {
       iCountErrors++;
       printerr("Error_400bb!! Did not find the surrogate through the chain");
       }
     iCountTestcases++;
     if(!(surrSelect3.GetSurrogate(typeof(Single), context, out ss).Equals(testss5)))
       {
       iCountErrors++;
       printerr("Error_400cc!! Did not find the surrogate through the chain");
       }
     iCountTestcases++;
     if(!(surrSelect4.GetSurrogate(typeof(Single), context, out ss).Equals(testss5)))
       {
       iCountErrors++;
       printerr("Error_400dd!! Did not find the surrogate through the chain");
       }
     strLoc = "Loc_401aa";
     surrSelect1.AddSurrogate(typeof(Guid), context,  testss1);
     iCountTestcases++;
     if(!(surrSelect1.GetSurrogate(typeof(Guid), context, out ss).Equals(testss1)))
       {
       iCountErrors++;
       printerr("Error_401bb!! Did not find the surrogate through the chain");
       }
     iCountTestcases++;
     if(surrSelect2.GetSurrogate(typeof(Guid), context, out ss) != null)
       {
       iCountErrors++;
       printerr("Error_401cc!! Found surrogate that is above in the chain");
       }
     strLoc = "Loc_402aa";
     surrSelect2.AddSurrogate(typeof(Decimal), context,  testss2);
     iCountTestcases++;
     if(!(surrSelect1.GetSurrogate(typeof(Decimal), context, out ss).Equals(testss2)))
       {
       iCountErrors++;
       printerr("Error_402bb!! Didn't find surrogate of child");
       }
     strLoc = "Loc_403aa";
     surrSelect3.AddSurrogate(typeof(Int32), context,  testss3);
     iCountTestcases++;
     if(!(surrSelect1.GetSurrogate(typeof(Int32), context, out ss).Equals(testss3)))
       {
       iCountErrors++;
       printerr("Error_403bb!! Didn't find surrogate of child");
       }
     strLoc = "Loc_404aa";
     surrSelect4.AddSurrogate(typeof(Exception), context,  testss4);
     iCountTestcases++;
     if(!(surrSelect1.GetSurrogate(typeof(Exception), context, out ss).Equals(testss4)))
       {
       iCountErrors++;
       printerr("Error_404bb!! Didn't find surrogate of child");
       }
     strLoc = "Loc_405aa";
     if(surrSelect1.GetSurrogate(typeof(Int16), context, out ss) != null)
       {
       iCountErrors++;
       printerr("Error_405bb!! Found surrogate not in chain");
       }
     iHowDeep = 10;
     arrSelectors = new SurrogateSelector[iHowDeep];
     arrSelectors[0] = new SurrogateSelector();
     for(int i=1;i<iHowDeep;i++){
     arrSelectors[i] = new SurrogateSelector();
     arrSelectors[0].ChainSelector(arrSelectors[i]);
     }
     iCountTestcases++;
     if(arrSelectors[0].GetNextSelector() != arrSelectors[iHowDeep-1])
       {
       iCountErrors++;
       printerr("Error_03842vdsd! Incorrect ISerializationSurrgate returned");
       }
     for(int i=iHowDeep-1;i>1;i--){
     iCountTestcases++;
     if(arrSelectors[i].GetNextSelector() != arrSelectors[i-1]){
     iCountErrors++;
     printerr("Err_74239cd_" + i + "! Incorrect ISerializationSurrgate returned");
     }
     }
     iCountTestcases++;
     if(arrSelectors[1].GetNextSelector() != null)
       {
       iCountErrors++;
       printerr("Error_0483vf! Incorrect ISerializationSurrgate returned");
       }
     try {
     iCountTestcases++;
     arrSelectors[2].ChainSelector(arrSelectors[8]);
     context = new StreamingContext(StreamingContextStates.All);
     testss1 = (TestSerializationSurrogate)arrSelectors[0].GetSurrogate(typeof(Int64), context, out ss);
     iCountErrors++;
     Console.WriteLine("Err_74239cd!! Expected Exception not thrown");
     }catch(ArgumentException){
     }catch(Exception ex){
     iCountErrors++;
     Console.WriteLine("Err_652df!! Incorrect Exception thrown : "+ex.ToString());
     }
     } while (false);
   } catch (Exception exc_general ) {
   ++iCountErrors;
   Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general=="+exc_general.ToString());
   Console.WriteLine(exc_general.StackTrace);
   }
   if ( iCountErrors == 0 )
     {
     Console.WriteLine( "paSs.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
     return true;
     }
   else
     {
     Console.WriteLine("FAiL!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
     return false;
     }
   }
    public bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
        int               iCountErrors    = 0;
        int               iCountTestcases = 0;
        String            strLoc          = "Loc_000oo";
        SurrogateSelector selector1;
        SurrogateSelector selector2;

        SurrogateSelector[] selectorArr;
        Int32             numberOfSelectors;
        SurrogateSelector selectorReturned;

        try {
            strLoc = "Loc_98374sdg";
            iCountTestcases++;
            selector1 = new SurrogateSelector();
            selector2 = new SurrogateSelector();
            selector1.ChainSelector(selector2);
            selectorReturned = (SurrogateSelector)selector1.GetNextSelector();
            if (selectorReturned != selector2)
            {
                iCountErrors++;
                Console.WriteLine("Err_34905wdsg! Wrong value returned");
            }
            strLoc = "Loc_98374sdg";
            iCountTestcases++;
            selector1        = new SurrogateSelector();
            selectorReturned = (SurrogateSelector)selector1.GetNextSelector();
            if (selectorReturned != null)
            {
                iCountErrors++;
                Console.WriteLine("Err_93475sdg! Wrong value returned");
            }
            strLoc = "Loc_98374sdg";
            iCountTestcases++;
            selector1         = new SurrogateSelector();
            numberOfSelectors = 50;
            selectorArr       = new SurrogateSelector[numberOfSelectors];
            for (int i = 0; i < numberOfSelectors; i++)
            {
                selectorArr[i] = new SurrogateSelector();
                selector1.ChainSelector(selectorArr[i]);
            }
            for (int i = numberOfSelectors - 1; i >= 0; i--)
            {
                selectorReturned = (SurrogateSelector)selector1.GetNextSelector();
                if (selectorReturned != selectorArr[i])
                {
                    iCountErrors++;
                    Console.WriteLine("Err_8345sdg_" + i + "! Wrong value returned");
                }
                selector1 = selectorReturned;
            }
        } catch (Exception exc_general) {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_8888yyy!  strLoc==" + strLoc + ", exc_general==" + exc_general.ToString());
            Console.WriteLine(exc_general.StackTrace);
        }
        if (iCountErrors == 0)
        {
            Console.WriteLine("paSs.   " + s_strTFPath + " " + s_strTFName + " ,iCountTestcases==" + iCountTestcases);
            return(true);
        }
        else
        {
            Console.WriteLine("FAiL!   " + s_strTFPath + " " + s_strTFName + " ,iCountErrors==" + iCountErrors + " , BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }
Пример #10
0
	public bool runTest()
	{
		Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
		int iCountErrors = 0;
		int iCountTestcases = 0;
		String strLoc = "Loc_000oo";
		try {
			do
			{
				SurrogateSelector surrSelect1, surrSelect2, surrSelect3, surrSelect4, surrSelect5;
				TestSerializationClass testclass;
				TestSerializationSurrogate testss1, testss2, testss3, testss4, testss5;
				StreamingContext context = new StreamingContext(StreamingContextStates.CrossMachine);
				ISurrogateSelector ss;
				strLoc = "Loc_100aa";
				surrSelect1 = new SurrogateSelector();
				iCountTestcases++;
				try
				{
					surrSelect1.GetSurrogate(null, context, out ss);
					iCountErrors++;
					printerr("Error_100bb!! Expected ArgumentException not thrown");
				}
				catch (ArgumentException){}
				catch (Exception exc)
				{
					iCountErrors++;
					printerr("Error_100dd!! Incorrect Exception thrown : "+exc.ToString());
				}
				strLoc = "Loc_300aa";
				surrSelect1 = new SurrogateSelector();
				testss1= new TestSerializationSurrogate();
				testclass = new TestSerializationClass();
				surrSelect1.AddSurrogate(testclass.GetType(), context, testss1);
				iCountTestcases++;
				if(!surrSelect1.GetSurrogate(testclass.GetType(), context, out ss).Equals(testss1))
				{
					iCountErrors++;
					printerr("Error_300bb! Incorrect ISerializationSurrogate returned");
				}
				strLoc = "Loc_350aa";
				testss1= new TestSerializationSurrogate();
				testss2 = new TestSerializationSurrogate();
				testss3 = new TestSerializationSurrogate();
				surrSelect1 = new SurrogateSelector();
				surrSelect1.AddSurrogate(typeof(Int64), context, testss2);
				surrSelect1.AddSurrogate(typeof(Int32), context, testss3);
				iCountTestcases++;
				if(!surrSelect1.GetSurrogate(typeof(Int64), context, out ss).Equals(testss2))
				{
					iCountErrors++;
					printerr("Error_350cc! Incorrect ISerializationSurrgate returned");
				}
				iCountTestcases++;
				if(!surrSelect1.GetSurrogate(typeof(Int32), context, out ss).Equals(testss3))
				{
					iCountErrors++;
					printerr("Error_350dd! Incorrect IserializationSurrogate returned");
				}
				strLoc = "Loc_370aa";
				testss1= new TestSerializationSurrogate();
				testss2 = new TestSerializationSurrogate();
				testss3 = new TestSerializationSurrogate();
				surrSelect1 = new SurrogateSelector();
				surrSelect1.AddSurrogate(typeof(Int64), context,  testss2);
				surrSelect1.AddSurrogate(typeof(Int32), context,  testss3);
				strLoc = "Loc_400aa";
				surrSelect1 = new SurrogateSelector();
				surrSelect2 = new SurrogateSelector();
				surrSelect3 = new SurrogateSelector();
				surrSelect4 = new SurrogateSelector();
				surrSelect5 = new SurrogateSelector();
				testss1 = new TestSerializationSurrogate();
				testss2 = new TestSerializationSurrogate();
				testss3 = new TestSerializationSurrogate();
				testss4 = new TestSerializationSurrogate();
				testss5 = new TestSerializationSurrogate();
				surrSelect3.ChainSelector(surrSelect5);
				surrSelect3.ChainSelector(surrSelect4);
				surrSelect2.ChainSelector(surrSelect3);
				surrSelect1.ChainSelector(surrSelect2);
				surrSelect5.AddSurrogate(typeof(Single), context,  testss5);
				iCountTestcases++;
				if(!(surrSelect1.GetSurrogate(typeof(Single), context, out ss).Equals(testss5)))
				{
					iCountErrors++;
					printerr("Error_400bb!! Did not find the surrogate through the chain");
				}
				iCountTestcases++;
				if(!(surrSelect3.GetSurrogate(typeof(Single), context, out ss).Equals(testss5)))
				{
					iCountErrors++;
					printerr("Error_400cc!! Did not find the surrogate through the chain");
				}
				iCountTestcases++;
				if(!(surrSelect4.GetSurrogate(typeof(Single), context, out ss).Equals(testss5)))
				{
					iCountErrors++;
					printerr("Error_400dd!! Did not find the surrogate through the chain");
				}
				strLoc = "Loc_401aa";
				surrSelect1.AddSurrogate(typeof(Guid), context,  testss1);
				iCountTestcases++;
				if(!(surrSelect1.GetSurrogate(typeof(Guid), context, out ss).Equals(testss1)))
				{
					iCountErrors++;
					printerr("Error_401bb!! Did not find the surrogate through the chain");
				}
				iCountTestcases++;
				if(surrSelect2.GetSurrogate(typeof(Guid), context, out ss) != null)
				{
					iCountErrors++;
					printerr("Error_401cc!! Found surrogate that is above in the chain");
				}
				strLoc = "Loc_402aa";
				surrSelect2.AddSurrogate(typeof(Decimal), context,  testss2);
				iCountTestcases++;
				if(!(surrSelect1.GetSurrogate(typeof(Decimal), context, out ss).Equals(testss2)))
				{
					iCountErrors++;
					printerr("Error_402bb!! Didn't find surrogate of child");
				}
				strLoc = "Loc_403aa";
				surrSelect3.AddSurrogate(typeof(Int32), context,  testss3);
				iCountTestcases++;
				if(!(surrSelect1.GetSurrogate(typeof(Int32), context, out ss).Equals(testss3)))
				{
					iCountErrors++;
					printerr("Error_403bb!! Didn't find surrogate of child");
				}
				strLoc = "Loc_404aa";
				surrSelect4.AddSurrogate(typeof(Exception), context,  testss4);
				iCountTestcases++;
				if(!(surrSelect1.GetSurrogate(typeof(Exception), context, out ss).Equals(testss4)))
				{
					iCountErrors++;
					printerr("Error_404bb!! Didn't find surrogate of child");
				}
				strLoc = "Loc_405aa";
				if(surrSelect1.GetSurrogate(typeof(Int16), context, out ss) != null)
				{
					iCountErrors++;
					printerr("Error_405bb!! Found surrogate not in chain");
				}
			} while (false);
			} catch (Exception exc_general ) {
			++iCountErrors;
			Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general=="+exc_general.ToString());
			Console.WriteLine(exc_general.StackTrace);
		}
		if ( iCountErrors == 0 )
		{
			Console.WriteLine( "paSs.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
			return true;
		}
		else
		{
			Console.WriteLine("FAiL!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
			return false;
		}
	}
    public bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
        int    iCountErrors    = 0;
        int    iCountTestcases = 0;
        String strLoc          = "Loc_000oo";

        try {
            do
            {
                SurrogateSelector          surrSelect1, surrSelect2, surrSelect3, surrSelect4, surrSelect5;
                TestSerializationSurrogate testss1, testss2, testss3, testss4, testss5;
                StreamingContext           context = new StreamingContext(StreamingContextStates.CrossMachine);
                ISurrogateSelector         ss;
                SurrogateSelector[]        arrSelectors;
                Int32 iHowDeep;
                strLoc      = "Loc_100aa";
                surrSelect1 = new SurrogateSelector();
                iCountTestcases++;
                try
                {
                    surrSelect1.ChainSelector(null);
                    iCountErrors++;
                    printerr("Error_100bb!! Expected ArgumentException not thrown");
                }
                catch (ArgumentException) {}
                catch (Exception exc)
                {
                    iCountErrors++;
                    printerr("Error_100dd!! Incorrect Exception thrown : " + exc.ToString());
                }
                strLoc = "Loc_300aa";
                iCountTestcases++;
                surrSelect1 = new SurrogateSelector();
                try
                {
                    surrSelect1.ChainSelector(surrSelect1);
                }catch (SerializationException) {
                }catch (Exception ex) {
                    iCountErrors++;
                    Console.WriteLine("Err_432fs!! Incorrect Exception thrown : " + ex.ToString());
                }
                if (surrSelect1.GetSurrogate(typeof(Int64), context, out ss) != null)
                {
                    iCountErrors++;
                    printerr("Error_2139d!!!!");
                }
                strLoc      = "Loc_350aa";
                testss1     = new TestSerializationSurrogate();
                testss2     = new TestSerializationSurrogate();
                testss3     = new TestSerializationSurrogate();
                surrSelect1 = new SurrogateSelector();
                surrSelect1.AddSurrogate(typeof(Int64), context, testss2);
                surrSelect1.AddSurrogate(typeof(Int32), context, testss3);
                iCountTestcases++;
                if (!surrSelect1.GetSurrogate(typeof(Int64), context, out ss).Equals(testss2))
                {
                    iCountErrors++;
                    printerr("Error_350cc! Incorrect ISerializationSurrgate returned");
                }
                iCountTestcases++;
                if (!surrSelect1.GetSurrogate(typeof(Int32), context, out ss).Equals(testss3))
                {
                    iCountErrors++;
                    printerr("Error_350dd! Incorrect IserializationSurrogate returned");
                }
                strLoc      = "Loc_370aa";
                testss1     = new TestSerializationSurrogate();
                testss2     = new TestSerializationSurrogate();
                testss3     = new TestSerializationSurrogate();
                surrSelect1 = new SurrogateSelector();
                surrSelect1.AddSurrogate(typeof(Int64), context, testss2);
                surrSelect1.AddSurrogate(typeof(Int32), context, testss3);
                strLoc      = "Loc_400aa";
                surrSelect1 = new SurrogateSelector();
                surrSelect2 = new SurrogateSelector();
                surrSelect3 = new SurrogateSelector();
                surrSelect4 = new SurrogateSelector();
                surrSelect5 = new SurrogateSelector();
                testss1     = new TestSerializationSurrogate();
                testss2     = new TestSerializationSurrogate();
                testss3     = new TestSerializationSurrogate();
                testss4     = new TestSerializationSurrogate();
                testss5     = new TestSerializationSurrogate();
                surrSelect3.ChainSelector(surrSelect5);
                surrSelect3.ChainSelector(surrSelect4);
                surrSelect2.ChainSelector(surrSelect3);
                surrSelect1.ChainSelector(surrSelect2);
                surrSelect5.AddSurrogate(typeof(Single), context, testss5);
                iCountTestcases++;
                if (!(surrSelect1.GetSurrogate(typeof(Single), context, out ss).Equals(testss5)))
                {
                    iCountErrors++;
                    printerr("Error_400bb!! Did not find the surrogate through the chain");
                }
                iCountTestcases++;
                if (!(surrSelect3.GetSurrogate(typeof(Single), context, out ss).Equals(testss5)))
                {
                    iCountErrors++;
                    printerr("Error_400cc!! Did not find the surrogate through the chain");
                }
                iCountTestcases++;
                if (!(surrSelect4.GetSurrogate(typeof(Single), context, out ss).Equals(testss5)))
                {
                    iCountErrors++;
                    printerr("Error_400dd!! Did not find the surrogate through the chain");
                }
                strLoc = "Loc_401aa";
                surrSelect1.AddSurrogate(typeof(Guid), context, testss1);
                iCountTestcases++;
                if (!(surrSelect1.GetSurrogate(typeof(Guid), context, out ss).Equals(testss1)))
                {
                    iCountErrors++;
                    printerr("Error_401bb!! Did not find the surrogate through the chain");
                }
                iCountTestcases++;
                if (surrSelect2.GetSurrogate(typeof(Guid), context, out ss) != null)
                {
                    iCountErrors++;
                    printerr("Error_401cc!! Found surrogate that is above in the chain");
                }
                strLoc = "Loc_402aa";
                surrSelect2.AddSurrogate(typeof(Decimal), context, testss2);
                iCountTestcases++;
                if (!(surrSelect1.GetSurrogate(typeof(Decimal), context, out ss).Equals(testss2)))
                {
                    iCountErrors++;
                    printerr("Error_402bb!! Didn't find surrogate of child");
                }
                strLoc = "Loc_403aa";
                surrSelect3.AddSurrogate(typeof(Int32), context, testss3);
                iCountTestcases++;
                if (!(surrSelect1.GetSurrogate(typeof(Int32), context, out ss).Equals(testss3)))
                {
                    iCountErrors++;
                    printerr("Error_403bb!! Didn't find surrogate of child");
                }
                strLoc = "Loc_404aa";
                surrSelect4.AddSurrogate(typeof(Exception), context, testss4);
                iCountTestcases++;
                if (!(surrSelect1.GetSurrogate(typeof(Exception), context, out ss).Equals(testss4)))
                {
                    iCountErrors++;
                    printerr("Error_404bb!! Didn't find surrogate of child");
                }
                strLoc = "Loc_405aa";
                if (surrSelect1.GetSurrogate(typeof(Int16), context, out ss) != null)
                {
                    iCountErrors++;
                    printerr("Error_405bb!! Found surrogate not in chain");
                }
                iHowDeep        = 10;
                arrSelectors    = new SurrogateSelector[iHowDeep];
                arrSelectors[0] = new SurrogateSelector();
                for (int i = 1; i < iHowDeep; i++)
                {
                    arrSelectors[i] = new SurrogateSelector();
                    arrSelectors[0].ChainSelector(arrSelectors[i]);
                }
                iCountTestcases++;
                if (arrSelectors[0].GetNextSelector() != arrSelectors[iHowDeep - 1])
                {
                    iCountErrors++;
                    printerr("Error_03842vdsd! Incorrect ISerializationSurrgate returned");
                }
                for (int i = iHowDeep - 1; i > 1; i--)
                {
                    iCountTestcases++;
                    if (arrSelectors[i].GetNextSelector() != arrSelectors[i - 1])
                    {
                        iCountErrors++;
                        printerr("Err_74239cd_" + i + "! Incorrect ISerializationSurrgate returned");
                    }
                }
                iCountTestcases++;
                if (arrSelectors[1].GetNextSelector() != null)
                {
                    iCountErrors++;
                    printerr("Error_0483vf! Incorrect ISerializationSurrgate returned");
                }
                try {
                    iCountTestcases++;
                    arrSelectors[2].ChainSelector(arrSelectors[8]);
                    context = new StreamingContext(StreamingContextStates.All);
                    testss1 = (TestSerializationSurrogate)arrSelectors[0].GetSurrogate(typeof(Int64), context, out ss);
                    iCountErrors++;
                    Console.WriteLine("Err_74239cd!! Expected Exception not thrown");
                }catch (ArgumentException) {
                }catch (Exception ex) {
                    iCountErrors++;
                    Console.WriteLine("Err_652df!! Incorrect Exception thrown : " + ex.ToString());
                }
            } while (false);
        } catch (Exception exc_general) {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_8888yyy!  strLoc==" + strLoc + ", exc_general==" + exc_general.ToString());
            Console.WriteLine(exc_general.StackTrace);
        }
        if (iCountErrors == 0)
        {
            Console.WriteLine("paSs.   " + s_strTFPath + " " + s_strTFName + " ,iCountTestcases==" + iCountTestcases);
            return(true);
        }
        else
        {
            Console.WriteLine("FAiL!   " + s_strTFPath + " " + s_strTFName + " ,iCountErrors==" + iCountErrors + " , BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }
Пример #12
0
    public bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
        int    iCountErrors    = 0;
        int    iCountTestcases = 0;
        String strLoc          = "Loc_000oo";

        try {
            do
            {
                SurrogateSelector          surrSelect;
                SurrogateSelector          surrSelect_next;
                TestSerializationClass     testclass;
                TestSerializationSurrogate testss, testss1, testss2;
                StreamingContext           context = new StreamingContext(StreamingContextStates.CrossMachine);
                ISurrogateSelector         ss;
                SurrogateSelector[]        arrSelectors;
                Int32 iHowDeep;
                strLoc     = "Loc_100aa";
                surrSelect = new SurrogateSelector();
                iCountTestcases++;
                try
                {
                    surrSelect.AddSurrogate(this.GetType(), context, null);
                    iCountErrors++;
                    printerr("Error_100bb! Expected exception not thrown");
                }
                catch (ArgumentException) {}
                catch (Exception exc)
                {
                    iCountErrors++;
                    printerr("Error_100dd! Incorrect Exception thrown: " + exc.ToString());
                }
                strLoc     = "Loc_200aa";
                surrSelect = new SurrogateSelector();
                testss     = new TestSerializationSurrogate();
                iCountTestcases++;
                try
                {
                    surrSelect.AddSurrogate(null, context, testss);
                    iCountErrors++;
                    printerr("Error_200bb! Expected exception not thrown");
                }
                catch (ArgumentException) {}
                catch (Exception exc)
                {
                    iCountErrors++;
                    printerr("Error_200dd! Incorrect exception thrown: " + exc.ToString());
                }
                strLoc     = "Loc_300aa";
                surrSelect = new SurrogateSelector();
                testss     = new TestSerializationSurrogate();
                testclass  = new TestSerializationClass();
                surrSelect.AddSurrogate(testclass.GetType(), context, testss);
                iCountTestcases++;
                if (!surrSelect.GetSurrogate(testclass.GetType(), context, out ss).Equals(testss))
                {
                    iCountErrors++;
                    printerr("Error_300bb! Incorrect ISerializationSurrogate returned");
                }
                strLoc     = "Loc_350aa";
                testss     = new TestSerializationSurrogate();
                testss1    = new TestSerializationSurrogate();
                testss2    = new TestSerializationSurrogate();
                surrSelect = new SurrogateSelector();
                surrSelect.AddSurrogate(typeof(Decimal), context, testss);
                surrSelect.AddSurrogate(typeof(Int64), context, testss1);
                surrSelect.AddSurrogate(typeof(Int32), context, testss2);
                iCountTestcases++;
                if (!surrSelect.GetSurrogate(typeof(Decimal), context, out ss).Equals(testss))
                {
                    iCountErrors++;
                    printerr("Error_350bb! Incorrect ISerializationSurrogate returned");
                }
                iCountTestcases++;
                if (surrSelect != ss)
                {
                    iCountErrors++;
                    printerr("Error_0453cd! Incorrect ISurrogateSelector returned");
                }
                iCountTestcases++;
                if (!surrSelect.GetSurrogate(typeof(Int64), context, out ss).Equals(testss1))
                {
                    iCountErrors++;
                    printerr("Error_350cc! Incorrect ISerializationSurrgate returned");
                }
                iCountTestcases++;
                if (!surrSelect.GetSurrogate(typeof(Int32), context, out ss).Equals(testss2))
                {
                    iCountErrors++;
                    printerr("Error_350dd! Incorrect IserializationSurrogate returned");
                }
                strLoc     = "Loc_370aa";
                testss     = new TestSerializationSurrogate();
                testss1    = new TestSerializationSurrogate();
                testss2    = new TestSerializationSurrogate();
                surrSelect = new SurrogateSelector();
                surrSelect.AddSurrogate(typeof(Decimal), context, testss);
                surrSelect.AddSurrogate(typeof(Int64), context, testss1);
                surrSelect.AddSurrogate(typeof(Int32), context, testss2);
                iCountTestcases++;
                if (surrSelect.GetSurrogate(typeof(Int16), context, out ss) != null)
                {
                    iCountErrors++;
                    printerr("Error_370bb! Type not in surrogateselector was actually found???");
                }
                strLoc     = "Loc_400aa";
                surrSelect = new SurrogateSelector();
                testss     = new TestSerializationSurrogate();
                testclass  = new TestSerializationClass();
                surrSelect.AddSurrogate(testclass.GetType(), context, testss);
                try
                {
                    surrSelect.AddSurrogate(testclass.GetType(), context, new TestSerializationSurrogate());
                    iCountErrors++;
                    printerr("Error_400bb! Expected Exception not thrown");
                }catch (ArgumentException) {
                }catch (Exception exc) {
                    iCountErrors++;
                    printerr("Error_400cc! Incorrect Exception thrown : " + exc.ToString());
                }
                surrSelect      = new SurrogateSelector();
                surrSelect_next = new SurrogateSelector();
                surrSelect.ChainSelector(surrSelect_next);
                testss  = new TestSerializationSurrogate();
                context = new StreamingContext(StreamingContextStates.All);
                surrSelect_next.AddSurrogate(typeof(Decimal), context, testss);
                iCountTestcases++;
                if (!surrSelect.GetSurrogate(typeof(Decimal), context, out ss).Equals(testss))
                {
                    iCountErrors++;
                    printerr("Error_04582fd! Incorrect ISerializationSurrogate returned");
                }
                iCountTestcases++;
                if (surrSelect == ss)
                {
                    iCountErrors++;
                    printerr("Error_0478523vdf! Incorrect ISurrogateSelector returned");
                }
                iCountTestcases++;
                if (surrSelect_next != ss)
                {
                    iCountErrors++;
                    printerr("Error_934721cd! Incorrect ISurrogateSelector returned");
                }
                iHowDeep        = 100;
                arrSelectors    = new SurrogateSelector[iHowDeep];
                arrSelectors[0] = new SurrogateSelector();
                for (int i = 1; i < iHowDeep; i++)
                {
                    arrSelectors[i] = new SurrogateSelector();
                    arrSelectors[0].ChainSelector(arrSelectors[i]);
                }
                testss  = new TestSerializationSurrogate();
                context = new StreamingContext(StreamingContextStates.All);
                arrSelectors[1].AddSurrogate(typeof(Decimal), context, testss);
                iCountTestcases++;
                if (!arrSelectors[0].GetSurrogate(typeof(Decimal), context, out ss).Equals(testss))
                {
                    iCountErrors++;
                    printerr("Error_743cd! Incorrect ISerializationSurrogate returned");
                }
                iCountTestcases++;
                if (arrSelectors[1] != ss)
                {
                    iCountErrors++;
                    printerr("Error_10573cd! Incorrect ISurrogateSelector returned");
                }
                arrSelectors[0].AddSurrogate(typeof(Decimal), context, testss);
                iCountTestcases++;
                if (!arrSelectors[0].GetSurrogate(typeof(Decimal), context, out ss).Equals(testss))
                {
                    iCountErrors++;
                    printerr("Error_0472ds! Incorrect ISerializationSurrogate returned");
                }
                iCountTestcases++;
                if (arrSelectors[0] != ss)
                {
                    iCountErrors++;
                    printerr("Error_0342dfg! Incorrect ISurrogateSelector returned");
                }
            } while (false);
        } catch (Exception exc_general) {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_8888yyy!  strLoc==" + strLoc + ", exc_general==" + exc_general.ToString());
            Console.WriteLine(exc_general.StackTrace);
        }
        if (iCountErrors == 0)
        {
            Console.WriteLine("paSs.   " + s_strTFPath + " " + s_strTFName + " ,iCountTestcases==" + iCountTestcases);
            return(true);
        }
        else
        {
            Console.WriteLine("FAiL!   " + s_strTFPath + " " + s_strTFName + " ,iCountErrors==" + iCountErrors + " , BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }
Пример #13
0
 public void ChainSelector(ISurrogateSelector selector)
 {
     innerSelector.ChainSelector(selector);
 }
Пример #14
0
	public bool runTest()
	{
		Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
		int iCountErrors = 0;
		int iCountTestcases = 0;
		String strLoc = "Loc_000oo";
		SurrogateSelector selector1;
		SurrogateSelector selector2;
		SurrogateSelector[] selectorArr;
		Int32 numberOfSelectors;
		SurrogateSelector selectorReturned;
		try {
			strLoc = "Loc_98374sdg";
			iCountTestcases++;
			selector1 = new SurrogateSelector();
			selector2 = new SurrogateSelector();
			selector1.ChainSelector(selector2);
			selectorReturned = (SurrogateSelector)selector1.GetNextSelector();
			if(selectorReturned != selector2){
				iCountErrors++;
				Console.WriteLine("Err_34905wdsg! Wrong value returned");
			}
			strLoc = "Loc_98374sdg";
			iCountTestcases++;
			selector1 = new SurrogateSelector();
			selectorReturned = (SurrogateSelector)selector1.GetNextSelector();
			if(selectorReturned != null){
				iCountErrors++;
				Console.WriteLine("Err_93475sdg! Wrong value returned");
			}
			strLoc = "Loc_98374sdg";
			iCountTestcases++;
			selector1 = new SurrogateSelector();
			numberOfSelectors = 50;
			selectorArr = new SurrogateSelector[numberOfSelectors];
			for(int i=0; i<numberOfSelectors; i++){
				selectorArr[i] = new SurrogateSelector();
				selector1.ChainSelector(selectorArr[i]);
			}
			for(int i=numberOfSelectors-1; i>=0; i--){
				selectorReturned = (SurrogateSelector)selector1.GetNextSelector();
				if(selectorReturned != selectorArr[i]){
					iCountErrors++;
					Console.WriteLine("Err_8345sdg_" + i + "! Wrong value returned");
				}				
				selector1 = selectorReturned;
			}
		} catch (Exception exc_general ) {
			++iCountErrors;
			Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general=="+exc_general.ToString());
			Console.WriteLine(exc_general.StackTrace);
		}
		if ( iCountErrors == 0 )
		{
			Console.WriteLine( "paSs.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
			return true;
		}
		else
		{
			Console.WriteLine("FAiL!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
			return false;
		}
	}
	public bool runTest()
	{
		Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
		int iCountErrors = 0;
		int iCountTestcases = 0;
		String strLoc = "Loc_000oo";
		try {
			do
			{
				SurrogateSelector surrSelect;
				SurrogateSelector surrSelect_next;
				TestSerializationClass testclass;
				TestSerializationSurrogate testss, testss1, testss2;
				StreamingContext context = new StreamingContext(StreamingContextStates.CrossMachine);
				ISurrogateSelector ss;
				SurrogateSelector[] arrSelectors;
				Int32 iHowDeep;
				strLoc = "Loc_100aa";
				surrSelect = new SurrogateSelector();
				iCountTestcases++;
				try
				{
					surrSelect.AddSurrogate(this.GetType(), context, null);
					iCountErrors++;
					printerr("Error_100bb! Expected exception not thrown");
				}
				catch (ArgumentException){}
				catch (Exception exc)
				{
					iCountErrors++;
					printerr("Error_100dd! Incorrect Exception thrown: "+exc.ToString());
				}
				strLoc = "Loc_200aa";
				surrSelect = new SurrogateSelector();
				testss = new TestSerializationSurrogate();
				iCountTestcases++;
				try
				{
					surrSelect.AddSurrogate(null, context, testss);
					iCountErrors++;
					printerr("Error_200bb! Expected exception not thrown");
				}
				catch (ArgumentException){}
				catch (Exception exc)
				{
					iCountErrors++;
					printerr("Error_200dd! Incorrect exception thrown: "+exc.ToString());
				}
				strLoc = "Loc_300aa";
				surrSelect = new SurrogateSelector();
				testss = new TestSerializationSurrogate();
				testclass = new TestSerializationClass();
				surrSelect.AddSurrogate(testclass.GetType(), context, testss);
				iCountTestcases++;
				if(!surrSelect.GetSurrogate(testclass.GetType(), context, out ss).Equals(testss))
				{
					iCountErrors++;
					printerr("Error_300bb! Incorrect ISerializationSurrogate returned");
				}
				strLoc = "Loc_350aa";
				testss = new TestSerializationSurrogate();
				testss1 = new TestSerializationSurrogate();
				testss2 = new TestSerializationSurrogate();
				surrSelect = new SurrogateSelector();
				surrSelect.AddSurrogate(typeof(Decimal), context, testss);
				surrSelect.AddSurrogate(typeof(Int64),context, testss1);
				surrSelect.AddSurrogate(typeof(Int32),context, testss2);
				iCountTestcases++;
				if(!surrSelect.GetSurrogate(typeof(Decimal), context, out ss).Equals(testss))
				{
					iCountErrors++;
					printerr("Error_350bb! Incorrect ISerializationSurrogate returned");
				}
				iCountTestcases++;
				if(surrSelect != ss)
				{
					iCountErrors++;
					printerr("Error_0453cd! Incorrect ISurrogateSelector returned");
				}
				iCountTestcases++;
				if(!surrSelect.GetSurrogate(typeof(Int64), context, out ss).Equals(testss1))
				{
					iCountErrors++;
					printerr("Error_350cc! Incorrect ISerializationSurrgate returned");
				}
				iCountTestcases++;
				if(!surrSelect.GetSurrogate(typeof(Int32), context, out ss).Equals(testss2))
				{
					iCountErrors++;
					printerr("Error_350dd! Incorrect IserializationSurrogate returned");
				}
				strLoc = "Loc_370aa";
				testss = new TestSerializationSurrogate();
				testss1 = new TestSerializationSurrogate();
				testss2 = new TestSerializationSurrogate();
				surrSelect = new SurrogateSelector();
				surrSelect.AddSurrogate(typeof(Decimal), context,  testss);
				surrSelect.AddSurrogate(typeof(Int64),context,  testss1);
				surrSelect.AddSurrogate(typeof(Int32),context,  testss2);
				iCountTestcases++;
				if(surrSelect.GetSurrogate(typeof(Int16), context, out ss) != null)
				{
					iCountErrors++;
					printerr("Error_370bb! Type not in surrogateselector was actually found???");
				}
				strLoc = "Loc_400aa";
				surrSelect = new SurrogateSelector();
				testss = new TestSerializationSurrogate();
				testclass = new TestSerializationClass();
				surrSelect.AddSurrogate(testclass.GetType(),context, testss);
				try
				{
					surrSelect.AddSurrogate(testclass.GetType(),context, new TestSerializationSurrogate());
					iCountErrors++;
					printerr("Error_400bb! Expected Exception not thrown");
				}catch (ArgumentException){
				}catch (Exception exc){
					iCountErrors++;
					printerr("Error_400cc! Incorrect Exception thrown : "+exc.ToString());
				}
				surrSelect = new SurrogateSelector();
				surrSelect_next = new SurrogateSelector();
				surrSelect.ChainSelector(surrSelect_next);
				testss = new TestSerializationSurrogate();
				context = new StreamingContext(StreamingContextStates.All);
				surrSelect_next.AddSurrogate(typeof(Decimal), context, testss);
				iCountTestcases++;
				if(!surrSelect.GetSurrogate(typeof(Decimal), context, out ss).Equals(testss))
				{
					iCountErrors++;
					printerr("Error_04582fd! Incorrect ISerializationSurrogate returned");
				}
				iCountTestcases++;
				if(surrSelect == ss)
				{
					iCountErrors++;
					printerr("Error_0478523vdf! Incorrect ISurrogateSelector returned");
				}
				iCountTestcases++;
				if(surrSelect_next != ss)
				{
					iCountErrors++;
					printerr("Error_934721cd! Incorrect ISurrogateSelector returned");
				}
				iHowDeep = 100;
				arrSelectors = new SurrogateSelector[iHowDeep];
				arrSelectors[0] = new SurrogateSelector();
				for(int i=1;i<iHowDeep;i++){
					arrSelectors[i] = new SurrogateSelector();
					arrSelectors[0].ChainSelector(arrSelectors[i]);
				}
				testss = new TestSerializationSurrogate();
				context = new StreamingContext(StreamingContextStates.All);
				arrSelectors[1].AddSurrogate(typeof(Decimal), context, testss);
				iCountTestcases++;
				if(!arrSelectors[0].GetSurrogate(typeof(Decimal), context, out ss).Equals(testss))
				{
					iCountErrors++;
					printerr("Error_743cd! Incorrect ISerializationSurrogate returned");
				}
				iCountTestcases++;
				if(arrSelectors[1] != ss)
				{
					iCountErrors++;
					printerr("Error_10573cd! Incorrect ISurrogateSelector returned");
				}
				arrSelectors[0].AddSurrogate(typeof(Decimal), context, testss);
				iCountTestcases++;
				if(!arrSelectors[0].GetSurrogate(typeof(Decimal), context, out ss).Equals(testss))
				{
					iCountErrors++;
					printerr("Error_0472ds! Incorrect ISerializationSurrogate returned");
				}
				iCountTestcases++;
				if(arrSelectors[0] != ss)
				{
					iCountErrors++;
					printerr("Error_0342dfg! Incorrect ISurrogateSelector returned");
				}
			} while (false);
			} catch (Exception exc_general ) {
			++iCountErrors;
			Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general=="+exc_general.ToString());
			Console.WriteLine(exc_general.StackTrace);
		}
		if ( iCountErrors == 0 )
		{
			Console.WriteLine( "paSs.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
			return true;
		}
		else
		{
			Console.WriteLine("FAiL!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
			return false;
		}
	}