Sorry for the bad subject
I have a test that uses TypeMock to intercept an SMS component. This works fine if I select to run only the one test. When I select two or more tests to run in the same test run, the test fails. The test in question is the
ShouldAbortWithSMSNotificationIfReferredNumberAlreadyUsedInCurrentPromo test below.
I have tried to remove the transaction stuff, and I have tried to Sleep the test at various places to see if there is a lag in there somewhere, but with no luck. I would really appreciate any help to get this test to run fine alongside other tests.
Thanks,
Morten
[TestMethod]
public void ShouldAbortWithSMSNotificationIfReferredNumberAlreadyRegistered()
{
ReturnCodes expected = ReturnCodes.PhoneNumberAlreadyExists;
MockManager.Init();
Mock smsMock = MockManager.Mock(typeof(HSLSMSProvider), Constructor.NotMocked);
smsMock.ExpectAndReturn("EnqueueMessage", ReturnCodes.OK, null).Args("+4741******-2", "The number +4741****** is already registered with ****** and is not eligible for the free €5.", "447797******", SMS.Providers.SMSSendPriority.Normal);
FreeMoneySMSPromo promo = getPromo();
ReturnCodes actual = promo.Process("PROMO 1 +4741******", "+4741******-2");
Assert.AreEqual(expected, actual, "Result didn't match");
MockManager.Verify();
}
[TestMethod]
public void ShouldAbortWithSMSNotificationIfReferredNumberAlreadyUsedInCurrentPromo()
{
ReturnCodes expected, actual;
string referringMobileNumber = "+4741******";
string referredMobileNumber = "+123456789";
FreeMoneySMSPromo promo = getPromo();
MockManager.Init();
Mock smsMock = MockManager.Mock(typeof(HSLSMSProvider), Constructor.Mocked);
smsMock.ExpectGet("SMSNumber", "4733******");
smsMock.ExpectAndReturn("EnqueueMessage", ReturnCodes.OK, null).Args(referringMobileNumber, "The number +123456789 is already registered in this promotion and has already got the free €5.", "4733******", SMS.Providers.SMSSendPriority.Normal);
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
{
PromoDSTableAdapters.PromoPendingAccountsTableAdapter adapter = new PromoPendingAccountsTableAdapter();
adapter.Insert(referredMobileNumber, (int?)promo.Settings.InitialFreeMoneyValue, 25, false, null);
expected = ReturnCodes.PhoneNumberAlreadyRegisteredInCurrentPromo;
actual = promo.Process(string.Format("PROMO 1 {0}", referredMobileNumber), referringMobileNumber);
}
Assert.AreEqual(expected, actual, "Result didn't match");
MockManager.Verify();
}