Пример #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);
        }
Пример #2
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");
        }