public List <long> GetIds(int i) //получает лист id(в cards) по выборке { List <long> list = new List <long>(); string specialName = new ManagmentController().GetSpecialNameUsingType(Type); using (NpgsqlConnection connection = new NpgsqlConnection(Connection.ConnectionString)) { connection.Open(); var cmd = new NpgsqlCommand($"select id from {specialName} where \"{GetProperty(i)}\" = '{GetValue(i)}' ", connection); var reader = cmd.ExecuteReader(); while (reader.Read()) { list.Add(reader.GetInt64(0)); } } return(list); }
public void RightNumberOfCategories() { var actual = new ManagmentController().GetCategories().Count; long expected = 0; using (NpgsqlConnection connection = new NpgsqlConnection(Connection.ConnectionString)) { connection.Open(); NpgsqlCommand cmd = new NpgsqlCommand("select count(type) from types", connection); var reader = cmd.ExecuteReader(); while (reader.Read()) { expected = reader.GetInt64(0); } } Assert.AreEqual(expected, actual); }