public void AddOrUpdate(Context context) { if (context.IsNew()) { _contextRepository.Add(context); } else { _contextRepository.Update(context); } }
public void Then_expected_methods_are_called_the_correct_times() { _sut.Add(_foo); Assert.Multiple(() => { _contextService.Received(_expectedContextManageCount).InitContext(); _contextService.Received(_expectedContextManageCount).ClearCurrentContext(); _dbSet.Received(1).AddAsync(_foo); _flushService.Received(1).FlushChangesAsync(_context); }); }
public void When_adding_a_null_entity_Then_an_exception_is_thrown() { Assert.That(() => _sut.Add(null), Throws.ArgumentNullException); }