public static void Action(ToyRegister bag, ChildrenRegister book)
        {
            Console.Clear();
            Console.WriteLine("Choose a child");

            var children = book.GetChildren();

            foreach (var child in children)
            {
                Console.WriteLine($"{child.Id}: {child.Name}");
            }

            int childId = int.Parse(Console.ReadLine());

            var kid = book.GetChild(childId);

            Console.WriteLine($"Choose a toy to revoke from {kid.Name}");
            Console.Write("> ");
            var kidsToys = bag.GetToysForChild(kid);

            foreach (var toy in kidsToys)
            {
                Console.WriteLine($"{toy.Id}: {toy.Name}");
            }

            int toyId       = int.Parse(Console.ReadLine());
            var toyToRevoke = kidsToys.First(t => t.Id == toyId);

            bag.RevokeToy(toyToRevoke, kid);
        }
Exemple #2
0
        public void RevokeToyFromChild()
        {
            int   id  = _book.AddChild("Terell");
            Child kid = _book.GetChild(id);
            Toy   toy = _register.Add("Silly Putty", kid);

            _register.RevokeToy(kid, toy);
            List <Toy> toysForTerell = _register.GetToysForChild(kid);

            Assert.DoesNotContain(toy, toysForTerell);
        }