public void ShouldRenderTwoRowsGivenOleDbDataAdapter() { const int expectedNumberOfLines = 4; var adapter = new OleDbDataAdapter { SelectCommand = new OleDbCommand("SELECT * FROM Pattern") { Connection = new OleDbConnection( @"Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source=AdapterSampleDb.sdf") } }; var myRenderer = new DataRenderer(adapter); var writer = new StringWriter(); myRenderer.Render(writer); var result = writer.ToString(); Console.WriteLine(result); var numberOfLines = result.Count(r => r == '\n'); Assert.AreEqual(expectedNumberOfLines, numberOfLines); }
public IEnumerable <SkycoreHRM.Shared.Department> GetData() { foreach (var strategy in Strategies) { try { IDbDataAdapter adapter = null; var accessContext = new DataAccessContext(strategy); adapter = accessContext.EstablishDataAccess(adapter); var myRenderer = new DataRenderer(adapter); var writer = new StringWriter(); myRenderer.Render(writer); var result = writer.ToString().Replace(" ", string.Empty); var rows = result.Split("\r\n").Where(e => !string.IsNullOrEmpty(e)); var departments = rows.Select(e => new SkycoreHRM.Shared.Department { Name = e }); return(departments); } catch (Exception) { continue; } } return(null); }
public string ListPatterns(IEnumerable <Pattern> patterns) { _dataRenderer = new DataRenderer(new PatternCollectionDbAdapter(patterns)); var writer = new StringWriter(); _dataRenderer.Render(writer); return(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 Souldbe4Lines() { DataRenderer dataRenderer = new DataRenderer(new StubDBDataAdabter()); var textWriter = new StringWriter(); dataRenderer.Render(textWriter); var result = textWriter.ToString(); Console.Write(result); Assert.AreEqual(3, result.Count(x => x == '\n')); }
public string ToString(List <Superhero> heroes) { _adapter = new SuperHeroDbAdapter(heroes); var renderer = new DataRenderer(_adapter); var textWriter = new StringWriter(); renderer.Render(textWriter); return(textWriter.ToString()); }
public void TestMethod1() { IDbDataAdapter adapter = new StubDbAdapter(); DataRenderer renderer = new DataRenderer(adapter); StringWriter writer = new StringWriter(); renderer.Render(writer); string result = writer.ToString(); Console.WriteLine(result); Assert.AreEqual(5, result.Count(c => c == '\n')); }
public void TestMethod2() { IDbDataAdapter oleDbAdapter = new SqlDataAdapter(@"SELECT Id, Nome, Descrizione FROM TestTable", new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\FabrizioDiNunzio\source\repos\OData\AdapterDemo\TestDatabase.mdf;Integrated Security=True")); DataRenderer renderer = new DataRenderer(oleDbAdapter); StringWriter writer = new StringWriter(); renderer.Render(writer); string result = writer.ToString(); Console.WriteLine(result); Assert.AreEqual(6, result.Count(c => c == '\n')); }
public void RenderOneRowGivenStubDataAdapter() { var myRenderer = new DataRenderer(new StubDbAdapter()); var writer = new StringWriter(); myRenderer.Render(writer); string result = writer.ToString(); Console.Write(result); int lineCount = result.Count(c => c == '\n'); Assert.AreEqual(3, lineCount); }
public void UseSqlDataAdapter() { var conString = ConfigurationManager.ConnectionStrings["SqlCon"].ConnectionString; var sqlString = "SELECT * FROM Patterns"; var adapter = new SqlDataAdapter(sqlString, conString); var textWriter = new StringWriter(); DataRenderer renderer = new DataRenderer(adapter); renderer.Render(textWriter); var result = textWriter.ToString(); Console.Write(result); Assert.AreEqual(4, result.Count(x => x == '\n')); }
public void ShouldRenderFromStubDataAdapter() { var dataAdapter = new StubDataDbAdapter(); var renderer = new DataRenderer(dataAdapter); var writer = new StringWriter(); renderer.Render(writer); var result = writer.ToString(); Console.Write(result); Assert.IsNotNull(result); }
public void RenderOneRowGivenStubDataAdapter() { var myRenderer = new DataRenderer(new StudDbAdapter()); var writer = new StringWriter(); myRenderer.Render(writer); var result = writer.ToString(); Console.Write(result); var lineCount = result.Count(c => c == '\n'); Assert.AreEqual(3, lineCount); }
public void render_one_row_given_a_StubDbDataAdapter() { var dataRenderer = new DataRenderer(new StubDataAdapter()); var writer = new StringWriter(); dataRenderer.Render(writer); string result = writer.ToString(); output.WriteLine(result); int lineCount = result.Count(c => c == '\n'); lineCount.ShouldBe(3); }
public void ShouldRenderOneRowGivenStubDataAdapter() { const int expectedNumberOfLines = 3; var myRenderer = new DataRenderer(new StubDbAdapter()); var writer = new StringWriter(); myRenderer.Render(writer); var result = writer.ToString(); Console.WriteLine(result); var numberOfLines = result.Count(r => r == '\n'); Assert.AreEqual(expectedNumberOfLines, numberOfLines); }
public void Render_GivenDataAdapter_RenderRows() { var stubAdapter = new Mock <IDbDataAdapter>(); stubAdapter.Setup(s => s.Fill(It.IsAny <DataSet>())) .Callback <DataSet>(x => { x.Tables.Add(RendererTestData.GetData()); x.AcceptChanges(); }); var dataRenderer = new DataRenderer(stubAdapter.Object); var writer = new StringWriter(); dataRenderer.Render(writer); var result = writer.ToString(); Assert.Equal(3, result.Count(c => c == '\n')); }
public void RenderTwoRowsGivenOleDbDataAdapter() { var adapter = new SqlDataAdapter(); adapter.SelectCommand = new SqlCommand("SELECT * FROM Pattern"); adapter.SelectCommand.Connection = new SqlConnection( @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=f:\Naruto Images\Sample.mdf;Integrated Security=True;Connect Timeout=30"); 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); }
public void RenderTwoRowsGivenOleDbDataAdapter() { var adapter = new OleDbDataAdapter(); adapter.SelectCommand = new OleDbCommand("SELECT * FROM Pattern"); adapter.SelectCommand.Connection = new OleDbConnection(); var renderer = new DataRenderer(adapter); var writer = new StringWriter(); renderer.Render(writer); var result = writer.ToString(); Console.Write(result); var lineCount = result.Count(c => c == '\n'); Assert.AreEqual(4, lineCount); }
static void Main(string[] args) { List <Person> persons = new List <Person>() { new Person() { Name = "Foo", Age = 25 }, new Person() { Name = "Bar", Age = 25 } }; var renderer = new DataRenderer(new PersonCollectionDbAdapter(persons)); renderer.Render(Console.Out); Console.ReadLine(); }
public void RenderTwoRowsGivenOleDbDataAdapter() { var adapter = new OleDbDataAdapter(); adapter.SelectCommand = new OleDbCommand("SELECT * FROM Pattern"); adapter.SelectCommand.Connection = new OleDbConnection( @"Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source=D:\Work\Amitac\Design Patterns Library\Design_Patterns_Library\01_Adapter_Pattern\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); }
public void render_two_rows_given_an_OleDbDataAdapter() { var sqlDataAdapter = new SqlDataAdapter(); sqlDataAdapter.SelectCommand = new SqlCommand("SELECT * FROM tbl_Pattern"); sqlDataAdapter.SelectCommand.Connection = new SqlConnection(@"Data Source=(localdb)\LocalDBApp;Initial Catalog=Sample;Integrated Security=True"); var dataRenderer = new DataRenderer(sqlDataAdapter); var writer = new StringWriter(); dataRenderer.Render(writer); string result = writer.ToString(); output.WriteLine(result); int lineCount = result.Count(c => c == '\n'); lineCount.ShouldBe(4); }
public void RenderTwoRowsGivenOleDbDataAdapter() { var adapter = new OleDbDataAdapter(); adapter.SelectCommand = new OleDbCommand("SELECT * FROM Pattern"); adapter.SelectCommand.Connection = new OleDbConnection( @"Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source=E:\Study Materials\DesignPattern\DesignPatternSamples\AdapterPattern\CSharpLib.AdapterPattern\Pluralsight_AdapterSample\DB\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); }
private void DrawGame(object sender, EventArgs e) { _canvasRenderer.Render(); _dataRenderer.Render(); label.Content = $"Voorraad: {_game._waterskibaan.LijnenVoorraad.GetCount()}"; }