コード例 #1
0
        public void OnInitialize_NoAccountAvailable_NoAccountSelected()
        {
            var sut = new CloseYearViewModel(new AccountingDataJournal());

            ((IActivate)sut).Activate();

            sut.RemoteAccount.Should().BeNull();
        }
コード例 #2
0
        public void CloseYearCommand_AccountSelected_CanExecute()
        {
            var sut = new CloseYearViewModel(new AccountingDataJournal());

            sut.RemoteAccount = new AccountDefinition();

            sut.CloseYearCommand.CanExecute(null).Should().BeTrue();
        }
コード例 #3
0
        public void OnInitialize_AccountsAvailable_AccountSelected()
        {
            var sut = new CloseYearViewModel(new AccountingDataJournal());

            sut.Accounts.Add(new AccountDefinition {
                ID = 1, Name = "CF", Type = AccountDefinitionType.Carryforward
            });

            ((IActivate)sut).Activate();

            sut.RemoteAccount.Should().Be(sut.Accounts.Single());
        }
コード例 #4
0
        public void CloseYear_NonDefaultConfiguration_SettingsRestored()
        {
            var windowManager = Substitute.For <IWindowManager>();
            var dialogs       = Substitute.For <IDialogs>();
            var fileSystem    = Substitute.For <IFileSystem>();
            var processApi    = Substitute.For <IProcess>();
            var settings      = new Settings();
            var sut           = new ProjectData(settings, windowManager, dialogs, fileSystem, processApi);

            sut.Load(Samples.SampleProject);
            sut.Storage.Accounts.Last().Account.Add(
                new AccountDefinition {
                ID = 99999, Name = "C2", Type = AccountDefinitionType.Carryforward
            });
            sut.Storage.Setup.Behavior.LastCarryForward          = 99999;
            sut.Storage.Setup.Behavior.LastCarryForwardSpecified = true;
            sut.Storage.Setup.Behavior.OpeningTextPattern        = OpeningTextOption.AccountName.ToString();
            CloseYearViewModel invokedViewModel = null;

            windowManager
            .ShowDialog(Arg.Any <CloseYearViewModel>(), Arg.Any <object>(), Arg.Any <IDictionary <string, object> >())
            .Returns(
                info =>
            {
                invokedViewModel = info.Arg <CloseYearViewModel>();
                return(false);
            });

            sut.CloseYear().Should().BeFalse();

            invokedViewModel.Should().BeEquivalentTo(
                new
            {
                TextOption = new { Option = OpeningTextOption.AccountName }, RemoteAccount = new { ID = 99999 }
            });
        }
コード例 #5
0
        public void CloseYearCommand_NoAccountSelected_CannotExecute()
        {
            var sut = new CloseYearViewModel(new AccountingDataJournal());

            sut.CloseYearCommand.CanExecute(null).Should().BeFalse();
        }