chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
We are using Isolator (I know there is a later version, but we are in the middle of a project and our tech lead does not want to update).

I wanted to test the paths through the following code:

Private Sub LogStart(ByVal xmlData As String)

      startTime = DateTime.Now()
      auditLog.AddToAudit("Date: " & startTime.ToString("MMddyyyy hh:mm:ss tt"))
      If My.Settings.DisplayXMLDebugData Then
         auditLog.AddToAudit("XML: " & xmlData)
      End If

   End Sub

Specifically, I expect auditLog.AddToAudit() to be called twice if My.Settings.DisplayXMLDebugData returns false and four times if My.Settings.DisplayXMLDebugData returns true.

My initial test was something like:
<TestMethod> _
   Public Sub LogStartWithXMLTest()
      Dim target As LoanProcessingWS_Accessor = New LoanProcessingWS_Accessor

      Using recorder As New TypeMock.RecordExpectations
           Dim dummy As Boolean = My.Settings.DisplayXMLDebugData()
      End Using



   End Sub

But that did not work. The error message is:
Test method AgFirst.LoanProcessing.WS.Tests.LoanProcessingWSTest.LogStartWithXMLTest threw exception: TypeMock.VerifyException:
TypeMock Verification: Method AgFirst.LoanProcessing.Common.AuditLog.AddToAudit() has 2 more expected calls
Method AgFirst.LoanProcessing.WS.Tests.My.MySettingsProperty.get_Settings() has 1 more expected calls
Method AgFirst.LoanProcessing.WS.Tests.My.MySettings.get_DisplayXMLDebugData() has 1 more expected calls

Can anyone help me out with how to mock a My.Settings property? I searched the forums but could not locate any thing on this.

asked by hodge (1.1k points)

3 Answers

0 votes
Is Auditlog a field or property?

I need a bit more information to further investigate this issue - lets take it offline
answered by dhelper (11.9k points)
0 votes

AuditLog is a class that contains audit logs. AddToAudit is a method that adds a line to the audit logs.

Feel free to contact me off-line. Since you are a moderator, I assume that you have my email address.

answered by hodge (1.1k points)
0 votes
The reason it didn't work was because My is a short write for Module/Class .My property in order to set bahvior on My all you need to do is write its "full name" at the recording block - AuditLog.My.Settings... and not just My.Settings which is a different Settings for the test class.
answered by dhelper (11.9k points)