示例#1
0
        public Notification Execute(ExecutionArguments executionArguments)
        {
            ApplicationSettings applicationSettings = executionArguments.ApplicationSettings;

            _systemService.StandardOut.WriteLine(GetLabelFor(x => x.StatementPath) + ":\t" + applicationSettings.StatementPath);
            return(Notification.Empty);
        }
示例#2
0
 public Notification Handle(ICommand command, ExecutionArguments executionArguments)
 {
     var prerequisiteResult = _prerequisiteChecker.Check(command, executionArguments);
     if (prerequisiteResult.HasErrors)
     {
         return prerequisiteResult;
     }
     var commandResult = command.Execute(executionArguments);
     if (commandResult.HasErrors)
     {
         return commandResult;
     }
     if (command.ChangesTheStatement())
     {
         var commandHistory = new CommandHistory
             {
                 Command = command.GetType().Name,
                 Args = executionArguments.Args,
                 Date = _systemService.CurrentDateTime
             };
         Statement statement = executionArguments.Statement;
         statement.CommandHistory.Add(commandHistory);
     }
     return commandResult;
 }
示例#3
0
        public Notification Execute(ExecutionArguments executionArguments)
        {
            Statement statement = executionArguments.Statement;

            statement.SelectedAccount.Name = executionArguments.Args[0];

            return Notification.InfoFor(SuccessMessageText);
        }
示例#4
0
        public Notification Execute(ExecutionArguments executionArguments)
        {
            Statement statement = executionArguments.Statement;

            statement.SelectedAccount.Name = executionArguments.Args[0];

            return(Notification.InfoFor(SuccessMessageText));
        }
        public Notification Execute(ExecutionArguments executionArguments)
        {
            Statement statement = executionArguments.Statement;

            var account = statement.Accounts.GetByPropertyValueOrIndex(x => x.Name, executionArguments.Args[0]);
            account.Name = executionArguments.Args[1];

            return Notification.InfoFor(SuccessMessageText);
        }
 public void Should_return_a_success_notification_if_the_Statement_result_does_not_have_errors()
 {
     var executionArguments = new ExecutionArguments
         {
             Statement = Notification.Empty.ToNotification<Statement>()
         };
     var result = new RequireStatement().Check(executionArguments);
     result.IsValid.ShouldBeTrue();
 }
 public void Before_first_test()
 {
     var executionArguments = new ExecutionArguments
         {
             Args = new[] { "a", "b", "c" }
         };
     _result = new PrerequisiteChecker()
         .Check(new CommandWithMultiplePrerequisites(), executionArguments);
 }
 public void Before_first_test()
 {
     var executionArguments = new ExecutionArguments
         {
             Args = new string[] { }
         };
     _result = new RequireExactlyNArgs(1, TooFewArgumentsCustomMessageText)
         .Check(executionArguments);
 }
示例#9
0
        public Notification Execute(ExecutionArguments executionArguments)
        {
            Statement statement = executionArguments.Statement;

            var account = statement.Accounts.GetByPropertyValueOrIndex(x => x.Name, executionArguments.Args[0]);
            statement.SelectedAccount = account;

            return Notification.InfoFor(SuccessMessageText, typeof(Account).GetSingularUIDescription());
        }
 public void Before_first_test()
 {
     var executionArguments = new ExecutionArguments
         {
             Args = new[] { "a", "b" }
         };
     _result = new RequireAtMostNArgs(1, TooManyArgumentsCustomMessageText)
         .Check(executionArguments);
 }
 public void Should_return_an_error_notification_if_the_Statement_result_has_errors()
 {
     var executionArguments = new ExecutionArguments
         {
             Statement = Notification.ErrorFor("pretend").ToNotification<Statement>()
         };
     var result = new RequireStatement().Check(executionArguments);
     result.IsValid.ShouldBeFalse();
 }
