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 4.2.3.0 (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"))
      auditLog.AddToAudit("")
      If My.Settings.DisplayXMLDebugData Then
         auditLog.AddToAudit("XML: " & xmlData)
         auditLog.AddToAudit("")
      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()
           recorder.Return(True).Repeat(1)
           target.auditLog.AddToAudit(Nothing)
           recorder.Repeat(4)
      End Using

      target.LogStart(<test>test</test>.ToString())

      MockManager.Verify()

   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.

Thanks,
Bobby
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
Hi,

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.

Thanks,
Bobby
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)
...