Ejemplo n.º 1
0
        public void Delete_GivenPoco_ShouldDeletePoco()
        {
            // Arrange
            DB.Insert(_person);
            _order.PersonId = _person.Id;
            DB.Insert(_order);
            _orderLine.OrderId = _order.Id;
            DB.Insert(_orderLine);
            DB.Insert(_note);

            // Act
            DB.Delete(_orderLine);
            DB.Delete(_order);
            DB.Delete(_person);
            DB.Delete(_note);

            _person = DB.SingleOrDefault<Person>(_person.Id);
            _order = DB.SingleOrDefault<Order>(_order.Id);
            _orderLine = DB.SingleOrDefault<OrderLine>(_orderLine.Id);
            _note = DB.SingleOrDefault<Note>(_note.Id);

            // Assert
            _person.ShouldBeNull();
            _order.ShouldBeNull();
            _orderLine.ShouldBeNull();
            _note.ShouldBeNull();
        }
Ejemplo n.º 2
0
        public void ShouldNotBe(Note other, bool sameIds)
        {
            if (sameIds)
                Id.ShouldBe(other.Id);
            else
                Id.ShouldNotBe(other.Id);

            CreatedOn.ShouldNotBe(other.CreatedOn);
            Text.ShouldNotBe(other.Text);
        }
Ejemplo n.º 3
0
        public void Delete_GivenPocoOrPrimaryKey_ShouldDeletePoco()
        {
            DB.Insert(_note);
            DB.Insert(_note2);
            DB.Insert(_person);

            DB.Delete<Person>(_person.Id).ShouldBe(1);
            DB.Delete<Note>(_note).ShouldBe(1);
            DB.Delete<Note>(new { _note2.Id }).ShouldBe(1);

            _person = DB.SingleOrDefault<Person>(_person.Id);
            _note = DB.SingleOrDefault<Note>(_note.Id);
            _note2 = DB.SingleOrDefault<Note>(_note2.Id);

            _person.ShouldBeNull();
            _note.ShouldBeNull();
            _note2.ShouldBeNull();
        }
Ejemplo n.º 4
0
        public void Delete_GivenSql_ShouldDeletePoco()
        {
            DB.Insert(_note);
            DB.Insert(_person);

            DB.Delete<Note>(new Sql($"WHERE {DB.Provider.EscapeSqlIdentifier("Id")} = @0", _note.Id)).ShouldBe(1);
            DB.Delete<Person>(new Sql($"WHERE {DB.Provider.EscapeSqlIdentifier("Id")} = @0", _person.Id)).ShouldBe(1);

            _person = DB.SingleOrDefault<Person>(_person.Id);
            _note = DB.SingleOrDefault<Note>(_note.Id);

            _person.ShouldBeNull();
            _note.ShouldBeNull();
        }
Ejemplo n.º 5
0
        public void Delete_GivenTableNamePrimaryKeyNamePocoAndPrimaryKeyValue_ShouldDeletePoco()
        {
            DB.Insert(_person);
            DB.Insert(_note);

            DB.Delete("People", "Id", _person, _person.Id).ShouldBe(1);
            DB.Delete("Note", "Id", _note, _note.Id).ShouldBe(1);

            _person = DB.SingleOrDefault<Person>(_person.Id);
            _note = DB.SingleOrDefault<Note>(_note.Id);

            _person.ShouldBeNull();
            _note.ShouldBeNull();
        }
Ejemplo n.º 6
0
 public void ShouldBe(Note other)
 {
     Id.ShouldBe(other.Id);
     CreatedOn.ShouldBe(other.CreatedOn);
     Text.ShouldBe(other.Text);
 }