public void LotteryReferenceDrawTest() { Lottery <TestReference> lottery = new Lottery <TestReference>(); var reference = new TestReference(); lottery.Enter(reference, 10); Assert.That(ReferenceEquals(reference, lottery.Draw())); }
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"; ObjectManager objmgr1 = null; ISurrogateSelector isur = null; StreamingContext sc1 = new StreamingContext(StreamingContextStates.All); ObjectIDGenerator objid1 = null; TestFixup tstfxp1; Int64 iRootID; Int64 iChildID; String strValue; bool fFirstTime; MemberInfo[] members = null; TestReference tst1; ThisImplementsIObjectReference tst2; try { do { strLoc="Loc_174cds"; tstfxp1 = new TestFixup(); objid1 = new ObjectIDGenerator(); iRootID = objid1.GetId(tstfxp1, out fFirstTime); strValue = "Hello World"; iChildID = objid1.GetId(strValue, out fFirstTime); members = FormatterServices.GetSerializableMembers(tstfxp1.GetType()); objmgr1 = new ObjectManager(isur, sc1); objmgr1.RecordFixup(iRootID, members[0], iChildID); objmgr1.RegisterObject(tstfxp1, iRootID); objmgr1.RegisterObject(strValue, iChildID); iCountTestcases++; if(!tstfxp1.strFixupValue.Equals(strValue)) { iCountErrors++; Console.WriteLine("Err_753cd! Expected value not returned, " + tstfxp1.strFixupValue + ", expected, " + strValue); } objmgr1.DoFixups(); iCountTestcases++; if(!tstfxp1.strFixupValue.Equals(strValue)) { iCountErrors++; Console.WriteLine("Err_90342ddvs! Expected value not returned, " + tstfxp1.strFixupValue + ", expected, " + strValue); } strLoc="Loc_5720xs"; tst1 = new TestReference(); tst2 = new ThisImplementsIObjectReference(); objid1 = new ObjectIDGenerator(); iRootID = objid1.GetId(tst1, out fFirstTime); iChildID = objid1.GetId(tst2, out fFirstTime); members = FormatterServices.GetSerializableMembers(typeof(TestReference)); Console.WriteLine("<<" + members[0].Name + ">>"); objmgr1 = new ObjectManager(isur, sc1); objmgr1.RecordFixup(iRootID, members[0], iChildID); objmgr1.RegisterObject(tst1, iRootID); objmgr1.RegisterObject(tst2, iChildID); try{ iCountTestcases++; objmgr1.DoFixups(); iCountErrors++; Console.WriteLine("Err_753fvdf! exception not thrown!!"); }catch(SerializationException){ }catch(Exception ex){ iCountErrors++; Console.WriteLine("Err_04523cd! Unexpected exception, " + ex.ToString()); } } while (false); } catch (Exception exc_general ) { ++iCountErrors; Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy! strLoc=="+ strLoc +", exc_general==\n"+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"; ObjectManager objmgr1 = null; ISurrogateSelector isur = null; StreamingContext sc1 = new StreamingContext(StreamingContextStates.All); ObjectIDGenerator objid1 = null; TestFixup tstfxp1; Int64 iRootID; Int64 iChildID; String strValue; bool fFirstTime; MemberInfo[] members = null; TestReference tst1; ThisImplementsIObjectReference tst2; try { do { strLoc = "Loc_174cds"; tstfxp1 = new TestFixup(); objid1 = new ObjectIDGenerator(); iRootID = objid1.GetId(tstfxp1, out fFirstTime); strValue = "Hello World"; iChildID = objid1.GetId(strValue, out fFirstTime); members = FormatterServices.GetSerializableMembers(tstfxp1.GetType()); objmgr1 = new ObjectManager(isur, sc1); objmgr1.RecordFixup(iRootID, members[0], iChildID); objmgr1.RegisterObject(tstfxp1, iRootID); objmgr1.RegisterObject(strValue, iChildID); iCountTestcases++; if (!tstfxp1.strFixupValue.Equals(strValue)) { iCountErrors++; Console.WriteLine("Err_753cd! Expected value not returned, " + tstfxp1.strFixupValue + ", expected, " + strValue); } objmgr1.DoFixups(); iCountTestcases++; if (!tstfxp1.strFixupValue.Equals(strValue)) { iCountErrors++; Console.WriteLine("Err_90342ddvs! Expected value not returned, " + tstfxp1.strFixupValue + ", expected, " + strValue); } strLoc = "Loc_5720xs"; tst1 = new TestReference(); tst2 = new ThisImplementsIObjectReference(); objid1 = new ObjectIDGenerator(); iRootID = objid1.GetId(tst1, out fFirstTime); iChildID = objid1.GetId(tst2, out fFirstTime); members = FormatterServices.GetSerializableMembers(typeof(TestReference)); Console.WriteLine("<<" + members[0].Name + ">>"); objmgr1 = new ObjectManager(isur, sc1); objmgr1.RecordFixup(iRootID, members[0], iChildID); objmgr1.RegisterObject(tst1, iRootID); objmgr1.RegisterObject(tst2, iChildID); try{ iCountTestcases++; objmgr1.DoFixups(); iCountErrors++; Console.WriteLine("Err_753fvdf! exception not thrown!!"); }catch (SerializationException) { }catch (Exception ex) { iCountErrors++; Console.WriteLine("Err_04523cd! Unexpected exception, " + ex.ToString()); } } while (false); } catch (Exception exc_general) { ++iCountErrors; Console.WriteLine(s_strTFAbbrev + " : Error Err_8888yyy! strLoc==" + strLoc + ", exc_general==\n" + 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); } }
static void AnotherMethod(TestReference testReference) { testReference(); Console.WriteLine("Hello From Another Method"); }