Example #1
0
        public void ProcessingMultipleRowsAndTrimmingSucceeds()
        {
            var mockObjects          = MockFactories.GetMockObjects();
            var clipboardConfig      = Mock.Get((IClipboardConfiguration)mockObjects[nameof(IClipboardConfiguration)]);
            var sharpClipboardMapper = Mock.Get((ISharpClipboardMapper)mockObjects[nameof(ISharpClipboardMapper)]);
            var textCopyMapper       = Mock.Get((ITextCopyMapper)mockObjects[nameof(ITextCopyMapper)]);

            clipboardConfig.SetupGet(x => x.AutomaticTrim).Returns(true);
            clipboardConfig.SetupGet(x => x.ProcessMultipleRows).Returns(true);
            clipboardConfig.SetupGet(x => x.MaxProcessedRows).Returns(100);

            var clipboardManager = MockFactories.ClipboardManagerFactory(mockObjects);

            string[] entries = new[] { string.Empty };
            clipboardManager.ClipboardTextUpdateReceived += (s, e) =>
            {
                entries = e.ClipboardEntries;
            };

            sharpClipboardMapper.Raise(
                x => x.ClipboardChanged += null,
                this,
                new ClipboardChangedEventArgs(
                    applicationName: "testApp",
                    clipboardContent: " testContent " + Environment.NewLine + " testContent2 ",
                    contentType: SharpClipboard.ContentTypes.Text));

            Assert.True(entries.Length == 2);
            Assert.Equal("testContent", entries[0]);
            Assert.Equal("testContent2", entries[1]);
        }
