Skip to content

Commit 02760fc

Browse files
NinjaRocksclaude
andcommitted
Fix null check in refactored Persist methods
Added null checks for entity/viewmodel parameters before accessing their Id property in the Persist methods. This fixes test failures where ArgumentNullException was expected but NullReferenceException was thrown instead. Fixes: - EfEntityStore.Persist: Added null check before calling PersistCore - EfViewModelStore.Persist: Added null check before calling PersistCore Test Results: - All 129 tests now pass (92 Core + 37 EF) - Fixed: Persist_NullEntity_ThrowsArgumentNullException - Fixed: Persist_NullViewModel_ThrowsArgumentNullException 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent cc222ae commit 02760fc

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/SourceFlow.Net.EntityFramework/Stores/EfEntityStore.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public async Task<TEntity> Get<TEntity>(int id) where TEntity : class, IEntity
3535

3636
public async Task<TEntity> Persist<TEntity>(TEntity entity) where TEntity : class, IEntity
3737
{
38+
if (entity == null)
39+
throw new ArgumentNullException(nameof(entity));
40+
3841
return await PersistCore(
3942
entity,
4043
entity.Id,

src/SourceFlow.Net.EntityFramework/Stores/EfViewModelStore.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public async Task<TViewModel> Get<TViewModel>(int id) where TViewModel : class,
3636

3737
public async Task<TViewModel> Persist<TViewModel>(TViewModel model) where TViewModel : class, IViewModel
3838
{
39+
if (model == null)
40+
throw new ArgumentNullException(nameof(model));
41+
3942
return await PersistCore(
4043
model,
4144
model.Id,

0 commit comments

Comments
 (0)