示例#12
0
 protected override void Before_first_test()
 {
     var executionArguments = new ExecutionArguments
         {
             Args = new[] { FilePath },
         };
     var validator = IoC.Get<IsAFilePath>();
     _result = validator.Check(executionArguments, 0);
 }
        public Notification Execute(ExecutionArguments executionArguments)
        {
            Statement statement = executionArguments.Statement;

            var accountType = statement.AccountTypes.GetByPropertyValueOrIndex(x => x.Name, executionArguments.Args[0]);
            accountType.Taxability = TaxabilityType.GetFor(executionArguments.Args[1]);

            return Notification.InfoFor(SuccessMessageText, typeof(TaxabilityType).GetSingularUIDescription());
        }
        public Notification Execute(ExecutionArguments executionArguments)
        {
            Statement statement = executionArguments.Statement;

            var account = statement.Accounts.GetByPropertyValueOrIndex(x => x.Name, executionArguments.Args[0]);

            account.Name = executionArguments.Args[1];

            return(Notification.InfoFor(SuccessMessageText));
        }
示例#15
0
        public Notification Execute(ExecutionArguments executionArguments)
        {
            Statement statement = executionArguments.Statement;

            var account = statement.Accounts.GetByPropertyValueOrIndex(x => x.Name, executionArguments.Args[0]);

            statement.SelectedAccount = account;

            return(Notification.InfoFor(SuccessMessageText, typeof(Account).GetSingularUIDescription()));
        }
        public Notification Execute(ExecutionArguments executionArguments)
        {
            Statement statement = executionArguments.Statement;

            var accountType = statement.AccountTypes.GetByPropertyValueOrIndex(x => x.Name, executionArguments.Args[0]);

            accountType.Taxability = TaxabilityType.GetFor(executionArguments.Args[1]);

            return(Notification.InfoFor(SuccessMessageText, typeof(TaxabilityType).GetSingularUIDescription()));
        }
 protected override void Before_first_test()
 {
     var validator = IoC.Get<IsTheIndexOfAnExistingAccount>();
     var executionArguments = new ExecutionArguments
         {
             Args = new[] { AccountIndex.ToString() },
             Statement = new Statement()
         };
     _result = validator.Check(executionArguments, 0);
 }
 protected override void Before_first_test()
 {
     var command = IoC.Get<IsTheNameOfAnExistingAccount>();
     var executionArguments = new ExecutionArguments
         {
             Args = new[] { AccountName },
             Statement = new Statement()
         };
     _result = command.Check(executionArguments, 0);
 }
 public void Before_first_test()
 {
     var executionArguments = new ExecutionArguments
         {
             Args = new[] { "a" },
             ApplicationSettings = new Notification<ApplicationSettings>()
         };
     _result = new PrerequisiteChecker()
         .Check(new CommandWithMultiplePrerequisites(), executionArguments);
 }
示例#20
0
        public Notification Execute(ExecutionArguments executionArguments)
        {
            Statement statement = executionArguments.Statement;
            foreach (var indexed in statement.Accounts.Where(x => !x.Inactive).GetIndexedValues())
            {
                _systemService.StandardOut.WriteLine(indexed.ToString(x => x.Name));
            }

            return Notification.Empty;
        }
示例#21
0
        public Notification Execute(ExecutionArguments executionArguments)
        {
            Statement statement = executionArguments.Statement;

            foreach (var indexed in statement.AccountTypes.GetIndexedValues())
            {
                _systemService.StandardOut.WriteLine(indexed.ToString(x => x.Name));
            }

            return(Notification.Empty);
        }
        public Notification Execute(ExecutionArguments executionArguments)
        {
            Statement statement = executionArguments.Statement;

            foreach (var indexed in statement.TaxReportingCategories.GetIndexedValues())
            {
                _systemService.StandardOut.WriteLine(indexed.ToString(x => x.Name));
            }

            return Notification.Empty;
        }
