Esempio n. 1
0
        public void Update_UpdatesObject()
        {
            //Arrange
            var orm = new OrMapper();
            PostGreSqlDatabase db = new PostGreSqlDatabase();
            Photographer       p  = GetPhotographer();
            int id = db.Insert(p);

            p.Id      = id;
            p.Name    = "OtherName";
            p.SurName = "OtherSurName";

            //Act
            db.Update(p);

            //Assert
            var lst = orm.GetQuery <Photographer>().Where(i => i.Id == id).ToList();

            Assert.NotNull(lst);
            Assert.IsAssignableFrom <List <Photographer> >(lst);
            Assert.Single(lst);
            Assert.Equal(p.Name, lst[0].Name);
            Assert.Equal(p.SurName, lst[0].SurName);

            //Cleanup
            p.Id = id;
            db.Delete(p);
        }
Esempio n. 2
0
        public void Delete_DeletesObject()
        {
            //Arrange
            var orm = new OrMapper();
            PostGreSqlDatabase db = new PostGreSqlDatabase();
            Photographer       p  = GetPhotographer();

            p.Id = db.Insert(p);
            int id = p.Id; //only because .where(... == p.Id cant be resolved by visitor and it writes photographer.id instead of 5 or 7 or whatever id is

            //Act
            db.Delete(p);

            //Assert
            Assert.NotNull(p);
            var lst = orm.GetQuery <Photographer>().Where(i => i.Id == id).ToList();

            Assert.NotNull(lst);
            Assert.IsAssignableFrom <List <Photographer> >(lst);
            Assert.Empty(lst);
        }
Esempio n. 3
0
        public void Insert_InsertsObject_ReturnsID()
        {
            //Arrange
            var orm = new OrMapper();
            PostGreSqlDatabase db = new PostGreSqlDatabase();
            Photographer       p  = GetPhotographer();

            //Act
            int id = db.Insert(p);

            //Assert
            Assert.NotNull(p);
            Assert.True(0 < id);
            var lst = orm.GetQuery <Photographer>().Where(i => i.Id == id).ToList();

            Assert.NotNull(lst);
            Assert.IsAssignableFrom <List <Photographer> >(lst);
            Assert.Single(lst);

            //Cleanup
            p.Id = id;
            db.Delete(p);
        }