public async Task AddEntityWithConflict() { // Arrange const long longValue = 555; const string stringValue = "555"; var entity = new Poco { LongValue = longValue, StringValue = stringValue }; await _repository.AddAsync(entity); Exception exception = null; // Act try { await _repository.AddAsync(entity); } catch (Exception e) { exception = e; } // Assert Assert.NotNull(exception); Assert.IsType<ConflictException>(exception); }
public async Task AddEntity() { // Arrange const long longValue = 555; const string stringValue = "555"; var entity = new Poco { LongValue = longValue, StringValue = stringValue }; // Act Poco result = await _repository.AddAsync(entity); // Assert Assert.Equal(longValue, result.LongValue); Assert.Equal(stringValue, result.StringValue); Assert.NotEqual(null, result.Id); }
public async Task DeleteEntityWithNotFound() { // Arrange const long longValue = 555; const string stringValue = "555"; var entity = new Poco { LongValue = longValue, StringValue = stringValue }; Exception exception = null; // Act try { await _repository.DeleteAsync(entity); } catch (Exception e) { exception = e; } // Assert Assert.NotNull(exception); Assert.IsType<NotFoundException>(exception); }