This chapter took us through the basics of creating a console application using the Spectre.Console.Cli library. This library removes a lot of the boilerplate code needed to parse command-line arguments and map them to operations in our code. By adopting their Command pattern, we are able to focus on our code and functionality without having … Continue reading Lesson 1.11: The Wrap
Tag: Spectre.Cli
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
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
Spectre.Cli Moved to Spectre.Console
There has been a big change to the Spectre.Cli project that I'm using in the CLI Lesson series. The project and package has moved into the Spectre.Console project. This combines the code for building command-line interface apps with the Spectre.Console capabilities to create rich, modern console UI with color, layout, and controls. While this is … Continue reading Spectre.Cli Moved to Spectre.Console