public void GetBuildProjectBySpecificationId_WhenSpeficationIdIsInValidFormat_ShouldReturnResult() { // Arrange ICalculationsApiClient mockApi = Substitute.For <ICalculationsApiClient>(); mockApi .GetBuildProjectBySpecificationId(Arg.Any <string>()) .Returns(new ApiResponse <Common.ApiClient.Calcs.Models.BuildProject>(HttpStatusCode.OK, new Common.ApiClient.Calcs.Models.BuildProject())); CalculationsRepository calculationsRepository = new CalculationsRepository(mockApi, CreateMapper()); // Act var configuredTaskAwaiter = calculationsRepository.GetBuildProjectBySpecificationId("Test").ConfigureAwait(false).GetAwaiter(); BuildProject buildProject = configuredTaskAwaiter.GetResult(); // Assert buildProject.Should().NotBeNull(); mockApi.Received(1).GetBuildProjectBySpecificationId(Arg.Any <string>()); }
public void GetBuildProjectBySpecificationId_WhenSpeficationIdIsEmpty_ShouldThrowException() { // Arrange ICalculationsApiClient apiClientProxy = Substitute.For <ICalculationsApiClient>(); CalculationsRepository calculationsRepository = new CalculationsRepository(apiClientProxy, CreateMapper()); ArgumentNullException exception = null; // Act try { var configuredTaskAwaiter = calculationsRepository.GetBuildProjectBySpecificationId(string.Empty).ConfigureAwait(false).GetAwaiter(); configuredTaskAwaiter.GetResult(); } catch (Exception e) { exception = e as ArgumentNullException; } // Assert exception.Should().NotBeNull(); exception.Should().BeOfType <ArgumentNullException>(); apiClientProxy.DidNotReceive().GetBuildProjectBySpecificationId(Arg.Any <string>()); }