Example #1
0
        public async Task ViewAppearing_DialogShown()
        {
            // Arrange
            dialogService.Setup(x => x.ShowLoadingDialog(It.IsAny <string>()));
            dialogService.Setup(x => x.HideLoadingDialog());

            crudService.Setup(x => x.ReadManyNoTracked <AccountViewModel>())
            .Returns(new List <AccountViewModel>()
                     .AsQueryable()
                     .BuildMock()
                     .Object);
            crudService.Setup(x => x.ReadSingleAsync <AccountViewModel>(It.IsAny <int>()))
            .ReturnsAsync(new AccountViewModel());

            var vm = new PaymentListViewModel(crudService.Object,
                                              paymentService.Object,
                                              dialogService.Object,
                                              settingsFacade.Object,
                                              balanceCalculatorService.Object,
                                              backupService.Object,
                                              navigationService.Object,
                                              messenger.Object,
                                              logProvider.Object);

            await vm.Initialize();

            // Act
            vm.ViewAppearing();

            // Assert
            dialogService.Verify(x => x.ShowLoadingDialog(It.IsAny <string>()), Times.Once);
        }
Example #2
0
        public async Task Init_PassAccountId_AccountIdSet()
        {
            // Arrange
            crudService.Setup(x => x.ReadSingleAsync <AccountViewModel>(It.IsAny <int>()))
            .ReturnsAsync(new AccountViewModel());

            balanceCalculatorService.Setup(x => x.GetEndOfMonthBalanceForAccount(It.IsAny <AccountViewModel>()))
            .Returns(0);

            var vm = new PaymentListViewModel(crudService.Object,
                                              paymentService.Object,
                                              dialogService.Object,
                                              settingsFacade.Object,
                                              balanceCalculatorService.Object,
                                              backupService.Object,
                                              navigationService.Object,
                                              messenger.Object,
                                              logProvider.Object);

            // Act
            vm.Prepare(new PaymentListParameter(42));
            await vm.Initialize();

            // Assert
            Assert.Equal(42, vm.AccountId);
        }
Example #3
0
        public async void Init_NullPassAccountId_AccountIdSet()
        {
            // Arrange
            accountService.Setup(x => x.GetById(It.IsAny <int>()))
            .ReturnsAsync(new Account());
            balanceCalculatorManager.Setup(x => x.GetEndOfMonthBalanceForAccount(It.IsAny <Account>()))
            .ReturnsAsync(0);

            var vm = new PaymentListViewModel(accountService.Object,
                                              paymentService.Object,
                                              dialogService.Object,
                                              settingsManager.Object,
                                              balanceCalculatorManager.Object,
                                              backupManager.Object,
                                              navigationService.Object,
                                              messenger.Object,
                                              logProvider.Object);

            // Act
            vm.Prepare(new PaymentListParameter());
            await vm.Initialize();

            // Assert
            Assert.Equal(0, vm.AccountId);
        }