public void CreateOneItemListOfScreensForDrawing()
 {
     IList<Screen> screens = new List<Screen>();
     screens.Add(new YellowScreen());
     MenuBuilder menuBuilder = new MenuBuilder(screens);
     Assert.AreEqual("1. Build Yellow Screen\n", menuBuilder.DisplayScreenItemsForSelection());
 }
 public void ShowWelcomeMessage()
 {
     var screens = new List<Screen>();
     screens.Add(new YellowScreen());
     screens.Add(new BlueScreen(new BlueScreenRepo()));
     screens.Add(new GreenScreen(new GreenScreenRepo()));
     MenuBuilder menuBuilder = new MenuBuilder(screens);
     Assert.AreEqual("Welcome to the colour screen picker. \n \nPlease enter you screen selection 1-3:\n", menuBuilder.DisplayWelcomeMessage());
 }
 public void CreateNumberedListOfScreensForDrawing()
 {
     IList<Screen> screens = new List<Screen>();
      screens.Add(new YellowScreen());
      screens.Add(new BlueScreen(new BlueScreenRepo()));
      screens.Add(new GreenScreen(new GreenScreenRepo()));
      MenuBuilder menuBuilder = new MenuBuilder(screens);
      Assert.AreEqual("1. Build Yellow Screen\n2. Build Blue Screen\n3. Build Green Screen\n", menuBuilder.DisplayScreenItemsForSelection());
 }
 public void GetBlueScreenMessage()
 {
     var screens = new List<Screen>();
     screens.Add(new YellowScreen());
     screens.Add(new BlueScreen(new BlueScreenRepo()));
     screens.Add(new GreenScreen(new GreenScreenRepo()));
     MenuBuilder menuBuilder = new MenuBuilder(screens);
     var screen = menuBuilder.GetScreen(2);
     Assert.AreEqual("Hello from the Blue Screen", screen.DisplayWelcomeMessage());
 }
Exemple #5
0
        static void Main(string[] args)
        {
            //Create the builder
            var builder = new ContainerBuilder();
            //Register the repositories. You would not implement concrete classes like this but this code shows two different repoitories and a blank constructor
            builder.RegisterType<BlueScreenRepo>();
            builder.RegisterType<GreenScreenRepo>();
            //register the actual screens
            builder.RegisterType<YellowScreen>().As<Screen>();
            builder.RegisterType<BlueScreen>().As<Screen>();
            builder.RegisterType<GreenScreen>().As<Screen>();
            //build the container
            var container = builder.Build();
            //menu builder is the conductor here
            var menu = new MenuBuilder(container.Resolve<IEnumerable<Screen>>().ToList());

            //ALL OF THE BELOW SHOULD LIVE IN ANOTHER CLASS [CONSOLEMANAGER] AND NOT JUST BE LEFT HERE UNTESTED AND MESSY - BUT THIS ISN'T PRODUCTION CODE
            Console.WriteLine(menu.DisplayWelcomeMessage());
            var key = Console.ReadLine();
            do
            {
                if (key == "x")
                    break;
                try
                {
                    Console.Clear();
                    var screen = menu.GetScreen(Convert.ToInt32(key));
                    Console.WriteLine(screen.DisplayWelcomeMessage());
                    Console.WriteLine("press any key to continue");
                    Console.ReadKey();

                }
                catch
                {
                }
                Console.Clear();
                Console.WriteLine(menu.DisplayWelcomeMessage());
                Console.WriteLine(menu.DisplayScreenItemsForSelection());
                key = Console.ReadLine();
                Console.Clear();

            } while (true);
        }