예제 #1
0
        private void CheckCoupleChild(Human parent, Human anotherParent, Type expectedChildType, string expectedChildPatronymic)
        {
            var child = _entitiesGenerator.Couple(parent, anotherParent);

            Assert.AreEqual(expectedChildType, child.GetType());
            var humanChild = child as Human;

            Assert.AreEqual(expectedChildPatronymic, humanChild?.Patronymic);
        }
예제 #2
0
        private static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            Console.WriteLine(Resources.About);
            if (DateTime.Now.DayOfWeek == DayOfWeek.Sunday)
            {
                Console.WriteLine(Resources.SundayGreeting);
                return;
            }

            Console.WriteLine(Resources.WorkDayGreeting);
            Console.WriteLine(Resources.HowToUse);

            var        entitiesGenerator = new EntitiesGenerator();
            ConsoleKey pressedKey;

            do
            {
                Human parent        = entitiesGenerator.CreateRandomHuman();
                Human anotherParent = entitiesGenerator.CreateRandomHuman();
                parent.ToConsole();
                anotherParent.ToConsole();
                try
                {
                    IHasName child = entitiesGenerator.Couple(parent, anotherParent);
                    if (child == null)
                    {
                        Console.WriteLine(Resources.FailedCoupleCreation);
                    }
                    else
                    {
                        child.ToConsole();
                    }
                }
                catch (SameSexException exception)
                {
                    Console.WriteLine(exception.Message);
                }
                Console.WriteLine();
                pressedKey = ReadControlKey();
            } while (!IsInterruptKey(pressedKey));
        }