Example #2
0
        public void CorrectNumberOfEntriesIsPublished(string testText, bool multipleRows, int maxMultipleRows, int expectedEntriesCount)
        {
            var mockObjects          = MockFactories.GetMockObjects();
            var clipboardConfig      = Mock.Get((IClipboardConfiguration)mockObjects[nameof(IClipboardConfiguration)]);
            var sharpClipboardMapper = Mock.Get((ISharpClipboardMapper)mockObjects[nameof(ISharpClipboardMapper)]);
            var textCopyMapper       = Mock.Get((ITextCopyMapper)mockObjects[nameof(ITextCopyMapper)]);

            clipboardConfig.SetupGet(x => x.MaxProcessedRows).Returns(maxMultipleRows);
            clipboardConfig.SetupGet(x => x.ProcessMultipleRows).Returns(multipleRows);

            var clipboardManager = MockFactories.ClipboardManagerFactory(mockObjects);

            clipboardManager.AppName = "testApp2";
            var eventCorrectRaised = false;

            clipboardManager.ClipboardTextUpdateReceived += (s, e) =>
            {
                eventCorrectRaised = e.ClipboardEntries.Length == expectedEntriesCount;
            };

            sharpClipboardMapper.Raise(
                x => x.ClipboardChanged += null,
                this,
                new ClipboardChangedEventArgs(
                    applicationName: "testApp",
                    clipboardContent: testText,
                    contentType: SharpClipboard.ContentTypes.Text));

            Assert.True(eventCorrectRaised);
        }
        public void N_BookP32()
        {
            var mockObjects = MockFactories.GetMockObjects();
            var vm          = MockFactories.FinCalcViewModelWithCalculatorImplementationFactory(mockObjects);

            vm.DigitPressedCommand.Execute(5);
            vm.DecimalSeparatorPressedCommand.Execute(null);
            vm.DigitPressedCommand.Execute(5);
            vm.InterestPressedCommand.Execute(false);
            vm.DigitPressedCommand.Execute(1);
            vm.DigitPressedCommand.Execute(0);
            vm.DigitPressedCommand.Execute(0);
            vm.DigitPressedCommand.Execute(0);
            vm.DigitPressedCommand.Execute(0);
            vm.AlgebSignCommand.Execute(null);
            vm.StartPressedCommand.Execute(false);
            vm.DigitPressedCommand.Execute(5);
            vm.DigitPressedCommand.Execute(5);
            vm.DigitPressedCommand.Execute(0);
            vm.AlgebSignCommand.Execute(null);
            vm.RatePressedCommand.Execute(false);
            vm.DigitPressedCommand.Execute(1);
            vm.DigitPressedCommand.Execute(0);
            vm.DigitPressedCommand.Execute(0);
            vm.DigitPressedCommand.Execute(0);
            vm.DigitPressedCommand.Execute(0);
            vm.DigitPressedCommand.Execute(0);
            vm.DigitPressedCommand.Execute(0);
            vm.EndPressedCommand.Execute(false);
            vm.YearsPressedCommand.Execute(false);

            Assert.True(vm.DisplayText == "39,85");
            Assert.True(Math.Abs(vm.DisplayNumber - 39.85) < this.Tolerance);
            Assert.True(Math.Abs(vm.YearsNumber - 39.85) < this.Tolerance);
        }
        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 E_BookP17()
        {
            var mockObjects = MockFactories.GetMockObjects();
            var vm          = MockFactories.FinCalcViewModelWithCalculatorImplementationFactory(mockObjects);

            vm.DigitPressedCommand.Execute(2);
            vm.DigitPressedCommand.Execute(5);
            vm.YearsPressedCommand.Execute(false);
            vm.DigitPressedCommand.Execute(7);
            vm.InterestPressedCommand.Execute(false);
            vm.DigitPressedCommand.Execute(0);
            vm.StartPressedCommand.Execute(false);
            vm.DigitPressedCommand.Execute(2);
            vm.DigitPressedCommand.Execute(0);
            vm.DigitPressedCommand.Execute(0);
            vm.DigitPressedCommand.Execute(0);
            vm.DigitPressedCommand.Execute(0);
            vm.DigitPressedCommand.Execute(0);
            vm.EndPressedCommand.Execute(false);
            vm.RatePressedCommand.Execute(false);

            Assert.True(vm.DisplayText == "-255,41");
            Assert.True(Math.Abs(vm.DisplayNumber - -255.41) < this.Tolerance);
            Assert.True(Math.Abs(vm.RateNumber - -255.41) < this.Tolerance);
        }
        public void P_BookP21()
        {
            var mockObjects = MockFactories.GetMockObjects();
            var vm          = MockFactories.FinCalcViewModelWithCalculatorImplementationFactory(mockObjects);

            vm.DigitPressedCommand.Execute(1);
            vm.OperatorPressedCommand.Execute("*");
            vm.YearsPressedCommand.Execute(false);
            vm.DigitPressedCommand.Execute(2);
            vm.DigitPressedCommand.Execute(5);
            vm.YearsPressedCommand.Execute(false);
            vm.DigitPressedCommand.Execute(2);
            vm.DigitPressedCommand.Execute(5);
            vm.DigitPressedCommand.Execute(0);
            vm.DigitPressedCommand.Execute(0);
            vm.DigitPressedCommand.Execute(0);
            vm.DigitPressedCommand.Execute(0);
            vm.AlgebSignCommand.Execute(null);
            vm.StartPressedCommand.Execute(false);
            vm.DigitPressedCommand.Execute(1);
            vm.DigitPressedCommand.Execute(2);
            vm.DigitPressedCommand.Execute(0);
            vm.DigitPressedCommand.Execute(0);
            vm.DigitPressedCommand.Execute(0);
            vm.RatePressedCommand.Execute(false);
            vm.DigitPressedCommand.Execute(0);
            vm.EndPressedCommand.Execute(false);
            vm.InterestPressedCommand.Execute(false);

            Assert.True(vm.DisplayText == "1,455");
            Assert.True(Math.Abs(vm.DisplayNumber - 1.455) < this.Tolerance);
            Assert.True(Math.Abs(vm.InterestNumber - 1.455) < this.Tolerance);
            Assert.True(Math.Abs(vm.NominalInterestRateNumber - 1.455) < this.Tolerance);
        }
        public void Kn_Manual_LoanQuestion1()
        {
            var mockObjects = MockFactories.GetMockObjects();
            var vm          = MockFactories.FinCalcViewModelWithCalculatorImplementationFactory(mockObjects);

            vm.DigitPressedCommand.Execute(1);
            vm.DigitPressedCommand.Execute(2);
            vm.OperatorPressedCommand.Execute("*");
            vm.YearsPressedCommand.Execute(false);
            vm.DigitPressedCommand.Execute(1);
            vm.DigitPressedCommand.Execute(0);
            vm.YearsPressedCommand.Execute(false);
            vm.DigitPressedCommand.Execute(4);
            vm.OperatorPressedCommand.Execute("*");
            vm.InterestPressedCommand.Execute(false);
            vm.DigitPressedCommand.Execute(1);
            vm.DigitPressedCommand.Execute(5);
            vm.DigitPressedCommand.Execute(0);
            vm.DigitPressedCommand.Execute(0);
            vm.DigitPressedCommand.Execute(0);
            vm.DigitPressedCommand.Execute(0);
            vm.StartPressedCommand.Execute(false);
            vm.DigitPressedCommand.Execute(2);
            vm.OperatorPressedCommand.Execute("*");
            vm.RatePressedCommand.Execute(false);
            vm.EndPressedCommand.Execute(false);

            Assert.True(vm.DisplayText == "-113.187,55");
            Assert.True(Math.Abs(vm.DisplayNumber - -113187.5488186329) < this.Tolerance);
            Assert.True(Math.Abs(vm.EndNumber - -113187.5488186329) < this.Tolerance);
        }
        public void SortedListOfMatchesByKeyIsCreated()
        {
            var mockObjects = MockFactories.GetMockObjects();

            var vm = MockFactories.DeepLinkCollectionViewModelFactory(mockObjects);

            vm.Sideload(MockedDeeplinkMatches.OrderTestList, DeepLinkSortOrder.Key);

            var firstLevelOneItem = vm.HierarchicalLinks.First();
            var lastLevelOneItem  = vm.HierarchicalLinks.Last();

            Assert.Equal("Key1", firstLevelOneItem.Name);
            Assert.Equal("Cat1", firstLevelOneItem.SecondLinkHierarchies.First().Name);
            Assert.Equal("Cat2", firstLevelOneItem.SecondLinkHierarchies.Last().Name);
            Assert.Equal("Key3", lastLevelOneItem.Name);
            Assert.Equal("Cat1", lastLevelOneItem.SecondLinkHierarchies.First().Name);
            Assert.Equal("Cat2", lastLevelOneItem.SecondLinkHierarchies.Last().Name);

            vm.Sideload(MockedDeeplinkMatches.OrderTestList, DeepLinkSortOrder.Key, true);

            firstLevelOneItem = vm.HierarchicalLinks.First();
            lastLevelOneItem  = vm.HierarchicalLinks.Last();

            Assert.Equal("Key3", firstLevelOneItem.Name);
            Assert.Equal("Cat2", firstLevelOneItem.SecondLinkHierarchies.First().Name);
            Assert.Equal("Cat1", firstLevelOneItem.SecondLinkHierarchies.Last().Name);
            Assert.Equal("Key1", lastLevelOneItem.Name);
            Assert.Equal("Cat2", lastLevelOneItem.SecondLinkHierarchies.First().Name);
            Assert.Equal("Cat1", lastLevelOneItem.SecondLinkHierarchies.Last().Name);
        }
