public void TestBasicCRUD()
        {
            using (Model.Context db = new Model.Context("mdbConnectionString"))
            {
                Note n = new Note();
                n.Content = "Test content";
                n.Created = DateTime.UtcNow.Date;
                n.Modified = DateTime.UtcNow.Date;

                db.InsertOnSubmit<Note>(n);
                db.SubmitChanges();

                Assert.AreNotEqual(n.Codigo, 0);

                Note result = db.Connection.Query<Note>("SELECT * FROM Notes WHERE Codigo = @Id", new { Id = n.Codigo }).FirstOrDefault();
                Assert.AreNotEqual(result, null);
                Assert.AreEqual(result.Content, n.Content);
                Assert.AreEqual(result.Created, n.Created);
                Assert.AreEqual(result.Modified, n.Modified);

                db.DeleteOnSubmit<Note>(result);
                db.SubmitChanges();

                Assert.IsFalse(db.Connection.Query<Post>("SELECT * FROM Notes WHERE Codigo = @Id", new { Id = n.Codigo }).Any());
            }
        }
Пример #2
0
		public void NoteEqualTest()
		{
			Note cs1 = new Note(Note.Letter.C, Note.Accidental.None, Note.Octave.OneLined);
			Note df1 = new Note(Note.Letter.D, Note.Accidental.None, Note.Octave.OneLined);

			Assert.IsTrue(cs1.Equals(cs1));
			// Test nie skończony!
		}
        public void TestUpdateSimple()
        {
            using (Model.Context db = new Model.Context("mdbConnectionString"))
            {
                Note n = new Note();
                n.Content = "Prueba";
                n.Created = DateTime.UtcNow.Date;
                n.Modified = DateTime.UtcNow.Date;

                db.InsertOnSubmit<Note>(n);
                db.SubmitChanges();

                n.Content = "Test";
                db.UpdateOnSubmit<Note>(n);
                db.SubmitChanges();

                Note newNote = db.Connection.Query<Note>("SELECT * FROM Notes WHERE Codigo = " + n.Codigo).FirstOrDefault();

                Assert.AreEqual(newNote.Content, "Test");

                db.DeleteOnSubmit<Note>(newNote);
                db.SubmitChanges();
            }
        }