diff --git a/.idea/.idea.resume builder/.idea/dataSources.xml b/.idea/.idea.resume builder/.idea/dataSources.xml index f74b2b9..733ee45 100644 --- a/.idea/.idea.resume builder/.idea/dataSources.xml +++ b/.idea/.idea.resume builder/.idea/dataSources.xml @@ -1,45 +1,12 @@ - + sqlite.xerial true org.sqlite.JDBC - jdbc:sqlite:$PROJECT_DIR$/resume builder/bin/Debug/net7.0/resume.sqlite + jdbc:sqlite:$USER_HOME$/AppData/Local/resume.db $ProjectFileDir$ - - sqlite.xerial - true - org.sqlite.JDBC - jdbc:sqlite:$PROJECT_DIR$/resume builder/bin/Debug/net7.0/backup_resume.sqlite - $ProjectFileDir$ - - - sqlite.xerial - true - org.sqlite.JDBC - jdbc:sqlite:$PROJECT_DIR$/TestResumeBuilder/bin/Debug/net7.0/backup_resume.sqlite - $ProjectFileDir$ - - - sqlite.xerial - true - org.sqlite.JDBC - jdbc:sqlite:$PROJECT_DIR$/TestResumeBuilder/bin/Debug/net7.0/resume.sqlite - $ProjectFileDir$ - - - sqlite.xerial - true - org.sqlite.JDBC - jdbc:sqlite:D:\Skyfiles\Dropbox\projects\resume builder\template.sqlite - $ProjectFileDir$ - - - file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.43.0/sqlite-jdbc-3.43.0.0.jar - - - \ No newline at end of file diff --git a/TestResumeBuilder/AppTest.cs b/TestResumeBuilder/AppTest.cs index c46c9e0..39cc972 100644 --- a/TestResumeBuilder/AppTest.cs +++ b/TestResumeBuilder/AppTest.cs @@ -3,23 +3,26 @@ namespace TestResumeBuilder { - //todo: find way to pass text to test command app for prompts - public abstract class AppTest - { - internal CommandAppTester TestApp; + //todo: find way to pass text to test command app for prompts + public abstract class AppTest + { + internal CommandAppTester TestApp; - [SetUp] - public virtual void InitializeApp() - { - TestApp = new CommandAppTester(); - TestApp.Configure(Program.AppConfiguration); - } + [SetUp] + public virtual void InitializeApp() + { + TestApp = new CommandAppTester(); + TestApp.Configure(Program.AppConfiguration); + } - protected CommandAppResult Run(IEnumerable cmdArgs, params string[] args) => - TestApp.Run(cmdArgs.Concat(args).ToArray()); + protected CommandAppResult Run(IEnumerable cmdArgs, params string[] args) => + TestApp.Run(cmdArgs.Concat(args).ToArray()); - protected CommandAppFailure RunAndCatch(IEnumerable cmdArgs, params string[] args) - where T : Exception => TestApp.RunAndCatch(cmdArgs.Concat(args).ToArray()); - } + protected CommandAppResult Run(string cmd, params string[] args) => + Run(args.Prepend(cmd)); + + protected CommandAppFailure RunAndCatch(IEnumerable cmdArgs, params string[] args) + where T : Exception => TestApp.RunAndCatch(cmdArgs.Concat(args).ToArray()); + } } \ No newline at end of file diff --git a/TestResumeBuilder/TestData.cs b/TestResumeBuilder/TestData.cs new file mode 100644 index 0000000..c524f2e --- /dev/null +++ b/TestResumeBuilder/TestData.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Bogus; + +namespace TestResumeBuilder; +internal class TestData +{ + public static IEnumerable RandomArgs() { + yield return new Faker().Random.WordsArray(1, 20).ToArray(); + yield return new Faker().Random.WordsArray(1, 20).ToArray(); + yield return new Faker().Random.WordsArray(1, 20).ToArray(); +} + public static string r => ""; +} diff --git a/TestResumeBuilder/TestResumeBuilder.csproj b/TestResumeBuilder/TestResumeBuilder.csproj index f18fc38..c8dc135 100644 --- a/TestResumeBuilder/TestResumeBuilder.csproj +++ b/TestResumeBuilder/TestResumeBuilder.csproj @@ -1,25 +1,35 @@ - + - - net8.0 - enable - enable + + net8.0 + enable + enable - false - true - + false + true + - - - - - - - - + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + - - - + + + diff --git a/TestResumeBuilder/commands/InitTest.cs b/TestResumeBuilder/commands/InitTest.cs new file mode 100644 index 0000000..33dc878 --- /dev/null +++ b/TestResumeBuilder/commands/InitTest.cs @@ -0,0 +1,20 @@ +namespace TestResumeBuilder.commands; + +[TestFixture] +public class InitTest : AppTest +{ + [Test] + public void Init_WithNoArgs_ShouldReturnSuccess() + { + var result = TestApp.Run("init"); + Assert.That(result.ExitCode, Is.EqualTo(0)); + } + + [Test] + [TestCaseSource(typeof(TestData), nameof(TestData.RandomArgs))] + public void Init_WithArgs_ShouldReturnSuccess(string[] args) + { + var result = Run("init", args); + Assert.That(result.ExitCode, Is.EqualTo(0)); + } +} \ No newline at end of file diff --git a/resume builder/Program.cs b/resume builder/Program.cs index 78aee2c..43c251b 100644 --- a/resume builder/Program.cs +++ b/resume builder/Program.cs @@ -20,11 +20,9 @@ private static int Main(string[] args) //todo: don't like that parent options and arguments are positional; spectre problem public static void AppConfiguration(IConfigurator config) { - if(config == null) - throw new ArgumentNullException(nameof(config)); - #if DEBUG - config.PropagateExceptions(); +#if DEBUG + config.PropagateExceptions(); config.ValidateExamples(); #endif