Example #9
0
        public void CalculateAndDisplayE_GivenAllNeededVariables(bool advance, double m, double n, double p, double k0, double kn, double expectedE)
        {
            // Arrange
            var mockObjects = MockFactories.GetMockObjects();
            var vm          = MockFactories.FinCalcViewModelWithCalculatorImplementationFactory(mockObjects);

            // Since I am sharing the test data with the plain calculation tests I have to manually adjust this value:
            expectedE *= -1;

            // Act
            if (advance)
            {
                FinCalcViewModelHelper.ExecuteDummyAction(vm, Ca.ToggleAdv);
            }

            FinCalcViewModelHelper.SetFinancialValue(vm, m, CommandWord.SetRatesPerAnnum);
            FinCalcViewModelHelper.SetFinancialValue(vm, n, CommandWord.SetYears);
            FinCalcViewModelHelper.SetFinancialValue(vm, p, CommandWord.SetNominalInterestRate);
            FinCalcViewModelHelper.SetFinancialValue(vm, k0, CommandWord.SetStart);
            FinCalcViewModelHelper.SetFinancialValue(vm, kn, CommandWord.SetEnd);
            vm.RatePressedCommand.Execute(false);

            // Assert
            vm.DisplayNumber.Should().BeApproximately(expectedE, this.Tolerance);
        }
