Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

Test cases

Patrik edited this page Jan 25, 2018 · 8 revisions

Model

public class AnimalSettings
{
    [Option("-a|--alive [VALUE]")]
    public bool IsAlive { get; set; }

    [Argument(1, "[LEGS]")]
    public int Legs { get; set; }
}

public class MammalSettings : AnimalSettings
{
    [Option("--name <VALUE>")]
    public string Name { get; set; }
}

public class DogSettings : MammalSettings
{
    [Option("-g|--good-boy [VALUE]")]
    public bool GoodBoy { get; set; }

    [Argument(0, "[AGE]")]
    public int Age { get; set; }
}

public class DogCommand : Command<DogSettings>
{
}

public class HorseCommand : Command<MammalSettings>
{
}

Test case #1

config.AddCommand<AnimalSettings>("animal", animal =>
{
    animal.AddCommand<MammalSettings>("mammal", mammal =>
    {
        mammal.AddCommand<DogCommand>("dog");
        mammal.AddCommand<HorseCommand>("horse");
    });
});
./program.exe animal --alive mammal --name Rufus dog 12 --good-boy

Legs = 0
Age=12
GoodBoy=true
Name=Rufus
IsAlive=true

Test case #2

config.AddCommand<DogCommand>("dog");
./program.exe dog 12 4 --good-boy --name Rufus --alive

Legs = 4
Age=12
GoodBoy=true
Name=Rufus
IsAlive=true

Test case #3

config.AddCommand<AnimalSettings>("animal", animal =>
{
    animal.AddCommand<DogCommand>("dog");
    animal.AddCommand<HorseCommand>("horse");
});
./program.exe animal dog 12 --good-boy --name Rufus

Legs = 0
Age=12
GoodBoy=true
Name=Rufus
IsAlive=false

Test case #4

config.AddCommand<AnimalSettings>("animal", animal =>
{
    animal.AddCommand<DogCommand>("dog");
});
./program.exe animal 4 dog 12 --good-boy --name Rufus

Legs = 4
Age=12
GoodBoy=true
Name=Rufus
IsAlive=false
Clone this wiki locally