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 have installed TypeMock 5.4.5, and several tests failed with strange TypeMock exceptions that we did not observe before.

Unfortunately the project is large, so I can't extract a small example that reproduces behavior, but here's what happens:

1. We have a test called GetCodeTables_ValidData_success.
2. In "arrange" part of test we fake a few objects
3. Test code makes a call to a method GetCodeTables
4. Inside GetCodeTables there is a following code:

                    Predicate<CpCurrencyInfo> predicate = c => c.CurrencyCode.Equals(responseCountryInfo.baseReceiveCurrency, StringComparison.InvariantCultureIgnoreCase);
                    var baseReceiveCurrency = currencyInfos.Find(predicate);


Attempt to execute this code fails with the following exception:

*** No method with name <GetCodeTables in type Contopronto.Connectors.MoneyGram.CpMoneyGramConnector exists.
at cn.b(Type A_0, String A_1)
at cn.c(Type A_0, String A_1)
at ce.a(String A_0, Object[] A_1, Object A_2, Object A_3, String A_4, Type A_5)
at c8.a(String A_0, Object A_1, MethodBase A_2, Object[] A_3, Object A_4, String A_5, ce A_6)
at c8.b(Object A_0, String A_1, String A_2, MethodBase A_3, Object[] A_4, Object A_5)
C:ProjectsTfs2008LuupTxpMainNETConnectorsMoneyGramManagerCpMoneyGramConnector.cs(1285,0): at Contopronto.Connectors.MoneyGram.CpMoneyGramConnector.<>c__DisplayClassc.<GetCodeTables>b__5(CpCurrencyInfo c)
at System.Collections.Generic.List`1.Find(Predicate`1 match)
C:ProjectsTfs2008LuupTxpMainNETConnectorsMoneyGramManagerCpMoneyGramConnector.cs(1368,0): at Contopronto.Connectors.MoneyGram.CpMoneyGramConnector.GetCodeTables()
C:ProjectsTfs2008LuupTxpMainNETConnectorsMoneyGramManagerTestsUnitCpMoneyGramConnectorTests.cs(1467,0): at Contopronto.Connectors.MoneyGram.Tests.Unit.CpMoneyGramConnectorTests.GetCodeTables_ValidData_success()
at TypeMock.MockManager.a(String A_0, String A_1, Object A_2, Object A_3, Boolean A_4, Object[] A_5)
at TypeMock.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected)
C:ProjectsTfs2008LuupTxpMainNETConnectorsMoneyGramManagerTestsUnitCpMoneyGramConnectorTests.cs(0,0): at Contopronto.Connectors.MoneyGram.Tests.Unit.CpMoneyGramConnectorTests.GetCodeTables_ValidData_success()

It looks like newest version of TypeMock has a problem with interpreting method name in the line
Contopronto.Connectors.MoneyGram.CpMoneyGramConnector.<>c__DisplayClassc.<GetCodeTables>b__5(CpCurrencyInfo c)

Apparently it expects a method name <GetCodeTables, prefixed with angle bracket which is of coure wrong.

Everything worked fine with previous Isolator version.
asked by vagif (19.4k points)

5 Answers

0 votes
Hi Vagif,

I have a few questions regarding this issue:
  • Do you fake the CodeTables class?
    Do you fake the CpMoneyGramConnector?
    What line does the exception come from (in your code)?


I've checked the code you've posted and it works fine. Unfortunately without a repro it would be very hard to understand this issue - is there a way to at least provide me with additional code so I can investigate this issue?
answered by dhelper (11.9k points)
0 votes
Hi Vagif,

I have a few questions regarding this issue:
  • Do you fake the CodeTables class?
    Do you fake the CpMoneyGramConnector?
    What line does the exception come from (in your code)?

I've checked the code you've posted and it works fine. Unfortunately without a repro it would be very hard to understand this issue - is there a way to at least provide me with additional code so I can investigate this issue?


Few more details:

Code tables are faked.
CpMoneyGramConnector is not faked.

Here's the offending piece:

                foreach (var responseCountryInfo in codeTableResponse.countryInfo)
                {
                    var countryInfo = new CpCountryInfo
                    {
                        BaseReceiveCurrency =
                            currencyInfos.Find(
                            c =>
                            c.CurrencyCode.Equals(responseCountryInfo.baseReceiveCurrency,
                                                  StringComparison.InvariantCultureIgnoreCase)),
                        CountryCode = responseCountryInfo.countryCode,
                        CountryLegacyCode = responseCountryInfo.countryLegacyCode,
                        CountryName = responseCountryInfo.countryName,
                        DirectedSendCountry = responseCountryInfo.directedSendCountry,
                        MoneyGramDirectedSendCountry = responseCountryInfo.mgDirectedSendCountry,
                        ReceiveActive = responseCountryInfo.receiveActive,
                        SendActive = responseCountryInfo.sendActive
                    };
                    countryInfos.Add(countryInfo);
                }


The exception is thrown when executing currencyInfos.Find delegate.
answered by vagif (19.4k points)
0 votes
Hi Vagif,

Please send the test code as well. I'm still cannot find the issue.
answered by dhelper (11.9k points)
0 votes
Hi Vagif,

Please send the test code as well. I'm still cannot find the issue.


I need some time to extract the offending part. The code is not mine, I will try to simplify it.
answered by vagif (19.4k points)
0 votes
Hi Vagif,

Please send the test code as well. I'm still cannot find the issue.


Hi!

See my latest post "Isolate.NonPublic is broken in 5.4.5". I managed to extract the code that triggers the failure.

Hope this helps.

Vagif
answered by vagif (19.4k points)
...