Example #10
0
        public void ClipBoardUpdateEventsAreCorrectlyProcessed()
        {
            var mockObjects          = MockFactories.GetMockObjects();
            var clipboardConfig      = Mock.Get((IClipboardConfiguration)mockObjects[nameof(IClipboardConfiguration)]);
            var sharpClipboardMapper = Mock.Get((ISharpClipboardMapper)mockObjects[nameof(ISharpClipboardMapper)]);
            var textCopyMapper       = Mock.Get((ITextCopyMapper)mockObjects[nameof(ITextCopyMapper)]);

            var clipboardManager = MockFactories.ClipboardManagerFactory(mockObjects);

            string[] entries = new[] { string.Empty };
            clipboardManager.ClipboardTextUpdateReceived += (s, e) =>
            {
                entries = e.ClipboardEntries;
            };

            sharpClipboardMapper.Raise(
                x => x.ClipboardChanged += null,
                this,
                new ClipboardChangedEventArgs(
                    applicationName: "testApp",
                    clipboardContent: "testContent",
                    contentType: SharpClipboard.ContentTypes.Text));

            Assert.True(entries.Length == 1);
            Assert.Equal("testContent", entries[0]);
        }
Example #11
0
        public void WindowGetsMinimized()
        {
            var mockObjects = MockFactories.GetMockObjects();

            var vm = MockFactories.ShellViewModelFactory(mockObjects);

            vm.MinimizeAppCommand.Execute(null);

            Assert.Equal(WindowState.Minimized, vm.CurWindowState);
        }
Example #12
0
        public void VmIsSubscribedToEventAggregator()
        {
            var mockObjects         = MockFactories.GetMockObjects();
            var eventAggregatorMock = Mock.Get((IEventAggregator)mockObjects[nameof(IEventAggregator)]);

            var vm = MockFactories.ShellViewModelFactory(mockObjects);

            // Test to make sure subscribe was called on the event aggregator at least once
            eventAggregatorMock.Verify(x => x.Subscribe(vm), Times.Once);
        }
Example #13
0
        public void MenuItemChangesAreHandled()
        {
            var mockObjects = MockFactories.GetMockObjects();

            var vm = MockFactories.ShellViewModelFactory(mockObjects);

            vm.MenuItemsSelectionChangedCommand.Execute(null);

            Assert.False(vm.IsMenuBarVisible);
        }
Example #14
0
        public void TextIsCopiedToClipboard()
        {
            var mockObjects    = MockFactories.GetMockObjects();
            var textCopyMapper = Mock.Get((ITextCopyMapper)mockObjects[nameof(ITextCopyMapper)]);

            var clipboardManager = MockFactories.ClipboardManagerFactory(mockObjects);

            clipboardManager.CopyTextToClipboard("test");

            textCopyMapper.Verify(x => x.SetText(It.IsAny <string>()), Times.Once);
        }
        public void DefaultBrowserIsSelectedEvenWhenNoBrowserIsSetAsDefault()
        {
            var mockObjects   = MockFactories.GetMockObjects();
            var browserConfig = Mock.Get((IBrowserConfiguration)mockObjects[nameof(IBrowserConfiguration)]);

            browserConfig.SetupGet(x => x.BrowserDefinitions).Returns(MockedBrowserDefinitions.BrowserDefinitionsWithoutDefaultBrowser);

            var browserManager = MockFactories.BrowserManagerFactory(mockObjects);

            Assert.False(browserManager.DefaultBrowserDefinition.IsDefault);
            Assert.True(browserManager.DefaultBrowserDefinition.Name == "test");
        }
        public void ActivateSecondFunctionTrigger_WhenActiveOperatorIsAdd()
        {
            // Arrange
            var mockObjects = MockFactories.GetMockObjects();
            var vm          = MockFactories.FinCalcViewModelWithCalculatorImplementationFactory(mockObjects);

            // Act
            vm.OperatorPressedCommand.Execute("*");

            // Assert
            vm.SecondFunctionTrigger.Should().BeTrue();
        }
