public async Task Info() { var o = Console.ForegroundColor; var r = ConsoleColor.Red; var g = ConsoleColor.Green; var b = ConsoleColor.Cyan; var sizes = await Hosting.GetSpaceInfoAsync(); var total = sizes.TotalSpace.TotalBytes; var usedPercent = total == 0 ? 0 : 100 * sizes.UsedSpace.TotalBytes / total; var freePercent = total == 0 ? 0 : 100 * sizes.FreeSpace.TotalBytes / total; ColoredConsole.WriteLine(o, "Used ", r, sizes.UsedSpace, o, " from ", b, sizes.TotalSpace, o, " - ", r, usedPercent, "%"); ColoredConsole.WriteLine(o, "Free ", g, sizes.FreeSpace, o, " from ", b, sizes.TotalSpace, o, " - ", g, freePercent, "%"); var maxCells = Console.WindowWidth - 1; var usedCells = maxCells * usedPercent / 100; ColoredConsole.Write(r, string.Join("", Enumerable.Repeat("|", (int)usedCells))); ColoredConsole.WriteLine(g, string.Join("", Enumerable.Repeat(".", maxCells - (int)usedCells))); }
public void ThrowsException_WhenHostUnavailable() { DisableInternet(); AssertThrows <HostUnavailable>(Hosting.GetSpaceInfoAsync()); }
public async Task CorrectWork_WhenServiceAvailable() { var space = await Hosting.GetSpaceInfoAsync(); space.TotalSpace.Should().Be(TotalDiskSpace); }