public bool runTest() { Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer); String strLoc = "Loc_000oo"; String strValue = String.Empty; int iCountErrors = 0; int iCountTestcases = 0; Int32 iValue; A a1; V v1; S s1; V_I vi1; Surrogate_1 surrogate; SurrogateSelector selector; SoapFormatter formatter; MemoryStream stream; StreamingContext context = new StreamingContext(StreamingContextStates.All); Object objRet; ReflectionPermission perm; try { strLoc = "Loc_9347sg"; iCountTestcases++; iValue = 5; formatter = new SoapFormatter(); stream = new MemoryStream(); try{ Serialize(formatter, stream, iValue); iCountErrors++; Console.WriteLine("Err_7349sg! No exception thrown, "); }catch(SecurityException){ }catch(Exception ex){ iCountErrors++; Console.WriteLine("Err_348tdg! Wrong exception thrown, " + ex.GetType().Name); } strLoc = "Loc_2407sdg"; iCountTestcases++; stream.Position = 0; formatter.Serialize(stream, iValue); stream.Position = 0; try{ objRet = Deserialize(formatter, stream); }catch(Exception ex){ iCountErrors++; Console.WriteLine("Err_207tdsg! Wrong exception thrown, " + ex.GetType().Name); } strLoc = "Loc_3947tfdg"; iCountTestcases++; a1 = new A(5); formatter = new SoapFormatter(); stream = new MemoryStream(); try{ Serialize(formatter, stream, a1); iCountErrors++; Console.WriteLine("Err_39475sdg! No exception thrown, "); }catch(SecurityException){ }catch(Exception ex){ iCountErrors++; Console.WriteLine("Err_2047tsfgb! Wrong exception thrown, " + ex.GetType().Name); } stream.Position = 0; formatter.Serialize(stream, a1); stream.Position = 0; try{ objRet = Deserialize(formatter, stream); iCountErrors++; Console.WriteLine("Err_9347tsfg! No exception thrown, "); }catch(SecurityException){ }catch(Exception ex){ iCountErrors++; Console.WriteLine("Err_0347tsfg! Wrong exception thrown, " + ex.GetType().Name); } strLoc = "Loc_34975sg"; iCountTestcases++; v1 = new V(5); formatter = new SoapFormatter(); stream = new MemoryStream(); try{ Serialize(formatter, stream, v1); iCountErrors++; Console.WriteLine("Err_98324sdg! No exception thrown, "); }catch(SecurityException){ }catch(Exception ex){ iCountErrors++; Console.WriteLine("Err_3047tfxg! Wrong exception thrown, " + ex.GetType().Name); } stream.Position = 0; formatter.Serialize(stream, v1); stream.Position = 0; try{ objRet = Deserialize(formatter, stream); iCountErrors++; Console.WriteLine("Err_7349sg! No exception thrown, "); } catch(SecurityException) { } catch(Exception ex) { iCountErrors++; Console.WriteLine("Err_29437tsg! Wrong exception thrown, " + ex.GetType().Name); } strLoc = "Loc_34975sg"; iCountTestcases++; s1 = new S(5); formatter = new SoapFormatter(); stream = new MemoryStream(); try{ Serialize(formatter, stream, s1); iCountErrors++; Console.WriteLine("Err_3946tsdg! No exception thrown, "); }catch(SecurityException){ }catch(Exception ex){ iCountErrors++; Console.WriteLine("Err_9347tsdg! Wrong exception thrown, " + ex.GetType().Name); } stream.Position = 0; formatter.Serialize(stream, s1); stream.Position = 0; try{ objRet = Deserialize(formatter, stream); iCountErrors++; Console.WriteLine("Err_98324sdg! No exception thrown, "); } catch(SecurityException) { } catch(Exception ex) { iCountErrors++; Console.WriteLine("Err_93745sdg! Exception thrown, " + ex.GetType().Name); } strLoc = "Loc_34975sg"; iCountTestcases++; vi1 = new V_I(6); formatter = new SoapFormatter(); stream = new MemoryStream(); try{ Serialize(formatter, stream, vi1); iCountErrors++; Console.WriteLine("Err_2075sdg! No exception thrown, "); }catch(SecurityException){ }catch(Exception ex){ iCountErrors++; Console.WriteLine("Err_294375sdg! Wrong exception thrown, " + ex.GetType().Name); } stream.Position = 0; formatter.Serialize(stream, vi1); stream.Position = 0; try{ objRet = Deserialize(formatter, stream); iCountErrors++; Console.WriteLine("Err_98324sdg! No exception thrown, "); } catch(SecurityException) { } catch(Exception ex) { iCountErrors++; Console.WriteLine("Err_24907tsdfg! Exception thrown, " + ex.GetType().Name); } strLoc = "Loc_34975sg"; iCountTestcases++; selector = new SurrogateSelector(); surrogate = new Surrogate_1(); selector.AddSurrogate(typeof(A), context, surrogate); selector.AddSurrogate(typeof(V), context, surrogate); formatter = new SoapFormatter(); formatter.SurrogateSelector = selector; stream = new MemoryStream(); a1 = new A(5); try{ Serialize(formatter, stream, a1); iCountErrors++; Console.WriteLine("Err_93475sdg! No exception thrown, "); }catch(SecurityException){ }catch(Exception ex){ iCountErrors++; Console.WriteLine("Err_3947tsg! Wrong exception thrown, " + ex.GetType().Name); } stream.Position = 0; formatter.Serialize(stream, a1); stream.Position = 0; try{ objRet = Deserialize(formatter, stream); iCountErrors++; Console.WriteLine("Err_98324sdg! No exception thrown, "); } catch(SecurityException) { } catch(Exception ex) { iCountErrors++; Console.WriteLine("Err_39047tsg! Exception thrown, " + ex.GetType().Name); } strLoc = "Loc_3048sdg"; iCountTestcases++; v1 = new V(7); formatter = new SoapFormatter(); formatter.SurrogateSelector = selector; stream = new MemoryStream(); try{ Serialize(formatter, stream, v1); iCountErrors++; Console.WriteLine("Err_9347tsgf! No exception thrown, "); }catch(SecurityException){ }catch(Exception ex){ iCountErrors++; Console.WriteLine("Err_2947tsgd! Wrong exception thrown, " + ex.GetType().Name); } stream.Position = 0; formatter.Serialize(stream, v1); stream.Position = 0; try{ objRet = Deserialize(formatter, stream); iCountErrors++; Console.WriteLine("Err_98324sdg! No exception thrown, "); } catch(SecurityException) { } catch(Exception ex) { iCountErrors++; Console.WriteLine("Err_89734trfsg! Exception thrown, " + ex.GetType().Name); } perm = new ReflectionPermission(PermissionState.Unrestricted); perm.Deny(); strLoc = "Loc_83245tsg"; iCountTestcases++; a1 = new A(5); formatter = new SoapFormatter(); stream = new MemoryStream(); try{ formatter.Serialize(stream, a1); stream.Position = 0; objRet = formatter.Deserialize(stream); if(((A)objRet).I!=5){ iCountErrors++; Console.WriteLine("Err_3947tsdg! wrong value returned, " + (Int32)objRet); } }catch(Exception ex){ iCountErrors++; Console.WriteLine("Err_29746tsfdg! Exception thrown, " + ex.GetType().Name); } } catch (Exception exc_general ) { ++iCountErrors; Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy! strLoc=="+ strLoc +", exc_general=="+exc_general.ToString()); } if ( iCountErrors == 0 ) { Console.WriteLine( "paSs. "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString()); return true; } else { Console.WriteLine("FAiL! "+s_strTFName+" ,inCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums ); return false; } }
public bool runTest() { Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer); String strLoc = "Loc_000oo"; String strValue = String.Empty; int iCountErrors = 0; int iCountTestcases = 0; Int32 iValue; A a1; V v1; S s1; V_I vi1; Surrogate_1 surrogate; SurrogateSelector selector; SoapFormatter formatter; MemoryStream stream; StreamingContext context = new StreamingContext(StreamingContextStates.All); Object objRet; ReflectionPermission perm; try { strLoc = "Loc_9347sg"; iCountTestcases++; iValue = 5; formatter = new SoapFormatter(); stream = new MemoryStream(); try{ Serialize(formatter, stream, iValue); iCountErrors++; Console.WriteLine("Err_7349sg! No exception thrown, "); }catch (SecurityException) { }catch (Exception ex) { iCountErrors++; Console.WriteLine("Err_348tdg! Wrong exception thrown, " + ex.GetType().Name); } strLoc = "Loc_2407sdg"; iCountTestcases++; stream.Position = 0; formatter.Serialize(stream, iValue); stream.Position = 0; try{ objRet = Deserialize(formatter, stream); }catch (Exception ex) { iCountErrors++; Console.WriteLine("Err_207tdsg! Wrong exception thrown, " + ex.GetType().Name); } strLoc = "Loc_3947tfdg"; iCountTestcases++; a1 = new A(5); formatter = new SoapFormatter(); stream = new MemoryStream(); try{ Serialize(formatter, stream, a1); iCountErrors++; Console.WriteLine("Err_39475sdg! No exception thrown, "); }catch (SecurityException) { }catch (Exception ex) { iCountErrors++; Console.WriteLine("Err_2047tsfgb! Wrong exception thrown, " + ex.GetType().Name); } stream.Position = 0; formatter.Serialize(stream, a1); stream.Position = 0; try{ objRet = Deserialize(formatter, stream); iCountErrors++; Console.WriteLine("Err_9347tsfg! No exception thrown, "); }catch (SecurityException) { }catch (Exception ex) { iCountErrors++; Console.WriteLine("Err_0347tsfg! Wrong exception thrown, " + ex.GetType().Name); } strLoc = "Loc_34975sg"; iCountTestcases++; v1 = new V(5); formatter = new SoapFormatter(); stream = new MemoryStream(); try{ Serialize(formatter, stream, v1); iCountErrors++; Console.WriteLine("Err_98324sdg! No exception thrown, "); }catch (SecurityException) { }catch (Exception ex) { iCountErrors++; Console.WriteLine("Err_3047tfxg! Wrong exception thrown, " + ex.GetType().Name); } stream.Position = 0; formatter.Serialize(stream, v1); stream.Position = 0; try{ objRet = Deserialize(formatter, stream); iCountErrors++; Console.WriteLine("Err_7349sg! No exception thrown, "); } catch (SecurityException) { } catch (Exception ex) { iCountErrors++; Console.WriteLine("Err_29437tsg! Wrong exception thrown, " + ex.GetType().Name); } strLoc = "Loc_34975sg"; iCountTestcases++; s1 = new S(5); formatter = new SoapFormatter(); stream = new MemoryStream(); try{ Serialize(formatter, stream, s1); iCountErrors++; Console.WriteLine("Err_3946tsdg! No exception thrown, "); }catch (SecurityException) { }catch (Exception ex) { iCountErrors++; Console.WriteLine("Err_9347tsdg! Wrong exception thrown, " + ex.GetType().Name); } stream.Position = 0; formatter.Serialize(stream, s1); stream.Position = 0; try{ objRet = Deserialize(formatter, stream); iCountErrors++; Console.WriteLine("Err_98324sdg! No exception thrown, "); } catch (SecurityException) { } catch (Exception ex) { iCountErrors++; Console.WriteLine("Err_93745sdg! Exception thrown, " + ex.GetType().Name); } strLoc = "Loc_34975sg"; iCountTestcases++; vi1 = new V_I(6); formatter = new SoapFormatter(); stream = new MemoryStream(); try{ Serialize(formatter, stream, vi1); iCountErrors++; Console.WriteLine("Err_2075sdg! No exception thrown, "); }catch (SecurityException) { }catch (Exception ex) { iCountErrors++; Console.WriteLine("Err_294375sdg! Wrong exception thrown, " + ex.GetType().Name); } stream.Position = 0; formatter.Serialize(stream, vi1); stream.Position = 0; try{ objRet = Deserialize(formatter, stream); iCountErrors++; Console.WriteLine("Err_98324sdg! No exception thrown, "); } catch (SecurityException) { } catch (Exception ex) { iCountErrors++; Console.WriteLine("Err_24907tsdfg! Exception thrown, " + ex.GetType().Name); } strLoc = "Loc_34975sg"; iCountTestcases++; selector = new SurrogateSelector(); surrogate = new Surrogate_1(); selector.AddSurrogate(typeof(A), context, surrogate); selector.AddSurrogate(typeof(V), context, surrogate); formatter = new SoapFormatter(); formatter.SurrogateSelector = selector; stream = new MemoryStream(); a1 = new A(5); try{ Serialize(formatter, stream, a1); iCountErrors++; Console.WriteLine("Err_93475sdg! No exception thrown, "); }catch (SecurityException) { }catch (Exception ex) { iCountErrors++; Console.WriteLine("Err_3947tsg! Wrong exception thrown, " + ex.GetType().Name); } stream.Position = 0; formatter.Serialize(stream, a1); stream.Position = 0; try{ objRet = Deserialize(formatter, stream); iCountErrors++; Console.WriteLine("Err_98324sdg! No exception thrown, "); } catch (SecurityException) { } catch (Exception ex) { iCountErrors++; Console.WriteLine("Err_39047tsg! Exception thrown, " + ex.GetType().Name); } strLoc = "Loc_3048sdg"; iCountTestcases++; v1 = new V(7); formatter = new SoapFormatter(); formatter.SurrogateSelector = selector; stream = new MemoryStream(); try{ Serialize(formatter, stream, v1); iCountErrors++; Console.WriteLine("Err_9347tsgf! No exception thrown, "); }catch (SecurityException) { }catch (Exception ex) { iCountErrors++; Console.WriteLine("Err_2947tsgd! Wrong exception thrown, " + ex.GetType().Name); } stream.Position = 0; formatter.Serialize(stream, v1); stream.Position = 0; try{ objRet = Deserialize(formatter, stream); iCountErrors++; Console.WriteLine("Err_98324sdg! No exception thrown, "); } catch (SecurityException) { } catch (Exception ex) { iCountErrors++; Console.WriteLine("Err_89734trfsg! Exception thrown, " + ex.GetType().Name); } perm = new ReflectionPermission(PermissionState.Unrestricted); perm.Deny(); strLoc = "Loc_83245tsg"; iCountTestcases++; a1 = new A(5); formatter = new SoapFormatter(); stream = new MemoryStream(); try{ formatter.Serialize(stream, a1); stream.Position = 0; objRet = formatter.Deserialize(stream); if (((A)objRet).I != 5) { iCountErrors++; Console.WriteLine("Err_3947tsdg! wrong value returned, " + (Int32)objRet); } }catch (Exception ex) { iCountErrors++; Console.WriteLine("Err_29746tsfdg! Exception thrown, " + ex.GetType().Name); } } catch (Exception exc_general) { ++iCountErrors; Console.WriteLine(s_strTFAbbrev + " : Error Err_8888yyy! strLoc==" + strLoc + ", exc_general==" + exc_general.ToString()); } if (iCountErrors == 0) { Console.WriteLine("paSs. " + s_strTFName + " ,iCountTestcases==" + iCountTestcases.ToString()); return(true); } else { Console.WriteLine("FAiL! " + s_strTFName + " ,inCountErrors==" + iCountErrors.ToString() + " , BugNums?: " + s_strActiveBugNums); return(false); } }