Example #17
0
        public void TitleBarDoubleClicksChangesWindowState()
        {
            var mockObjects = MockFactories.GetMockObjects();

            var vm = MockFactories.ShellViewModelFactory(mockObjects);

            var curState = vm.CurWindowState;

            vm.TitleBarDoubleClickedCommand.Execute(null);

            Assert.NotEqual(curState, vm.CurWindowState);
        }
Example #18
0
        public async Task ErrorEventsAreHandled()
        {
            var mockObjects = MockFactories.GetMockObjects();

            // var dialogHostMapper = Mock.Get((IDialogHostMapper)mockObjects[nameof(IDialogHostMapper)]);
            var snackbarMock = Mock.Get((ISnackbarMessageQueue)mockObjects[nameof(ISnackbarMessageQueue)]);
            var vm           = MockFactories.ShellViewModelFactory(mockObjects);

            await vm.Handle(new ErrorEvent(new Exception(), "test"));

            // dialogHostMapper.Verify(x => x.Show(It.IsAny<object>(), It.IsAny<object>()), Times.Once);
            snackbarMock.Verify(x => x.Enqueue(It.IsAny <object>(), It.IsAny <object>(), It.IsAny <Action <ErrorEvent> >(), It.IsAny <ErrorEvent>()), Times.Once);
        }
Example #19
0
        public void HotKeyIsRegistered()
        {
            var mockObjects   = MockFactories.GetMockObjects();
            var hotkeyManager = Mock.Get((INHotkeyManagerMapper)mockObjects[nameof(INHotkeyManagerMapper)]);

            hotkeyManager.Setup(x =>
                                x.AddOrReplace(It.IsAny <string>(), It.IsAny <Key>(), It.IsAny <ModifierKeys>()));

            var vm = MockFactories.ShellViewModelFactory(mockObjects);

            // Test to make sure subscribe was called on the event aggregator at least once
            hotkeyManager.Verify(x => x.AddOrReplace(It.IsAny <string>(), It.IsAny <Key>(), It.IsAny <ModifierKeys>()), Times.Once);
        }
        public void CopyingToClipboardIsHandled()
        {
            var mockObjects          = MockFactories.GetMockObjects();
            var clipboardManagerMock = Mock.Get((IClipboardManager)mockObjects[nameof(IClipboardManager)]);

            clipboardManagerMock.Setup(x => x.CopyTextToClipboard(It.IsAny <string>())).Verifiable();

            var vm = MockFactories.DeepLinkCollectionViewModelFactory(mockObjects);

            vm.CopyLinkToClipboardCommand.Execute("test");

            clipboardManagerMock.Verify(x => x.CopyTextToClipboard(It.IsAny <string>()), Times.Once);
        }
        public void TextboxUpdatesThatDoNotMatchAreProcessed()
        {
            var mockObjects = MockFactories.GetMockObjects();

            var deeplinkManagerMock = Mock.Get((IDeepLinkManager)mockObjects[nameof(IDeepLinkManager)]);

            deeplinkManagerMock.Setup(x => x.GetDeepLinkMatches(It.IsAny <string>())).Returns((List <DeepLinkMatch>)null);

            var vm = MockFactories.DeepLinkCollectionViewModelFactory(mockObjects);

            vm.ApplyInputCommand.Execute("test");

            Assert.Empty(vm.HierarchicalLinks);
        }
        public void UrlOpeningWithDefaultBrowserSucceeds()
        {
            var mockObjects   = MockFactories.GetMockObjects();
            var proxyMock     = Mock.Get((IProcessProxy)mockObjects[nameof(IProcessProxy)]);
            var browserConfig = Mock.Get((IBrowserConfiguration)mockObjects[nameof(IBrowserConfiguration)]);

            browserConfig.SetupGet(x => x.BrowserDefinitions).Returns(MockedBrowserDefinitions.BrowserDefinitions);

            var browserManager = MockFactories.BrowserManagerFactory(mockObjects);

            browserManager.OpenWithDefaultBrowser("test");

            proxyMock.Verify(x => x.StartProcess(It.IsAny <ProcessStartInfo>()));
        }
        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);
        }
