コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }