Unit test crashes in TFS but not locally (NullReferenceException)

I have the following unit test (some things have been renamed, but otherwise identical), which works fine locally and passes as expected.

[TestClass, ExcludeFromCodeCoverage] public class SearchControllerTests { private Mock<IRepository> _repository; private Mock<ICrypter> _crypter; private SearchController _controller; [TestInitialize] public void Initialize() { _repository = new Mock<IRepository>(); _crypter = new Mock<ICrypter>(); _controller = new SearchController(_repository.Object, _crypter.Object); } [TestMethod] public void SearchViewSimple() { var result = _controller.Search() as PartialViewResult; Assert.IsNotNull(result); Assert.AreEqual("Search", result.ViewBag.Title); } } 

It also runs in TFS 2015. However, we are updating to update TFS 2015 Update 2, and in this case, a failure in this environment does not work with the identical build process. The NullReferenceException is thrown on this line in the initialization method.

 _crypter = new Mock<ICrypter>(); 

ICrypter is a very simple shell for SCrypt using CryptSharp:

 [assembly: Dependency(typeof(ICrypter), typeof(Crypter))] namespace ProjectNameRemoved.Cryptography { public interface ICrypter { string GetHash(string value); } public class Crypter : ICrypter { public string GetHash(string value) { // Removed } } } 

Is there a difference between TFS 2015 and 2015 Update 2, which might cause something like this? Or maybe some kind of dependency problem when CryptSharp does not load? The external connections in the assembly are beautiful, and the packages seem to have been updated without problems or warnings.

+6
source share

All Articles