public IList <IServerObj> GetServers() { Configurations = parseConfiguration.GetConfigServers_Npgsql(); if (Configurations != null) { foreach (var _Configurations in Configurations) { try { provider.Createconnection(_Configurations.Value); provider.OpenConnection(); DataList = provider.GetDataReader(); writerServers.CreateServerObj(_Configurations.Key); foreach (var _DataList in DataList) { string nameDb = _DataList[0]; string sizeDb = _DataList[1]; string updateDateDb = _DataList[2]; writerServers.WriteServerObjs(nameDb, sizeDb, updateDateDb); } ListServerObjs.Add(writerServers.GetServerObj()); provider.CloseConnection(); } catch (Exception e) { string[] code = e.Message.Split(':'); string ExceptionMessage; switch (code[0]) { case "28P01": ExceptionMessage = "Не правильный пароль или User Id, для подключения к серверу"; break; default: ExceptionMessage = e.Message; break; } Console.WriteLine("Ошибка: {0}\nНажмите любую кнопку для закрытия программы", e.Message); Console.ReadKey(); Environment.Exit(1); } } } return(ListServerObjs); }
public void WriteServerObjsTest_ReturnCorrectDb() { string nameServer = "LocalServer"; string nameDb = "DbTest"; string sizeDb = "0,00741"; string updateDateDb = "02.04.2020"; writerServers.CreateServerObj(nameServer); writerServers.WriteServerObjs(nameDb, sizeDb, updateDateDb); Assert.AreEqual(StubtServerObjs.NameServer, writerServers.GetServerObj().NameServer); Assert.AreEqual(StubtServerObjs.DataBases[0].name, writerServers.GetServerObj().DataBases[0].name); Assert.AreEqual(StubtServerObjs.DataBases[0].size, writerServers.GetServerObj().DataBases[0].size); Assert.AreEqual(StubtServerObjs.DataBases[0].updateDate, writerServers.GetServerObj().DataBases[0].updateDate); }