public void ListThresholdIsHandled() { var mockObjects = MockFactories.GetMockObjects(); var vm = MockFactories.DeepLinkHistoryViewModelFactory(mockObjects); for (int i = 1; i <= 10; i++) { vm.Handle(new DeepLinkMatchesUpdatedEvent( new List <DeepLinkMatch>() { new DeepLinkMatch(), }, "test" + i)); } Assert.Equal(10, vm.HistoryEntryList.Count); vm.Handle(new DeepLinkMatchesUpdatedEvent( new List <DeepLinkMatch>() { MockedDeeplinkMatches.SimpleDeepLinkMatch, }, "test100")); Assert.Equal(10, vm.HistoryEntryList.Count); Assert.Equal("test2", vm.HistoryEntryList.Last().DeepLinkMatchValue); Assert.Equal("test100", vm.HistoryEntryList.First().DeepLinkMatchValue); }
public void VmIsSubscribedToEventAggregator() { var mockObjects = MockFactories.GetMockObjects(); var eventAggregatorMock = Mock.Get((IEventAggregator)mockObjects[nameof(IEventAggregator)]); var vm = MockFactories.DeepLinkHistoryViewModelFactory(mockObjects); // Test to make sure subscribe was called on the event aggregator at least once eventAggregatorMock.Verify(x => x.Subscribe(vm), Times.Once); }
public void IncomingEventsAreHandled() { var mockObjects = MockFactories.GetMockObjects(); var vm = MockFactories.DeepLinkHistoryViewModelFactory(mockObjects); vm.Handle(new DeepLinkMatchesUpdatedEvent( new List <DeepLinkMatch>() { MockedDeeplinkMatches.SimpleDeepLinkMatch, }, "test")); Assert.NotEmpty(vm.HistoryEntryList); }
public void SelectedEntryIsPublishedAfterSelectionChanged() { var mockObjects = MockFactories.GetMockObjects(); var eventAggregatorMock = Mock.Get((IEventAggregator)mockObjects[nameof(IEventAggregator)]); eventAggregatorMock.Setup(x => x.Publish(It.IsAny <object>(), It.IsAny <System.Action <System.Action> >())).Verifiable(); var vm = MockFactories.DeepLinkHistoryViewModelFactory(mockObjects); vm.HistoryItemsSelectionChangedCommand.Execute(new HistoryEntry() { DeepLinkMatches = new List <DeepLinkMatch>() { MockedDeeplinkMatches.SimpleDeepLinkMatch, }, DeepLinkMatchValue = "test", }); eventAggregatorMock.Verify(x => x.Publish(It.IsAny <object>(), It.IsAny <System.Action <System.Action> >()), Times.Exactly(1)); Assert.Equal("test", vm.HistoryEntry.DeepLinkMatchValue); }
public void KnownEntriesDoNotUpdateList() { var mockObjects = MockFactories.GetMockObjects(); var vm = MockFactories.DeepLinkHistoryViewModelFactory(mockObjects); vm.HistoryEntryList.Add(new HistoryEntry() { DeepLinkMatches = new List <DeepLinkMatch>() { MockedDeeplinkMatches.SimpleDeepLinkMatch, }, DeepLinkMatchValue = "test", }); vm.Handle(new DeepLinkMatchesUpdatedEvent( new List <DeepLinkMatch>() { MockedDeeplinkMatches.SimpleDeepLinkMatch, }, "test")); Assert.Single(vm.HistoryEntryList); }