public void FormatValueBackwards()
        {
            BackwardsFormatter formatter = new BackwardsFormatter();
            string             formatted = formatter.Format("Title", "The Animal Farm");

            Assert.Equal("Title: mraF laminA ehT", formatted);
        }
예제 #2
0
        public void BackwardsFormatter()
        {
            var formatter = new BackwardsFormatter();

            CreateManuscriptsWith(formatter);
            foreach (var doc in _documents)
            {
                doc.Print();
            }
        }
예제 #3
0
        public Library()
        {
            var standardFormatter  = new StandardFormatter();
            var backwardsFormatter = new BackwardsFormatter();
            var fancyFormatter     = new FancyFormatter();

            _manuscripts = new List <IManusript>();

            var faq = new FAQ(standardFormatter)
            {
                Title = "The Bridge Pattern FAQ"
            };

            faq.Questions.Add("What is it?", "A design pattern.");
            faq.Questions.Add("When do we use it?", "When you need to separate an abstraction from an implementation.");
            _manuscripts.Add(faq);

            var book = new Book(backwardsFormatter)
            {
                Title  = "Lots of Patterns",
                Author = "John Sonmez",
                Text   = "Blah blah blah..."
            };

            _manuscripts.Add(book);

            var paper = new TermPaper(fancyFormatter)
            {
                Class      = "Design Patterns",
                Student    = "Joe N00b",
                Text       = "Blah blah blah",
                References = "GOF"
            };

            _manuscripts.Add(paper);

            foreach (var manuscript in _manuscripts)
            {
                manuscript.Print();
            }
        }
예제 #4
0
        private static void DemoBridgePattern()
        {
            List <Manuscript> documents = new List <Manuscript>();
            //var formatter = new StandardFormatter();
            BackwardsFormatter formatter = new BackwardsFormatter();

            FAQ faq = new FAQ(formatter)
            {
                Title = "The Bridge pattern FAQ",
            };

            faq.Questions.Add("What is it?", "A design pattern");
            faq.Questions.Add("When do we use it?", "When you need to separate an abstraction from an implementation");
            documents.Add(faq);

            Book book = new Book(formatter)
            {
                Title  = "Lots of patterns",
                Author = "PA",
                Text   = "qwerty qazwsx",
            };

            documents.Add(book);

            TermPaper paper = new TermPaper(formatter)
            {
                Class      = "Design Patterns",
                Student    = "P",
                Text       = "qwerty wsx",
                References = "GOF",
            };

            documents.Add(paper);

            foreach (Manuscript doc in documents)
            {
                doc.Print();
            }
        }