Exemplo n.º 1
0
        public Notification Execute(ExecutionArguments executionArguments)
        {
            ApplicationSettings applicationSettings = executionArguments.ApplicationSettings;

            _systemService.StandardOut.WriteLine(GetLabelFor(x => x.StatementPath) + ":\t" + applicationSettings.StatementPath);
            return(Notification.Empty);
        }
Exemplo n.º 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;
 }
Exemplo n.º 3
0
        public Notification Execute(ExecutionArguments executionArguments)
        {
            Statement statement = executionArguments.Statement;

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

            return Notification.InfoFor(SuccessMessageText);
        }
Exemplo n.º 4
0
        public Notification Execute(ExecutionArguments executionArguments)
        {
            Statement statement = executionArguments.Statement;

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

            return(Notification.InfoFor(SuccessMessageText));
        }
Exemplo n.º 5
0
        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);
 }
Exemplo n.º 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();
 }
Exemplo n.º 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());
        }
Exemplo n.º 14
0
        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));
        }
Exemplo n.º 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);
 }
Exemplo n.º 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;
        }
Exemplo n.º 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;
        }
Exemplo n.º 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);
        }
Exemplo n.º 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();
 }
Exemplo n.º 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()));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
 }
Exemplo n.º 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()));
        }
Exemplo n.º 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);
                }
Exemplo n.º 38
0
                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);
                }
Exemplo n.º 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);
 }