Lesson 1.10: CLI End to End Tests

Unit tests are just one type of test that we can use to validate our console application. While those are validating that command logic is working in isolation, we also need to verify that our command configuration was done correctly, that our repository is working, and that the command line works the way our users … Continue reading Lesson 1.10: CLI End to End Tests

Lesson 1.9: Unit Testing Commands

The detailed description for just one test and how to run it got longer than expected, so we are putting the remaining command tests in this separate lesson. We won't go over each test in excruciating detail in this lesson. Instead, we will only focus on the differences or uniqueness of particular tests. For detailed … Continue reading Lesson 1.9: Unit Testing Commands

Lesson 1.8: Our First Command Unit Test

Having created our unit test project in lesson 1.7, we are ready to start writing some tests. This lesson will focus on the mechanics of setting up our first test in xUnit, how to mock our IUniversityRepository dependency, and the strategy of which tests to write to cover all of the scenarios for our commands. … Continue reading Lesson 1.8: Our First Command Unit Test

Lesson 1.7: Setting Up Unit Test Project

Testing is an important part of any project or command-line app. Spectre.Console.Cli is designed very well to support unit testing of commands. Unit tests are isolated tests meant to test just the code and logic within a component, or a command in the case of CLI apps. Using interfaces for dependent components and dependency injection … Continue reading Lesson 1.7: Setting Up Unit Test Project

Lesson 1.6: Using Dependency Injection

In lesson 1.5, we discussed what dependency injection was and how to build two classes to integrate our DI engine into the Spectre.Console.Cli app. This lesson will build on that and show how we can use dependency injection in a more robust example. We will build a fully-functional IUniversityRepository, which implements all of the CRUD … Continue reading Lesson 1.6: Using Dependency Injection

Lesson 1.5: Setting up Dependency Injection Components

Spectre.Console supports the ability to use dependency injection to find types for our commands. The library has an integration mechanism so that developers can use their favorite DI engine with their command-line app. In this lesson, we will learn how to integrate the .NET Extensions dependency injection engine with Spectre.Console. If you are unfamiliar with … Continue reading Lesson 1.5: Setting up Dependency Injection Components

Lesson 1.4: Async Commands

To this point, we have been using synchronous commands, but the Spectre.Console.Cli library also supports asynchronous commands. For anyone familiar with the async/await concepts in .NET, these commands follow the same pattern. When our commands use asynchronous APIs (for file I/O or web service calls), then we also need our commands to be asynchronous. With … Continue reading Lesson 1.4: Async Commands

Lesson 1.3: Nested Commands

The Spectre.Console.Cli supports having multiple nested commands to enable multiple operations on a particular resource. For example: if we have a command with additional operations, we can represent that as nested commands: command operation1, command operation2, command operation3, and so on. To enable this type of nesting, the Spectre.Console.Cli provides the AddBranch configuration method. To … Continue reading Lesson 1.3: Nested Commands

CLI Lessons Updated to Spectre.Console v0.36

With the changes to merge the Spectre.Cli and Spectre.Console packages, we had to update our existing lessons to the new combined package as well. Starting with Spectre.Console v0.36, both code bases are in a single package. Our tutorial lessons have also been updated to the new version. Lesson 1.1: Starting with Spectre.Console.CliLesson 1.2: Multiple, Default, … Continue reading CLI Lessons Updated to Spectre.Console v0.36