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 5.14: Use Service Client to Retrieve ItemTemplates From Game Services

In this lesson, we will refactor the ItemFactory to use the GameServiceClient to load item data from our game services rather than from the local resource file. We will fetch the ItemTemplates during the application startup so that any latency is part of the launch. We already have loading logic and a progress indicator at … Continue reading Lesson 5.14: Use Service Client to Retrieve ItemTemplates From Game Services

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 5.13: Build Reusable Service Client for Game Engine

After spending most of this chapter working to create our game services, we are going to return to the SimpleRPG game engine. We want to replace our local game data files with requests to our game services. That way we can retrieve updated data from the services and cache it locally for the running game … Continue reading Lesson 5.13: Build Reusable Service Client for Game Engine

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 5.12: Create CD Pipeline for Azure Functions App

In lesson 5.3, we set up a continuous delivery pipeline for our SimpleRPG game Blazor app. We also need to set up a deployment pipeline for our game services. This pipeline will release the latest game services build to our Azure account and Functions App resource. The specific steps of this deployment script will be … Continue reading Lesson 5.12: Create CD Pipeline for Azure Functions App

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 5.11: Create CI Pipeline for Azure Functions Project

Early in our development of the SimpleRPG game project, we set up a continuous integration pipeline to automate our build with every repo check-in. Now we are going to set up another pipeline for our game services. Since the services are in their own repository and solution and have different deployment requirements, we will need … Continue reading Lesson 5.11: Create CI Pipeline for Azure Functions Project

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