Ejemplo n.º 1
0
        public string ListPatterns(IEnumerable <Pattern> patterns)
        {
            _dataRender = new DataRenderer(new PatternFill(patterns));
            var writer = new StringWriter();

            _dataRender.Render(writer);
            return(writer.ToString());
        }
Ejemplo n.º 2
0
        private static void Example1()
        {
            var myRenderer = new DataRenderer(new StubDbAdapter());

            var writer = new StringWriter();

            myRenderer.Render(writer);

            Console.Write(writer.ToString());
        }
        public string ListPatterns(IEnumerable <Pattern> patterns)
        {
            var adapter = new PatternCollectionDbAdapter(patterns);

            _dataRenderer = new DataRenderer(adapter);

            var writer = new StringWriter();

            _dataRenderer.Render(writer);

            return(writer.ToString());
        }
        public void RenderOneRowGivenStubDBAdapter()
        {
            var myRenderer = new DataRenderer(new StubDBAdapter());
            var writer     = new StringWriter();

            myRenderer.Render(writer);

            string result = writer.ToString();

            Console.WriteLine(result);

            int lineCount = result.Count(c => c == '\n');

            Assert.AreEqual(3, lineCount);
        }
Ejemplo n.º 5
0
            public void WhenGivenStubDbDataAdapter_ShouldRenderASingleRow()
            {
                //Arrange
                var stubDataAdapter = makeNewStubDbDataAdapter();
                var writer          = new StringWriter();
                var sut             = new DataRenderer(stubDataAdapter);

                //Act
                sut.Render(writer);

                var result = writer.ToString();

                Write(result);
                //Assert
                result.Count(c => c == '\n').ShouldBe(3);
            }
Ejemplo n.º 6
0
        private static void Example2()
        {
            var connectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Github\DesignPatterns\AdapterPattern\Sample.mdf;Integrated Security=True";

            var adapter = new SqlDataAdapter
            {
                SelectCommand = new SqlCommand("Select * from Pattern")
                {
                    Connection = new SqlConnection(connectionString)
                }
            };

            var myRenderer = new DataRenderer(adapter);

            var writer = new StringWriter();

            myRenderer.Render(writer);

            Console.Write(writer.ToString());
        }
        public void RenderTwoRowsGivenOleDbDataAdapter()
        {
            var adapter = new OleDbDataAdapter();

            adapter.SelectCommand            = new OleDbCommand("SELECT * FROM Pattern");
            adapter.SelectCommand.Connection = new OleDbConnection(@"
              Provider=Microsoft.SQLSERVER.CE.OLEDB.4.0;Data Source=C:\Apps\DesignPatterns\AdapterPattern\Sample.sdf");
            var myRenderer = new DataRenderer(adapter);

            var writer = new StringWriter();

            myRenderer.Render(writer);

            string result = writer.ToString();

            Console.Write(result);

            int lineCount = result.Count(c => c == '\n');

            Assert.AreEqual(4, lineCount);
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            Console.WriteLine("--------------------------------Simple Stub----------------------------------------------");
            DataRenderer dr = new DataRenderer(new StubAdapter());

            dr.Render(Console.Out);


            Console.WriteLine("--------------------------------Adapter Stub----------------------------------------------");

            List <Pattern> lstPatterns = new List <Pattern>();

            lstPatterns.Add(new Pattern()
            {
                Id = "1", Description = "This is adapter pattern.", Name = "Adapter Patttern"
            });
            PatternRender pt     = new PatternRender(new DataPatternRenderAdapter());
            string        result = pt.ListPatterns(lstPatterns);

            Console.WriteLine(result);


            Console.ReadLine();
        }
Ejemplo n.º 9
0
        public void Render(TextWriter writer)
        {
            var _dataRenderer = new DataRenderer(_dataAdapter);

            _dataRenderer.Render(writer);
        }
Ejemplo n.º 10
0
 public void Render(TextWriter writer)
 {
     var  _dataRenderer = new DataRenderer(_dataAdapter);
     _dataRenderer.Render(writer);
 }