コード例 #1
0
        public void Budget1ShouldBeEffectiveUntilBudget2EffectiveDate()
        {
            BudgetCurrencyContext subject = CreateSubject1();

            Assert.IsTrue(subject.BudgetArchived);
            Assert.AreEqual(new DateTime(2014, 01, 20), subject.EffectiveUntil);
        }
コード例 #2
0
        private static BudgetCurrencyContext CreateSubject1()
        {
            BudgetModel budget1 = BudgetModelTestData.CreateTestData1();
            var         subject = new BudgetCurrencyContext(new BudgetCollection(new[] { budget1, BudgetModelTestData.CreateTestData2() }), budget1);

            return(subject);
        }
コード例 #3
0
        public void Budget2ShouldBeCurrentAfterConstruction()
        {
            BudgetCurrencyContext subject = CreateSubject2();

            Assert.IsTrue(subject.BudgetActive);
            Assert.IsFalse(subject.BudgetArchived);
            Assert.IsFalse(subject.BudgetInFuture);
        }
コード例 #4
0
 private void OnClosedNotificationReceived(object sender, EventArgs eventArgs)
 {
     CurrentBudget = new BudgetCurrencyContext(this.maintenanceService.Budgets, this.maintenanceService.Budgets.CurrentActiveBudget);
     Budgets       = CurrentBudget.BudgetCollection;
     BudgetBucketBindingSource.BucketRepository = this.maintenanceService.BudgetBucketRepository;
     RaisePropertyChanged(() => TruncatedFileName);
     MessengerInstance.Send(new BudgetReadyMessage(CurrentBudget, Budgets));
 }
コード例 #5
0
 private void SyncDataFromBudgetService()
 {
     Budgets       = this.maintenanceService.Budgets;
     CurrentBudget = new BudgetCurrencyContext(Budgets, Budgets.CurrentActiveBudget);
     BudgetBucketBindingSource.BucketRepository = this.maintenanceService.BudgetBucketRepository;
     RaisePropertyChanged(() => TruncatedFileName);
     if (CurrentBudget != null)
     {
         MessengerInstance.Send(new BudgetReadyMessage(CurrentBudget, Budgets));
     }
 }
コード例 #6
0
        public void ShouldIndicateFutureBudgetWhenOneIsGiven()
        {
            var budget3 = new BudgetModel {
                EffectiveFrom = new DateTime(2020, 01, 30)
            };
            var subject = new BudgetCurrencyContext(
                new BudgetCollection(
                    new[]
            {
                BudgetModelTestData.CreateTestData1(),
                BudgetModelTestData.CreateTestData2(),
                budget3
            }),
                budget3
                );

            Assert.IsFalse(subject.BudgetActive);
            Assert.IsFalse(subject.BudgetArchived);
            Assert.IsTrue(subject.BudgetInFuture);
        }
コード例 #7
0
        public BudgetController(
            [NotNull] UiContext uiContext,
            [NotNull] IBudgetMaintenanceService maintenanceService,
            [NotNull] IApplicationDatabaseService applicationDatabaseService)
        {
            if (uiContext == null)
            {
                throw new ArgumentNullException(nameof(uiContext));
            }

            if (maintenanceService == null)
            {
                throw new ArgumentNullException(nameof(maintenanceService));
            }

            if (applicationDatabaseService == null)
            {
                throw new ArgumentNullException(nameof(applicationDatabaseService));
            }

            this.maintenanceService         = maintenanceService;
            this.applicationDatabaseService = applicationDatabaseService;
            this.questionBox           = uiContext.UserPrompts.YesNoBox;
            this.messageBox            = uiContext.UserPrompts.MessageBox;
            this.inputBox              = uiContext.UserPrompts.InputBox;
            BudgetPieController        = uiContext.BudgetPieController;
            NewBudgetController        = uiContext.NewBudgetModelController;
            NewBudgetController.Ready += OnAddNewBudgetReady;
            Shown = false;

            MessengerInstance = uiContext.Messenger;
            MessengerInstance.Register <ShellDialogResponseMessage>(this, OnPopUpResponseReceived);
            this.maintenanceService.Closed += OnClosedNotificationReceived;
            this.maintenanceService.NewDataSourceAvailable += OnNewDataSourceAvailableNotificationReceived;
            this.maintenanceService.Saving     += OnSavingNotificationReceived;
            this.maintenanceService.Validating += OnValidatingNotificationReceived;
            this.maintenanceService.Saved      += OnSavedNotificationReceived;

            CurrentBudget = new BudgetCurrencyContext(this.maintenanceService.Budgets, this.maintenanceService.Budgets.CurrentActiveBudget);
        }
コード例 #8
0
        public void ModelShouldNotBeNullAfterConstruction()
        {
            BudgetCurrencyContext subject = CreateSubject1();

            Assert.IsNotNull(subject.Model);
        }
コード例 #9
0
 private void ShowOtherBudget(BudgetModel budgetToShow)
 {
     CurrentBudget = new BudgetCurrencyContext(Budgets, budgetToShow);
     Shown         = true;
     Dirty         = false; // Need to reset this because events fire needlessly (in this case) as a result of setting the CurrentBudget.
 }