Example #24
0
        public void WindowIsRestoredWhenHotKeyIsPressed()
        {
            var mockObjects   = MockFactories.GetMockObjects();
            var hotkeyManager = Mock.Get((INHotkeyManagerMapper)mockObjects[nameof(INHotkeyManagerMapper)]);

            hotkeyManager.Setup(x =>
                                x.AddOrReplace(It.IsAny <string>(), It.IsAny <Key>(), It.IsAny <ModifierKeys>()));

            var vm = MockFactories.ShellViewModelFactory(mockObjects);

            vm.CurWindowState = WindowState.Minimized;

            hotkeyManager.Raise(x => x.HotKeyPressed += null, this, new MappedHotKeyEventArgs("test"));

            Assert.Equal(WindowState.Normal, vm.CurWindowState);
        }
Example #25
0
        public void ErrorIsThrownIfHotkeyIsAlreadyRegistered()
        {
            var mockObjects         = MockFactories.GetMockObjects();
            var hotkeyManagerMock   = Mock.Get((INHotkeyManagerMapper)mockObjects[nameof(INHotkeyManagerMapper)]);
            var eventAggregatorMock = Mock.Get((IEventAggregator)mockObjects[nameof(IEventAggregator)]);

            hotkeyManagerMock.Setup(x =>
                                    x.AddOrReplace(It.IsAny <string>(), It.IsAny <Key>(), It.IsAny <ModifierKeys>()));

            var vm = MockFactories.ShellViewModelFactory(mockObjects);

            // Test to make sure subscribe was called on the event aggregator at least once
            hotkeyManagerMock.Raise(x => x.HotkeyAlreadyRegistered += null, this, new MappedHotkeyAlreadyRegisteredEventArgs("test"));

            eventAggregatorMock.Verify(x => x.Publish(It.IsAny <object>(), It.IsAny <System.Action <System.Action> >()), Times.Exactly(1));
        }
