public void getTemporaryAuthTokenThrowsPinAuthenticationException_pollinForTemporaryAuthToken_throwsPinAuthException() { //ARRANGE var mockedAuthService = new Mock <IAuthenticationService>(); mockedAuthService.Setup(auth => auth.GetTemporaryAuthTokenAsync(It.IsAny <string>())).Throws(exepctedPinAuthenticationException); var sut = new TempAuthTokenPoller(mockedAuthService.Object); //ACT Func <Task> pollForTemporaryAuthTokenFunction = async() => await sut.poll(_pinCode, 1, 0); //ASSERT pollForTemporaryAuthTokenFunction.ShouldThrow <PinAuthenticationException>(); }
public void getTemporaryAuthTokenReturnsTheToken_pollingForTemporaryAuthToken_returnTemporaryAuthToken() { //ARRANGE var mockedAuthenticationService = new Mock <IAuthenticationService>(); mockedAuthenticationService.Setup(auth => auth.GetTemporaryAuthTokenAsync(It.IsAny <string>())).ReturnsAsync(_tempAuthToken); var sut = new TempAuthTokenPoller(mockedAuthenticationService.Object); //ACT var tempAuthToken = sut.poll(_pinCode, 1, 0).Result; //ASSERT tempAuthToken.Should().BeAssignableTo <string>().And .BeSameAs(_tempAuthToken); }
public void getTemporaryAuthTokenThrowsExceptionsTillReachMaxNumberOfAttempts_pollingForTempAuthToken_returnsPinAuthenticationException() { //ARRANGE var mockedAuthenticationService = new Mock <IAuthenticationService>(); mockedAuthenticationService.SetupSequence(auth => auth.GetTemporaryAuthTokenAsync(It.IsAny <string>())) .Throws(exepctedPinAuthenticationException) .Throws(exepctedPinAuthenticationException) .Throws(exepctedPinAuthenticationException); var sut = new TempAuthTokenPoller(mockedAuthenticationService.Object); //ACT Func <Task> pollForTemporaryAuthTokenFunction = async() => await sut.poll(_pinCode, 3, 0); //ASSERT pollForTemporaryAuthTokenFunction.ShouldThrow <PinAuthenticationException>(); //TODO: return another exception }