Ejemplo n.º 1
0
        // Internal for unit testing purposes.
        internal static string BuildAllMessagesAsSingleMessage(ISayHelloFactory helloFactory,
                                                               IEnumerable <ISayHelloLanguage> languageHellos,
                                                               IEnumerable <ISayHello> allHellos,
                                                               IEnglishHello englishHello,
                                                               IFrenchHello frenchHello)
        {
            var sb = new StringBuilder();

            sb.AppendLine("Here are all the results from the Say Hello injected classes");
            sb.AppendLine();
            sb.AppendLine($"The IEnglishHello says in {englishHello.Language} '{englishHello.GetHello()}'");
            sb.AppendLine($"The IFrenchHello says in {frenchHello.Language} '{frenchHello.GetHello()}'");
            sb.AppendLine();
            sb.AppendLine("Here are all the results from the IEnumerable<ISayHelloLanguage> injected classes");
            sb.AppendLine();

            foreach (var langHello in languageHellos)
            {
                sb.AppendLine($"The {langHello.GetType().Name} says in {langHello.Language} '{langHello.GetHello()}'");
            }

            sb.AppendLine();
            sb.AppendLine("Here are all the results from the IEnumerable<ISayHello> injected classes\n");

            foreach (var langHello in allHellos)
            {
                sb.AppendLine($"The {langHello.GetType().Name} says '{langHello.GetHello()}'");
            }

            sb.AppendLine();
            sb.AppendLine("Here are all the results from the ISayHelloFactory.GetSupportedLanguageHellos()");
            sb.AppendLine();

            foreach (var langHello in helloFactory.GetSupportedLanguageHellos())
            {
                sb.AppendLine($"The {langHello.GetType().Name} says in {langHello.Language} '{langHello.GetHello()}'");
            }

            sb.AppendLine();
            sb.AppendLine("Here are all the results from the ISayHelloFactory.GetAllLanguageHellos()");
            sb.AppendLine();

            foreach (var langHello in helloFactory.GetAllLanguageHellos())
            {
                sb.AppendLine($"The {langHello.GetType().Name} says in {langHello.Language} '{langHello.GetHello()}'");
            }

            sb.AppendLine();
            sb.AppendLine("Here are all the results from the ISayHelloFactory.GetAllHellos()");
            sb.AppendLine();

            foreach (var langHello in helloFactory.GetAllHellos())
            {
                sb.AppendLine($"The {langHello.GetType().Name} says '{langHello.GetHello()}'");
            }

            return(sb.ToString());
        }
Ejemplo n.º 2
0
 public HomeController(ISayHelloFactory helloFactory,
                       IEnumerable <ISayHelloLanguage> languageHellos,
                       IEnumerable <ISayHello> allHellos,
                       IEnglishHello englishHello,
                       IFrenchHello frenchHello)
 {
     _helloFactory   = helloFactory;
     _languageHellos = languageHellos;
     _allHellos      = allHellos;
     _englishHello   = englishHello;
     _frenchHello    = frenchHello;
 }
Ejemplo n.º 3
0
 protected abstract string GetAllMessagesFromController(ISayHelloFactory helloFactory,
                                                        IEnumerable <ISayHelloLanguage> languageHellos,
                                                        IEnumerable <ISayHello> allHellos,
                                                        IEnglishHello englishHello,
                                                        IFrenchHello frenchHello);
Ejemplo n.º 4
0
 protected override string GetAllMessagesFromController(ISayHelloFactory helloFactory, IEnumerable <ISayHelloLanguage> languageHellos, IEnumerable <ISayHello> allHellos,
                                                        IEnglishHello englishHello, IFrenchHello frenchHello)
 {
     return(HomeController.BuildAllMessagesAsSingleMessage(helloFactory, languageHellos, allHellos, englishHello, frenchHello));
 }