public void DeleteById_ItDeletesTheRecordWithoutReadIt([Values("sqlserver", "sqlite")] string databaseEngine) { using (var dataContext = this.BuildDataContext(databaseEngine)) { Assert.AreEqual(TENANT_ID, dataContext.TenantId, "Wrong data context tenant id."); //insert dataContext.MockDeletableEntityRepository.Insert(new MockDeletableEntity { //Id = 1, Name = "Name" }); dataContext.Save(); MockDeletableEntity mockDeletableEntity = dataContext.MockDeletableEntityRepository.FindOneBy(x => x.Name == "Name"); Assert.IsNotNull(mockDeletableEntity, "Entity is null."); //delete dataContext.MockDeletableEntityRepository.DeleteById(mockDeletableEntity.Id); dataContext.Save(); mockDeletableEntity = dataContext.MockDeletableEntityRepository.FindOneBy(x => x.Name == "Name"); Assert.IsNull(mockDeletableEntity, "Entity is not null."); dataContext.Rollback(); } }
public void IsDeleted_MustHandleItInAutomaticAndHiddenWay([Values("sqlserver", "sqlite")] string databaseEngine) { using (var dataContext = this.BuildDataContext(databaseEngine)) { Assert.AreEqual(TENANT_ID, dataContext.TenantId, "Wrong data context tenant id."); //insert dataContext.MockDeletableEntityRepository.Insert(new MockDeletableEntity { //Id = 1, IsDeleted = true, Name = "Name" }); dataContext.Save(); MockDeletableEntity mockDeletableEntity = dataContext.MockDeletableEntityRepository.FindOneBy(x => x.Name == "Name"); Assert.IsNull(mockDeletableEntity, "Entity is not null."); //update mockDeletableEntity = dataContext.MockDeletableEntityRepository.FindOneBy(x => x.Name == "Name" && x.IsDeleted == true, false, true); mockDeletableEntity.Name = "NAME"; mockDeletableEntity.IsDeleted = false; dataContext.MockDeletableEntityRepository.Update(mockDeletableEntity); dataContext.Save(); mockDeletableEntity = dataContext.MockDeletableEntityRepository.FindManyBy(x => x.Name == "NAME").FirstOrDefault(); Assert.IsNotNull(mockDeletableEntity, "Entity is null."); Assert.AreEqual("NAME", mockDeletableEntity.Name, "Wrong name."); dataContext.Rollback(); } }