public async Task AddAsync_Returns_None_When_Agency_Name_Is_Null(Agency agency) { // Arrange agency.Name = null; // Act var result = await _agenciesService.AddAsync(agency); // Assert result.HasValue.ShouldBe(false); result.MatchNone(error => error .Messages .ShouldAllBe(msg => msg == "Agency name cannot be empty!")); }
public async Task AddAsync_Returns_None_If_Connection_To_Database_Is_Lost(Agency agency) { // Arrange var wrongConnectionString = "Server=x;Database=y;" + "Integrated Security=True;" + "Trusted_Connection=True;" + "MultipleActiveResultSets=true;"; _agenciesService = new AgenciesService( _mapperMock.Object, DbContextProvider.GetSqlServerDbContext(wrongConnectionString)); // Act var result = await _agenciesService.AddAsync(agency); // Assert result.HasValue.ShouldBe(false); result.MatchNone(error => error .Messages .ShouldAllBe(msg => msg == "An unhandled exception has occurred while creating the agency : " + "A network-related or instance-specific error occurred while " + "establishing a connection to SQL Server. " + "The server was not found or was not accessible. " + "Verify that the instance name is correct and that SQL Server " + "is configured to allow remote connections. " + "(provider: Named Pipes Provider, error: 40 - " + "Could not open a connection to SQL Server)!")); }