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(); }
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)); }
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 void Should_return_an_error_notification_if_the_Statement_has_only_inactive_accounts() { var accounts = new List<Account> { new Account { Inactive = true } }; var statement = new Statement { Accounts = accounts }; var executionArguments = new ExecutionArguments { Statement = new Notification<Statement> { Item = statement } }; var result = new RequireActiveAccountsExist().Check(executionArguments); result.HasErrors.ShouldBeTrue(); Regex.IsMatch(result.Errors, RequireActiveAccountsExist.NoActiveAccountsMessageText.MessageTextToRegex()).ShouldBeTrue(); }
protected override void Before_first_test() { var validator = IoC.Get<IsTheIndexOfAnExistingAccount>(); var statement = new Statement(); statement.Accounts.Add(new Account { Name = "Alpha" }); var executionArguments = new ExecutionArguments { Args = new[] { AccountIndex.ToString() }, Statement = statement }; _result = validator.Check(executionArguments, 0); }
public Notification Save(Statement statement) { var settingsResult = _applicationSettingsService.Load(); if (settingsResult.HasErrors) { return settingsResult; } ApplicationSettings settings = settingsResult; var path = settings.StatementPath; if (path.IsNullOrEmpty()) { return Notification.ErrorFor(InitializationErrorMessageText, typeof(Statement).GetSingularUIDescription()); } var result = _serializationService.SerializeToFile(statement, path); if (result.HasErrors) { return Notification.ErrorFor(SerializationErrorMessageText, typeof(Statement).GetSingularUIDescription(), path, Environment.NewLine, result.Errors); } return result; }
protected override void Before_first_test() { var applicationSettingsService = IoC.Get<IApplicationSettingsService>(); ApplicationSettings applicationSettings = applicationSettingsService.Load(); applicationSettings.StatementPath = StatementPath; applicationSettingsService.Save(applicationSettings); var storageService = IoC.Get<IStorageService>(); var statement = new Statement(); _result = storageService.Save(statement); }
protected override void Before_first_test() { var validator = IoC.Get<IsTheNameOfAnExistingTaxReportingCategory>(); var statement = new Statement(); statement.TaxReportingCategories.Add(new TaxReportingCategory { Name = TaxReportingCategoryName }); var executionArguments = new ExecutionArguments { Args = new[] { TaxReportingCategoryName }, Statement = statement }; _result = validator.Check(executionArguments, 0); }
protected override void Before_first_test() { var validator = IoC.Get<IsTheNameOfAnExistingAccountType>(); var statement = new Statement(); statement.AccountTypes.Add(new AccountType { Name = AccountTypeName }); var executionArguments = new ExecutionArguments { Args = new[] { AccountTypeName }, Statement = statement }; _result = validator.Check(executionArguments, 0); }
public void Should_return_a_success_notification_if_the_Statement_has_at_least_one_active_account() { var accounts = new List<Account> { new Account { Inactive = false } }; var statement = new Statement { Accounts = accounts }; var executionArguments = new ExecutionArguments { Statement = Notification.Empty.ToNotification(statement) }; var result = new RequireActiveAccountsExist().Check(executionArguments); result.IsValid.ShouldBeTrue(); }