public void LoadManyAndSelectPosTest() { BridgesReader reader = new BridgesReader(); reader.query = query; Expect.Call(query.Select(SQLSelectBridgesMode.SelectPos)).Return(true); List <DataRows> rows = new List <DataRows>(); DataRows row = new DataRows(); row.AddField(new DataField("BRNAME", "Most1")); row.AddField(new DataField("KM", 12.56)); row.AddField(new DataField("NUM", "P-86")); row.AddField(new DataField("RDNAME", "Road1")); row.AddField(new DataField("ID", 10)); rows.Add(row); row = new DataRows(); row.AddField(new DataField("BRNAME", "Most2")); row.AddField(new DataField("KM", 14.45)); row.AddField(new DataField("NUM", "P-86")); row.AddField(new DataField("RDNAME", "Road1")); row.AddField(new DataField("ID", 11)); rows.Add(row); row = new DataRows(); row.AddField(new DataField("BRNAME", "Most3")); row.AddField(new DataField("KM", 14.45)); row.AddField(new DataField("NUM", "P-89")); row.AddField(new DataField("RDNAME", "Road2")); row.AddField(new DataField("ID", 12)); rows.Add(row); row = new DataRows(); row.AddField(new DataField("BRNAME", "Most4")); row.AddField(new DataField("KM", 14.45)); row.AddField(new DataField("NUM", "P-89")); row.AddField(new DataField("RDNAME", "Road2")); row.AddField(new DataField("ID", 13)); rows.Add(row); Expect.Call(query.GetRows()).Return(rows); repository.ReplayAll(); List <RoadData> records = reader.Load(BridgesReader.BrViewMode.viewPos); Assert.AreEqual("P-86 Road1", records[0].Name); Assert.AreEqual("(12,56) Most1", records[0].Bridges[0].Name); Assert.AreEqual(10, records[0].Bridges[0].IDBR); Assert.AreEqual("P-89 Road2", records[1].Name); Assert.AreEqual("(14,45) Most4", records[1].Bridges[1].Name); Assert.AreEqual(13, records[1].Bridges[1].IDBR); Assert.AreEqual(2, records[0].Bridges.Count); Assert.AreEqual(2, records[1].Bridges.Count); repository.VerifyAll(); }
public override bool Select(string SQL) { pErrorMsg = "No error"; pErrorCode = 0; try { SqlCeCommand command = new SqlCeCommand(SQL, DataBasePDA.Get()); RecordSet Set = new RecordSet(command.ExecuteReader()); Set.Next(); string[] fields = Set.Fileds(); Rows = new List<DataRows>(); while(!Set.Eof) { DataRows row = new DataRows(); foreach (string fieldname in fields) { row.AddField(new DataField(fieldname, Set.FieldByName(fieldname))); } Rows.Add(row); Set.Next(); } } catch(Exception ex) { pErrorMsg = ex.Message; pErrorCode = 1; throw; //return false; } return true; }
public void LoadManyAndSelectPosTest() { BridgesReader reader = new BridgesReader(); reader.query = query; Expect.Call(query.Select(SQLSelectBridgesMode.SelectPos)).Return(true); List<DataRows> rows = new List<DataRows>(); DataRows row = new DataRows(); row.AddField(new DataField("BRNAME", "Most1")); row.AddField(new DataField("KM", 12.56)); row.AddField(new DataField("NUM", "P-86")); row.AddField(new DataField("RDNAME", "Road1")); row.AddField(new DataField("ID", 10)); rows.Add(row); row = new DataRows(); row.AddField(new DataField("BRNAME", "Most2")); row.AddField(new DataField("KM", 14.45)); row.AddField(new DataField("NUM", "P-86")); row.AddField(new DataField("RDNAME", "Road1")); row.AddField(new DataField("ID", 11)); rows.Add(row); row = new DataRows(); row.AddField(new DataField("BRNAME", "Most3")); row.AddField(new DataField("KM", 14.45)); row.AddField(new DataField("NUM", "P-89")); row.AddField(new DataField("RDNAME", "Road2")); row.AddField(new DataField("ID", 12)); rows.Add(row); row = new DataRows(); row.AddField(new DataField("BRNAME", "Most4")); row.AddField(new DataField("KM", 14.45)); row.AddField(new DataField("NUM", "P-89")); row.AddField(new DataField("RDNAME", "Road2")); row.AddField(new DataField("ID", 13)); rows.Add(row); Expect.Call(query.GetRows()).Return(rows); repository.ReplayAll(); List<RoadData> records = reader.Load(BridgesReader.BrViewMode.viewPos); Assert.AreEqual("P-86 Road1", records[0].Name); Assert.AreEqual("(12,56) Most1", records[0].Bridges[0].Name); Assert.AreEqual(10, records[0].Bridges[0].IDBR); Assert.AreEqual("P-89 Road2", records[1].Name); Assert.AreEqual("(14,45) Most4", records[1].Bridges[1].Name); Assert.AreEqual(13, records[1].Bridges[1].IDBR); Assert.AreEqual(2, records[0].Bridges.Count); Assert.AreEqual(2, records[1].Bridges.Count); repository.VerifyAll(); }
public void LoadOneTest() { BridgesReader reader = new BridgesReader(); reader.query = query; Expect.Call(query.Select(SQLSelectBridgesMode.SelectRel)).Return(true); List<DataRows> rows = new List<DataRows>(); DataRows row = new DataRows(); row.AddField(new DataField("BRNAME", "Most1")); row.AddField(new DataField("KM", 12.56)); row.AddField(new DataField("NUM", "P-86")); row.AddField(new DataField("RDNAME", "Road")); row.AddField(new DataField("ID", 10)); rows.Add(row); Expect.Call(query.GetRows()).Return(rows); repository.ReplayAll(); List<RoadData> records = reader.Load(BridgesReader.BrViewMode.viewRel); Assert.AreEqual("P-86 Road", records[0].Name); Assert.AreEqual("(12,56) Most1", records[0].Bridges[0].Name); Assert.AreEqual(10, records[0].Bridges[0].IDBR); repository.VerifyAll(); }
public void LoadOneTest() { BridgesReader reader = new BridgesReader(); reader.query = query; Expect.Call(query.Select(SQLSelectBridgesMode.SelectRel)).Return(true); List <DataRows> rows = new List <DataRows>(); DataRows row = new DataRows(); row.AddField(new DataField("BRNAME", "Most1")); row.AddField(new DataField("KM", 12.56)); row.AddField(new DataField("NUM", "P-86")); row.AddField(new DataField("RDNAME", "Road")); row.AddField(new DataField("ID", 10)); rows.Add(row); Expect.Call(query.GetRows()).Return(rows); repository.ReplayAll(); List <RoadData> records = reader.Load(BridgesReader.BrViewMode.viewRel); Assert.AreEqual("P-86 Road", records[0].Name); Assert.AreEqual("(12,56) Most1", records[0].Bridges[0].Name); Assert.AreEqual(10, records[0].Bridges[0].IDBR); repository.VerifyAll(); }
public void LoadTest() { List<FieldInfo> lf; FieldInfo.query = query; Expect.Call(query.Select(string.Format(FieldInfo.sql,1))).Return(true); List<DataRows> rows=new List<DataRows>(); DataRows row = new DataRows(); row.AddField(new DataField("fieldname","testvalue")); rows.Add(row); Expect.Call(query.GetRows()).Return(rows); repository.ReplayAll(); lf=FieldInfo.LoadFields(1); repository.VerifyAll(); Assert.AreEqual(1,lf.Count); Assert.AreEqual("testvalue",lf[0].fieldName); }
public void LoadTest() { List <FieldInfo> lf; FieldInfo.query = query; Expect.Call(query.Select(string.Format(FieldInfo.sql, 1))).Return(true); List <DataRows> rows = new List <DataRows>(); DataRows row = new DataRows(); row.AddField(new DataField("fieldname", "testvalue")); rows.Add(row); Expect.Call(query.GetRows()).Return(rows); repository.ReplayAll(); lf = FieldInfo.LoadFields(1); repository.VerifyAll(); Assert.AreEqual(1, lf.Count); Assert.AreEqual("testvalue", lf[0].fieldName); }
public override bool Select(string SQL) { OracleCommand command = new OracleCommand(SQL, DataBaseOracle.Get()); OracleDataReader reader; try { reader = command.ExecuteReader(); } catch(Exception) { return false; } DataRows row; Rows=new List<DataRows>(); while (reader.Read()) { row = new DataRows(); for (int i = 0; i < reader.FieldCount; i++) row.AddField(new DataField(reader.GetName(i), Convert.ToString(reader.GetValue(i)))); Rows.Add(row); } DataBaseOracle.Disconnect(); return true; }