public async Task GetClassesAsync_WithoutClassesPresent_ReturnsEmptyList() { List <Class> expectedClasses = _fixture.CreateMany <Class>(0).ToList(); _classRepository .Setup(x => x.GetAllAsync()) .ReturnsAsync(expectedClasses); GetAllClassesResult result = await _sut.GetClassesAsync(); result.Should().NotBeNull(); result.Classes.Should().BeEmpty(); }
private async Task <Cifra.Application.Models.Class.Class> AskForClassAsync() { Console.Clear(); Console.WriteLine("The following classes exist:"); GetAllClassesResult result = await _classController.GetClassesAsync(); int index = 1; foreach (var @class in result.Classes) { Console.WriteLine($"[{index}] {@class.Name.Value}"); index++; } Console.WriteLine(); var chosenIndex = SharedConsoleFlows.AskForByte("Select one of the following classes, type a number"); var chosenClass = result.Classes.ElementAtOrDefault(chosenIndex - 1); if (chosenClass == null) { Console.WriteLine("Invalid choice!"); return(await AskForClassAsync()); } return(chosenClass); }