public void GetBuildProjectBySpecificationId_WhenSpeficationIdIsInValidFormat_ShouldReturnResult() { // Arrange ICalcsApiClientProxy mockApi = Substitute.For <ICalcsApiClientProxy>(); mockApi .GetAsync <BuildProject>(Arg.Any <string>()) .Returns(new BuildProject()); CalculationsRepository calculationsRepository = new CalculationsRepository(mockApi); ArgumentNullException exception = null; // Act var configuredTaskAwaiter = calculationsRepository.GetBuildProjectBySpecificationId("Test").ConfigureAwait(false).GetAwaiter(); BuildProject buildProject = configuredTaskAwaiter.GetResult(); // Assert buildProject.Should().NotBeNull(); mockApi.Received(1).GetAsync <BuildProject>(Arg.Any <string>()); }
public void GetBuildProjectBySpecificationId_WhenSpeficationIdIsEmpty_ShouldThrowException() { // Arrange ICalcsApiClientProxy apiClientProxy = Substitute.For <ICalcsApiClientProxy>(); CalculationsRepository calculationsRepository = new CalculationsRepository(apiClientProxy); 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().GetAsync <BuildProject>(Arg.Any <string>()); }