Here is a snippet of my test code:
When I do this I get an exception:
System.IO.FileLoadException: System.IO.FileLoadException: Could not load file or assembly 'Telerik.JustMock_fe91bf8a4e2f4132a3849f92ab689d67, Version=2012.3.1025.4, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044).
at Microsoft.Practices.Prism.Events.CompositePresentationEvent`1.Subscribe(Action`1 action)
at Complaints.Modules.Web.ViewModels.PendingListViewModel..ctor(IPendingListView view, ISubmissionRepository subRepository, IEventAggregator events) in PendingListViewModel.cs: line 73
If I remove the code that creates and arranges subscribedEvent and leave the mocked event aggregator alone (just create, no arranging), then the same line of code returns a NullReferenceException.
The problem line of code is :
in the constructor of my Class under test.
I had the same issues when I used a Mocking Container, so I switched to creating all the mocks individually, but it's still not working.
What am I doing wrong?
private
PendingListViewModel _vm;
[TestInitialize]
public
void
Setup()
{
var view = Mock.Create<IPendingListView>();
var repository = Mock.Create<ISubmissionRepository>();
repository.Arrange(x => x.GetPendingSubmissions()).Returns(GetSubmissionSet());
var subscribedEvent = Mock.Create<RefreshPendingSubmissions>();
subscribedEvent.Arrange(x => x.Subscribe(Arg.IsAny<Action<
string
>>())).DoNothing();
var events = Mock.Create<IEventAggregator>();
events.Arrange(x => x.GetEvent<RefreshPendingSubmissions>()).Returns(subscribedEvent);
_vm =
new
PendingListViewModel(view, repository, events);
}
[TestMethod]
public
void
ExecuteSortByCountyCommand_CollectionShouldContainOneSortDescriptor()
{
_vm.SortCountyCommand.Execute(
"ASC"
);
Assert.IsTrue(_vm.SubmissionsCollection.SortDescriptions.Count == 1);
}
When I do this I get an exception:
System.IO.FileLoadException: System.IO.FileLoadException: Could not load file or assembly 'Telerik.JustMock_fe91bf8a4e2f4132a3849f92ab689d67, Version=2012.3.1025.4, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044).
at Microsoft.Practices.Prism.Events.CompositePresentationEvent`1.Subscribe(Action`1 action)
at Complaints.Modules.Web.ViewModels.PendingListViewModel..ctor(IPendingListView view, ISubmissionRepository subRepository, IEventAggregator events) in PendingListViewModel.cs: line 73
If I remove the code that creates and arranges subscribedEvent and leave the mocked event aggregator alone (just create, no arranging), then the same line of code returns a NullReferenceException.
The problem line of code is :
_events.GetEvent<RefreshPendingSubmissions>().Subscribe(a => OnRefresh());
in the constructor of my Class under test.
I had the same issues when I used a Mocking Container, so I switched to creating all the mocks individually, but it's still not working.
What am I doing wrong?