using System.Data;

namespace praktika.TestPr
{
    [TestClass]
    public class TestsClass 
    {
        Form1 form = new Form1();
        [TestMethod]
        public void Q_ShouldWrapIdentifierWithQuotes()
        {
            Assert.AreEqual("\"users\"", Form1.Q("users"));
        }

        [TestMethod]
        public void Q_ShouldEscapeInnerQuotes()
        {
            Assert.AreEqual("\"user\"\"name\"", Form1.Q("user\"name"));
        }

        [TestMethod]
        public void PrepareTable_PrimaryKeyShouldBeReadOnly()
        {
            var table = new DataTable();
            table.Columns.Add("id");

            form.PrepareTable("authors", table);

            Assert.IsTrue(table.Columns["id"].ReadOnly);
        }
        [TestMethod]
        public void PrepareTable_NormalColumnShouldBeEditable()
        {
            var table = new DataTable();
            table.Columns.Add("name");

            form.PrepareTable("authors", table);

            Assert.IsFalse(table.Columns["name"].ReadOnly);
        }
        [TestMethod]
        public void UsersTable_ShouldBeAdminOnly()
        {
            Assert.IsTrue(
                form.tables["users"].AdminOnly);
        }
    }
}