Bone Head or Bug in 2.1

Bone Head or Bug in 2.1

Old forum URL: forums.lhotka.net/forums/t/982.aspx


JZuerlein posted on Tuesday, August 22, 2006

I have a unit test that I was expecting to pass, but it doesn't.  It almost feels like there are two instances of the CommentResponse object.  One with the value from the database, and one that was changed to string.empty.  I havn't tried it with 2.03.

Anyone see a bonehead mistake in the code?

<Test()> _

Public Sub ChangeProperty()

   Dim testEval As Evaluation = Evaluation.GetEvaluation(_eval.EvaluationID)

   For Each r As AbstractResponse In _eval.Responses

      If r.QuestionID = _commentQuestion.QuestionID Then

      _commentResponseID = CType(r, CommentResponse).ResponseID

      CType(r, CommentResponse).Comment = String.Empty

      End If

   Next

   Assert.AreEqual(String.Empty, CType(testEval.Responses.GetItem(_commentResponseID),    CommentResponse).Comment)

End Sub

Public Function GetItem(ByVal ResponseID As Integer) As IResponse

   For Each r As AbstractResponse In Me

      If r.ResponseID = ResponseID Then

         Return r

      End If

     Next

   Return Nothing

End Function

 

UnitTest Result:

EPAS.BusinessObjects.UnitTests.ResponseTestFixtures.CommmentResponseFixture.ChangeProperty :
 String lengths differ.  Expected length=0, but was length=4.
 Strings differ at index 0.
 expected: <"">
  but was: <"Test">
 ------------^

Baldu replied on Tuesday, August 22, 2006

You're iterating over _eval.Responses when you set the Comment to String.Empty, but you use testEval.Responses in your Assert statement.  I'm assuming you are returning a new object from GetEvaluation.

JZuerlein replied on Tuesday, August 22, 2006

Bonehead it is! 

Thanks you for the help.

Jeff

Copyright (c) Marimer LLC