public async Task AddClient_ShouldAddCreatedOnDate_WhenClientSaved() { // Arrange // Act using (var context = new AppDbContext(_dbContextOptions)) { var service = new ClientsDataService(context); var result = await service.AddClient(new Client { CreatedOn = DateTime.MinValue }); // Assert result.CreatedOn.Should().NotBe(DateTime.MinValue); } }
public void AddClient_ShouldThrowArgumentNullException_WhenClientIsNull() { // Arrange // Act using (var context = new AppDbContext(_dbContextOptions)) { var service = new ClientsDataService(context); Func <Task> action = async() => await service.AddClient(null); // Assert action.Should().Throw <ArgumentNullException>(); } }
public async Task AddClient_ShouldBlankClientId_WhenClientIdProvided() { // Arrange const int clientId = 999; // Act using (var context = new AppDbContext(_dbContextOptions)) { var service = new ClientsDataService(context); var result = await service.AddClient(new Client { ClientId = clientId }); // Assert result.ClientId.Should().NotBe(clientId); } }
public async Task AddClient_ShouldReturnAddedClient_WhenClientSaved() { // Arrange const string expectedClientName = "name"; // Act using (var context = new AppDbContext(_dbContextOptions)) { var service = new ClientsDataService(context); var result = await service.AddClient(new Client { Name = expectedClientName }); // Assert result.Name.Should().Be(expectedClientName); } }