Beispiel #1
0
        public void GetByID_Test()
        {
            Setup();

            _testDB.RunSQL("INSERT INTO ThingOne ( Name, Score) VALUES ('Testing name', 5) ");

            ThingOne thing = _thingOneData.GetByID(testId);

            DataTable dt = _testDB.GetBySQL("SELECT * FROM ThingOne WHERE ThingOneID = " + testId);

            Assert.AreEqual(dt.Rows[0]["Name"].ToString(), thing.Name);
        }
Beispiel #2
0
        public void Update_Test()
        {
            Setup();

            _testDB.RunSQL("INSERT INTO ThingOne ( Name, Score) VALUES ('Testing name', 5) ");

            string newName = "Something else name";

            ThingOne thing = _thingOneData.GetByID(testId);

            thing.Name = newName;

            _thingOneData.Update(thing);

            DataTable dt = _testDB.GetBySQL("SELECT * FROM ThingOne WHERE ThingOneID = " + testId);

            Assert.AreEqual(newName, dt.Rows[0]["Name"].ToString());
        }
Beispiel #3
0
        public void AddM21Child_Test()
        {
            Setup();

            _testDB.RunSQL("INSERT INTO ThingOne ( Name, Score) VALUES ('Top thing', 10) ;");
            _testDB.RunSQL("INSERT INTO ThingTwo ( Name, Description) VALUES ('Bob', 'Is a top thing') ;");

            ThingOne topThing = _thingOneData.GetByID(1);

            _thingTwoData.SelectLevels = 2;
            ThingTwo bob = _thingTwoData.GetByID(1);

            bob.ThingOne = topThing;

            _thingTwoData.Update(bob);

            DataTable dt = _testDB.GetBySQL("SELECT ThingTwoID, Name, Description, ThingOneID FROM dbo.[ThingTwo] WHERE ThingTwoID = 1");

            DataRow dr = dt.Rows[0];

            Assert.IsTrue(dr["ThingOneID"].ToString() == "1");
        }
Beispiel #4
0
        public void Create_Test()
        {
            Setup();

            string name         = "Testing name";
            int    rowsToInsert = 1;
            int    rowsInserted = 0;

            ThingOne thing = new ThingOne()
            {
                Name  = name,
                Score = 1
            };

            _thingOneData.Create(thing);

            DataTable dt = _testDB.GetBySQL("SELECT * FROM ThingOne WHERE Name = '" + name + "'");

            rowsInserted = dt.Rows.Count;

            Assert.AreEqual(rowsToInsert, rowsInserted);
        }