using System;
namespace Amphora.UnitTests
{
public enum SampleMode
{
Fast,
Slow,
}
[Flags]
public enum SampleSet
{
A = 1,
B = 2,
}
///
/// The one place in the test assembly that keeps flags in static fields, so scanning the assembly finds exactly
/// these.
///
public class SampleFlags
{
public static readonly Flag Vsync = new Flag("Turns vertical sync on.", defaultValue: true);
public static readonly Flag Quiet = new Flag("Mutes the sound.");
public static readonly Flag Seed = new Flag("Fixes the seed.", defaultValue: 7);
public static readonly Flag Level = new Flag("Sets the level.", defaultValue: 3);
public static readonly Flag Offset = new Flag("Shifts the clock.");
public static readonly Flag Scale = new Flag("Scales the view.", defaultValue: 1.5);
public static readonly Flag Title = new Flag("Names the window.", defaultValue: "none");
public static readonly Flag Mode = new Flag("Picks the speed.", SampleMode.Slow);
public static readonly Flag Nameless = new Flag("Has no default.");
private static readonly Flag Hidden = new Flag("Is kept in a private field.");
public static readonly Flag Letter =
new Flag("Picks a letter.", 'a', TryParseLetter, "");
public static readonly int NotAFlag = 5;
public readonly Flag OnAnInstance = new Flag("Is kept in an instance field.");
public static FlagBase PrivateFlag => Hidden;
public static bool TryParseLetter(string text, out char value, out string problem)
{
value = default;
problem = null;
if (text.Length == 1 && char.IsLetter(text[0]))
{
value = text[0];
return true;
}
if (text == "unexplained")
{
return false;
}
problem = $"needs one letter, not '{text}'";
return false;
}
}
}