UnitTest1.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System.Data;
  2. namespace praktika.TestPr
  3. {
  4. [TestClass]
  5. public class TestsClass
  6. {
  7. Form1 form = new Form1();
  8. [TestMethod]
  9. public void Q_ShouldWrapIdentifierWithQuotes()
  10. {
  11. Assert.AreEqual("\"users\"", Form1.Q("users"));
  12. }
  13. [TestMethod]
  14. public void Q_ShouldEscapeInnerQuotes()
  15. {
  16. Assert.AreEqual("\"user\"\"name\"", Form1.Q("user\"name"));
  17. }
  18. [TestMethod]
  19. public void PrepareTable_PrimaryKeyShouldBeReadOnly()
  20. {
  21. var table = new DataTable();
  22. table.Columns.Add("id");
  23. form.PrepareTable("authors", table);
  24. Assert.IsTrue(table.Columns["id"].ReadOnly);
  25. }
  26. [TestMethod]
  27. public void PrepareTable_NormalColumnShouldBeEditable()
  28. {
  29. var table = new DataTable();
  30. table.Columns.Add("name");
  31. form.PrepareTable("authors", table);
  32. Assert.IsFalse(table.Columns["name"].ReadOnly);
  33. }
  34. [TestMethod]
  35. public void UsersTable_ShouldBeAdminOnly()
  36. {
  37. Assert.IsTrue(
  38. form.tables["users"].AdminOnly);
  39. }
  40. }
  41. }