Example #26
0
        public void CalculateAndDisplayN_GivenAllNeededVariables(double m, double p, double k0, double e, double kn, double expectedN)
        {
            // Arrange
            var mockObjects = MockFactories.GetMockObjects();
            var vm          = MockFactories.FinCalcViewModelWithCalculatorImplementationFactory(mockObjects);

            // Act
            FinCalcViewModelHelper.SetFinancialValue(vm, m, CommandWord.SetRatesPerAnnum);
            FinCalcViewModelHelper.SetFinancialValue(vm, p, CommandWord.SetNominalInterestRate);
            FinCalcViewModelHelper.SetFinancialValue(vm, k0, CommandWord.SetStart);
            FinCalcViewModelHelper.SetFinancialValue(vm, e, CommandWord.SetRate);
            FinCalcViewModelHelper.SetFinancialValue(vm, kn, CommandWord.SetEnd);
            vm.YearsPressedCommand.Execute(false);

            // Assert
            vm.DisplayNumber.Should().BeApproximately(expectedN, this.Tolerance);
        }
        public void IncomingEventsAreHandled()
        {
            var mockObjects         = MockFactories.GetMockObjects();
            var eventAggregatorMock = Mock.Get((IEventAggregator)mockObjects[nameof(IEventAggregator)]);

            var vm = MockFactories.DeepLinkCollectionViewModelFactory(mockObjects);

            vm.Handle(new HistoricalDeepLinkSelectedEvent(
                          new List <DeepLinkMatch>()
            {
                MockedDeeplinkMatches.SimpleDeepLinkMatch,
            },
                          "test"));

            // Updates that come from the history part should not fire a vice versa update
            eventAggregatorMock.Verify(x => x.Publish(It.IsAny <object>(), It.IsAny <System.Action <System.Action> >()), Times.Exactly(0));
        }
        public void PercentageCalculationExamples()
        {
            var mockObjects = MockFactories.GetMockObjects();
            var vm          = MockFactories.FinCalcViewModelWithCalculatorImplementationFactory(mockObjects);

            // 200 * 5
            vm.DigitPressedCommand.Execute(2);
            vm.DigitPressedCommand.Execute(0);
            vm.DigitPressedCommand.Execute(0);
            vm.OperatorPressedCommand.Execute("*");
            vm.DigitPressedCommand.Execute(5);
            vm.EndPressedCommand.Execute(false);
            Assert.True(vm.DisplayText == "10,00");
            Assert.True(Math.Abs(vm.DisplayNumber - 10) < this.Tolerance);

            // 200 + 5
            vm.DigitPressedCommand.Execute(2);
            vm.DigitPressedCommand.Execute(0);
            vm.DigitPressedCommand.Execute(0);
            vm.OperatorPressedCommand.Execute("+");
            vm.DigitPressedCommand.Execute(5);
            vm.EndPressedCommand.Execute(false);
            Assert.True(vm.DisplayText == "210,00");
            Assert.True(Math.Abs(vm.DisplayNumber - 210) < this.Tolerance);

            // 200 - 5
            vm.DigitPressedCommand.Execute(2);
            vm.DigitPressedCommand.Execute(0);
            vm.DigitPressedCommand.Execute(0);
            vm.OperatorPressedCommand.Execute("-");
            vm.DigitPressedCommand.Execute(5);
            vm.EndPressedCommand.Execute(false);
            Assert.True(vm.DisplayText == "190,00");
            Assert.True(Math.Abs(vm.DisplayNumber - 190) < this.Tolerance);

            // 200 / 5 <-- not documented and not very useful
            vm.DigitPressedCommand.Execute(2);
            vm.DigitPressedCommand.Execute(0);
            vm.DigitPressedCommand.Execute(0);
            vm.OperatorPressedCommand.Execute("/");
            vm.DigitPressedCommand.Execute(5);
            vm.EndPressedCommand.Execute(false);
            Assert.True(vm.DisplayText == "4.000,00");
            Assert.True(Math.Abs(vm.DisplayNumber - 4000) < this.Tolerance);
        }
        public void ClipboardUpdatesThatDoNotMatchAreProcessed()
        {
            var mockObjects = MockFactories.GetMockObjects();

            var clipboardManagerMock = Mock.Get((IClipboardManager)mockObjects[nameof(IClipboardManager)]);
            var deeplinkManagerMock  = Mock.Get((IDeepLinkManager)mockObjects[nameof(IDeepLinkManager)]);
            var eventAggregatorMock  = Mock.Get((IEventAggregator)mockObjects[nameof(IEventAggregator)]);

            deeplinkManagerMock.Setup(x => x.GetDeepLinkMatches(It.IsAny <string>())).Returns((List <DeepLinkMatch>)null);
            eventAggregatorMock.Setup(x => x.Publish(It.IsAny <object>(), It.IsAny <System.Action <System.Action> >())).Verifiable();

            var vm = MockFactories.DeepLinkCollectionViewModelFactory(mockObjects);

            clipboardManagerMock.Raise(x => x.ClipboardTextUpdateReceived += null, this, new ClipboardTextUpdateEventArgs(new[] { "test" }));

            deeplinkManagerMock.Verify(x => x.GetDeepLinkMatches(It.IsAny <string>()), Times.Exactly(1));
            eventAggregatorMock.Verify(x => x.Publish(It.IsAny <object>(), It.IsAny <System.Action <System.Action> >()), Times.Exactly(0));
        }
        public void ChangingDeepLinkSortOrderIsHandled()
        {
            var mockObjects = MockFactories.GetMockObjects();

            var vm = MockFactories.DeepLinkCollectionViewModelFactory(mockObjects);

            vm.Sideload(MockedDeeplinkMatches.OrderTestList);

            var firstLevelOneItem = vm.HierarchicalLinks.First();

            Assert.Equal("Cat1", firstLevelOneItem.Name);

            vm.ChangeDeepLinkSortOrderDirectionCommand.Execute(null);

            firstLevelOneItem = vm.HierarchicalLinks.First();

            Assert.Equal("Key1", firstLevelOneItem.Name);
        }