public async Task <ActionResult <Payment> > Create([FromBody] AuthorisationRequest createRequest) { try { var errors = await ValidateRequest(createRequest); if (errors != null) { return(BadRequest(errors)); } var payment = new Payment { CreditCardDetails = createRequest.CreditCardData, TransactionDetails = createRequest.TransactionDetails, }; await _paymentService.CreatePayment(payment); return(CreatedAtAction(nameof(GetByPaymentId), new { paymentId = payment.Id }, payment)); } catch (PaymentGatewayServiceException pgse) { _logger.LogError("Caugh bad known error from repo"); return(UnprocessableEntity(pgse.Message)); } }
public override Task <AuthorisationReply> IsAuthorised(AuthorisationRequest request, ServerCallContext context) { return(Task.FromResult(new AuthorisationReply { IsAuthorised = false })); }
public int Login(AuthorisationRequest authorisationInfo) { string authprosation_json = JsonConvert.SerializeObject(authorisationInfo); Debug.Log("In Login in DataManager"); Debug.Log("Json : " + authprosation_json); return(0); }
public void Authorise_Always_CallsStopwatchStop() { //arrange var request = new AuthorisationRequest(); //act _decorator.Authorise(request); //assert _stopwatch.AssertWasCalled(s => s.Stop()); }
public void Authorise_Always_CallsDecoratedAuthorisationService() { //arrange var request = new AuthorisationRequest(); //act _decorator.Authorise(request); //assert _decoratee.AssertWasCalled(d => d.Authorise(request)); }
public void OnAuthorisationSend() { AuthorisationCanvasController authorisationCanvasController = canvasManager.GetAuthorisationCanvasController(); AuthorisationRequest authorisationInfo = authorisationCanvasController.GetAuthorisationInfo(); int res = dataManager.Login(authorisationInfo); if (res != 0) { } applicationView.OpenScreen(ScreenType.MainMenu); }
private async Task <string> ValidateRequest(AuthorisationRequest request) { var result = await _validator.ValidateAsync(request); if (result.IsValid) { return(null); } var validationErrors = JsonConvert.SerializeObject(result.Errors.Select(e => e.ErrorMessage)); _logger.LogDebug($"Validation Errors : {validationErrors}"); return(validationErrors); }
private AuthorisationGrant GetAuthorisationGrant() { AuthorisationRequest request = new AuthorisationRequest { Username = "******", Password = "******", Scope = new string[0], }; AuthorisationServiceBl authorisationService = new AuthorisationServiceBl(); AuthorisationGrant grant = authorisationService.GetAuthorisationCode(request); return(grant); }
public void Authorise_GivenARunOf3Timings_LogsAverageExecutionTime(int timing1, int timing2, int timing3, int expectedAverage) { //arrange var request = new AuthorisationRequest(); var expectedMessage = string.Format(_logMessageFormat, _applicationNow.ToString("o"), expectedAverage, "3"); _decorator = new LogAverageExecutionTimeDecorator<IAuthorisationService>(_decoratee, _stopwatch, _logger, _clock, 3); //act _stopwatch.Stub(s => s.ElapsedTime).Return(new TimeSpan(0, 0, 0, timing1)).Repeat.Once(); _decorator.Authorise(request); _stopwatch.Stub(s => s.ElapsedTime).Return(new TimeSpan(0, 0, 0, timing2)).Repeat.Once(); _decorator.Authorise(request); _stopwatch.Stub(s => s.ElapsedTime).Return(new TimeSpan(0, 0, 0, timing3)).Repeat.Once(); _decorator.Authorise(request); //assert _logger.AssertWasCalled(d => d.Log(expectedMessage)); }
public void Authorise_SampleSizeSupplied_CallsLoggerCorrectNumberOfTimes(int numberOfRequests, int sampleSize, int expectedNumberOfCallsToLogger) { //arrange _decorator = new LogAverageExecutionTimeDecorator<IAuthorisationService>(_decoratee, _stopwatch, _logger, _clock, sampleSize); var request = new AuthorisationRequest(); //act for (int x = 0; x < numberOfRequests; x++) { _decorator.Authorise(request); } //assert _logger.AssertWasCalled(l => l.Log(Arg<string>.Is.Anything), options => options.Repeat.Times(expectedNumberOfCallsToLogger)); }
public void Authorise_MultipleThreads_LogsExpectedNumberOfTimes() { //arrange var request = new AuthorisationRequest(); var expectedMessage = string.Format(_logMessageFormat, _applicationNow.ToString("o"), 1, 100); _stopwatch.Stub(s => s.ElapsedTime).Return(new TimeSpan(0, 0, 0, 0, 1)); _decorator = new LogAverageExecutionTimeDecorator<IAuthorisationService>(_decoratee, _stopwatch, _logger, _clock); var t1 = new Thread(() => { for (int x = 0; x <= MaxSampleSize; x++) { _decorator.Authorise(request); } }); var t2 = new Thread(() => { for (int x = 0; x <= MaxSampleSize; x++) { _decorator.Authorise(request); } }); var t3 = new Thread(() => { for (int x = 0; x <= MaxSampleSize; x++) { _decorator.Authorise(request); } }); //act t1.Start(); t2.Start(); t3.Start(); t1.Join(); t2.Join(); t3.Join(); //assert _logger.AssertWasCalled(l => l.Log(expectedMessage), options => options.Repeat.Times(60)); }
public void Authorise_InvokedOverSampleSize_ContinuesLogging() { //arrange var request = new AuthorisationRequest(); var expectedMessage = string.Format(_logMessageFormat, _applicationNow.ToString("o"), 1, MaxSampleSize); _stopwatch.Stub(s => s.ElapsedTime).Return(new TimeSpan(0, 0, 0, 0, 1)); _decorator = new LogAverageExecutionTimeDecorator<IAuthorisationService>(_decoratee, _stopwatch, _logger, _clock, MaxSampleSize); //act for (int x = 0; x <= MaxSampleSize*3; x++) { _decorator.Authorise(request); } //assert _logger.AssertWasCalled(l => l.Log(expectedMessage), options => options.Repeat.Times(3)); }
public void Authorise(AuthorisationRequest request) { Thread.Sleep(_randomNumberGenerator.Next(25)); }
public void Authorise(AuthorisationRequest request) { //Authorisation code }
public void OnNotification(Notification notification) { var res = 0; switch (notification) { case Notification.RegistrationChosen: applicationView.OpenScreen(ScreenType.RegistrationMenu); break; case Notification.RegistrationSend: RegistrationCanvasController registrationCanvasController = canvasManager.GetRegistrationCanvasController(); RegistrationRequest registrationInfo = registrationCanvasController.GetRegistrationInfo(); res = dataManager.Register(registrationInfo); if (res != 0) { } //var net_manager = AlphaSNetManager.GetInstance(); //https://localhost:5001/api/Participant //net_manager.SendGet("https://localhost:5001/api/Participant"); applicationView.OpenScreen(ScreenType.MainMenu); break; case Notification.AuthorisationChosen: applicationView.OpenScreen(ScreenType.AuthorisationMenu); break; case Notification.AuthorisationSend: AuthorisationCanvasController authorisationCanvasController = canvasManager.GetAuthorisationCanvasController(); AuthorisationRequest authorisationInfo = authorisationCanvasController.GetAuthorisationInfo(); res = dataManager.Login(authorisationInfo); if (res != 0) { } applicationView.OpenScreen(ScreenType.MainMenu); break; case Notification.MatchingStart: Debug.Log("Opening matching screen"); applicationView.OpenScreen(ScreenType.MatchingScreen); break; case Notification.BaseAlphaStart: applicationView.ShowErrorMessage("No base alpha (("); Debug.Log(":AOSDkfjs;dlfkjad;rlrk"); applicationView.OpenScreen(ScreenType.MainMenu); break; case Notification.GameStart: applicationView.OpenScreen(ScreenType.GameScreen); break; case Notification.MatchingFinish: applicationView.OpenScreen(ScreenType.MainMenu); break; case Notification.CloseError: applicationView.CloseErrorMessage(); break; default: break; } }