示例#23
0
        public Notification Execute(ExecutionArguments executionArguments)
        {
            Statement statement = executionArguments.Statement;

            var accountType = statement.AccountTypes.GetIndexedValues()
                              .First(x => x.Item.Name == executionArguments.Args[0] || x.Index.ToString() == executionArguments.Args[0]).Item;

            _systemService.StandardOut.WriteLine(GetLabelFor(x => x.Name) + ":\t" + accountType.Name);
            _systemService.StandardOut.WriteLine(GetLabelFor(x => x.Taxability) + ":\t" + accountType.Taxability.Label);

            return(Notification.Empty);
        }
示例#24
0
        public Notification Execute(ExecutionArguments executionArguments)
        {
            var accountType = new AccountType
                {
                    Name = executionArguments.Args[0],
                    Taxability = TaxabilityType.GetFor(executionArguments.Args[1])
                };

            Statement statement = executionArguments.Statement;
            statement.AccountTypes.Add(accountType);

            return Notification.InfoFor(SuccessMessageText, typeof(AccountType).GetSingularUIDescription());
        }
 public void Should_return_an_error_notification_if_the_Statement_has_no_accounts()
 {
     var executionArguments = new ExecutionArguments
         {
             Statement = new Notification<Statement>
                 {
                     Item = new Statement()
                 }
         };
     var result = new RequireActiveAccountsExist().Check(executionArguments);
     result.HasErrors.ShouldBeTrue();
     Regex.IsMatch(result.Errors, RequireActiveAccountsExist.NoActiveAccountsMessageText.MessageTextToRegex()).ShouldBeTrue();
 }
 public void Should_return_an_error_notification_if_the_Statement_has_no_tax_reporting_categories()
 {
     var executionArguments = new ExecutionArguments
         {
             Statement = new Notification<Statement>
                 {
                     Item = new Statement()
                 }
         };
     var result = new RequireTaxReportingCategoriesExist().Check(executionArguments);
     result.HasErrors.ShouldBeTrue();
     Regex.IsMatch(result.Errors, RequireTaxReportingCategoriesExist.NoTaxReportingCategoriesMessageText.MessageTextToRegex()).ShouldBeTrue();
 }
 public void Should_return_a_success_notification_if_the_Statement_has_a_selected_account()
 {
     var statement = new Statement
         {
             SelectedAccount = new Account()
         };
     var executionArguments = new ExecutionArguments
         {
             Statement = statement
         };
     var result = new RequireSelectedAccount().Check(executionArguments);
     result.IsValid.ShouldBeTrue();
 }
示例#28
0
        public Notification Execute(ExecutionArguments executionArguments)
        {
            var category = new TaxReportingCategory
            {
                Name = executionArguments.Args[0],
            };

            Statement statement = executionArguments.Statement;

            statement.TaxReportingCategories.Add(category);

            return(Notification.InfoFor(SuccessMessageText, typeof(TaxReportingCategory).GetSingularUIDescription()));
        }
示例#29
0
        public Notification Execute(ExecutionArguments executionArguments)
        {
            ApplicationSettings applicationSettings = executionArguments.ApplicationSettings;

            applicationSettings.StatementPath = executionArguments.Args.Last().ToStatementPath();
            var statement = new Statement();

            AddDefaultAccountTypes(statement);
            AddDefaultTaxReportingCategories(statement);
            AddDefaultTransactionTypes(statement);
            executionArguments.Statement = statement;

            return(Notification.InfoFor(SuccessMessageText, typeof(Statement).GetSingularUIDescription(), applicationSettings.StatementPath));
        }
示例#30
0
        public Notification Execute(ExecutionArguments executionArguments)
        {
            var accountType = new AccountType
            {
                Name       = executionArguments.Args[0],
                Taxability = TaxabilityType.GetFor(executionArguments.Args[1])
            };

            Statement statement = executionArguments.Statement;

            statement.AccountTypes.Add(accountType);

            return(Notification.InfoFor(SuccessMessageText, typeof(AccountType).GetSingularUIDescription()));
        }
 public void Should_return_an_error_notification_if_the_Statement_result_has_errors()
 {
     var statement = new Statement
         {
             SelectedAccount = null
         };
     var executionArguments = new ExecutionArguments
         {
             Statement = statement
         };
     var result = new RequireSelectedAccount().Check(executionArguments);
     result.IsValid.ShouldBeFalse();
     result.Errors.ShouldContain(RequireSelectedAccount.AccountNeedsToBeSelected.ReplaceTypeReferencesWithUIDescriptions(false));
 }
