I am testing SendEmail using Unit Tests (Nunit):
// Arrange
var mockDbContext = new Mock<DbContext>();
IService service = new Service(mockDbContext.Object);
// Act
var result = service.SendEmail(string.Empty,1,1);
//Assert
Assert.That(result, Is.Not.Null);
Assert.That(result, Is.InstanceOf<bool>());
Assert.AreEqual(result, false);
public bool SendEmail(string emailAddress, int mId, int deadline)
{
try
{
dynamic email = new Email("CirculationEmail");
email.To = emailAddress;
email.MId = mId;
email.Deadline = deadline;
email.Send();
return true;
}
catch (Exception ex)
{
Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
return false;
}
}
SendEmail uses Postal. I get the following error when I run the test. When I debug it throws the error before even hitting the first debug point within my SendEmail.
System.IO.FileLoadException : Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I added the below to the app.config and searched through my code to see if it ever references 3.0.0.0, it doesn't.
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
I am wondering if maybe another error message is being masked (somehow) by the MVC wrong version one?