示例#32
0
        public Notification Execute(ExecutionArguments executionArguments)
        {
            Statement statement = executionArguments.Statement;

            var accountType = statement.AccountTypes.GetByPropertyValueOrIndex(x => x.Name, executionArguments.Args[1]);

            var account = new Account
            {
                Name        = executionArguments.Args[0],
                AccountType = accountType,
            };

            statement.Accounts.Add(account);

            return(Notification.InfoFor(SuccessMessageText, typeof(Account).GetSingularUIDescription()));
        }
示例#33
0
        public Notification Execute(ExecutionArguments executionArguments)
        {
            Statement statement = executionArguments.Statement;

            var accountType = statement.AccountTypes.GetByPropertyValueOrIndex(x => x.Name, executionArguments.Args[1]);

            var account = new Account
                {
                    Name = executionArguments.Args[0],
                    AccountType = accountType,
                };

            statement.Accounts.Add(account);

            return Notification.InfoFor(SuccessMessageText, typeof(Account).GetSingularUIDescription());
        }
 public void Should_return_a_success_notification_if_the_Statement_has_at_least_one_tax_reporting_category()
 {
     var taxReportingCategories = new List<TaxReportingCategory>
         {
             new TaxReportingCategory()
         };
     var statement = new Statement
         {
             TaxReportingCategories = taxReportingCategories
         };
     var executionArguments = new ExecutionArguments
         {
             Statement = Notification.Empty.ToNotification(statement)
         };
     var result = new RequireTaxReportingCategoriesExist().Check(executionArguments);
     result.IsValid.ShouldBeTrue();
 }
 public Notification Execute(ExecutionArguments executionArguments)
 {
     throw new NotImplementedException();
 }
 protected override void Before_first_test()
 {
     var validator = IoC.Get<IsTheNameOfAnExistingAccount>();
     var statement = new Statement();
     statement.Accounts.Add(new Account
         {
             Name = AccountName
         });
     var executionArguments = new ExecutionArguments
         {
             Args = new[] { AccountName },
             Statement = statement
         };
     _result = validator.Check(executionArguments, 0);
 }
                protected override void Before_first_test()
                {
                    _expectedAccountType = Init.GetDefaultAccountTypes().Last();
                    _executionArguments = Subcutaneous.FromCommandline()
                        .Init(@"x:\previous.statement")
                        .AddAccount("Alpha", Init.GetDefaultAccountTypes().First().Name)
                        .ClearOutput()
                        .CreateExecutionArguments("Alpha", _expectedAccountType.Name);

                    var command = IoC.Get<ChangeAccountType>();
                    _result = command.Execute(_executionArguments);
                }
                protected override void Before_first_test()
                {
                    _executionArguments = Subcutaneous.FromCommandline()
                        .Init(@"x:\previous.statement")
                        .ClearOutput()
                        .CreateExecutionArguments(ExpectedAccountName, _expectedTaxabilityType.Key);

                    var command = IoC.Get<AddAccountType>();
                    _result = command.Execute(_executionArguments);
                }
示例#39
0
 public Notification Execute(ExecutionArguments executionArguments)
 {
     ApplicationSettings applicationSettings = executionArguments.ApplicationSettings;
     _systemService.StandardOut.WriteLine(GetLabelFor(x => x.StatementPath) + ":\t" + applicationSettings.StatementPath);
     return Notification.Empty;
 }
 public Notification Check(ExecutionArguments executionArguments, int argumentIndex)
 {
     return Notification.Empty;
 }
 public Notification Execute(ExecutionArguments executionArguments)
 {
     return Notification.InfoFor(CommandWasExecutedMessageText);
 }