public async Task ShouldGetEvents() { MockDiscoveryRequest(); MockLoginRequest(); var getEventsResponse = new GetEventsResponse { Events = _events }; _mockRestClient .Setup(x => x.GetAsync <GetEventsResponse>( It.IsAny <string>(), It.IsAny <Dictionary <string, string> >() )) .ReturnsAsync(getEventsResponse); var nubankClient = new Nubank(_mockRestClient.Object, "login", "password"); await nubankClient.LoginAsync(); var actualEvents = await nubankClient.GetEventsAsync(); Assert.Equal(_events, actualEvents); _mockRestClient.Verify(x => x.GetAsync <GetEventsResponse>( It.IsAny <string>(), It.IsAny <Dictionary <string, string> >() ), Times.Once()); }
static async Task Main() { Console.WriteLine("Nubank Client"); Console.WriteLine("Please, type your login (CPF):"); var login = Console.ReadLine().Trim(); Console.WriteLine("Type your password:"******"You must authenticate with your phone to be able to access your data."); Console.WriteLine("Scan the QRCode below with you Nubank application on the following menu:"); Console.WriteLine("Nu(Seu Nome) > Perfil > Acesso pelo site"); Console.WriteLine(); Console.WriteLine(result.GetQrCodeAsAscii()); Console.WriteLine($"Use your phone to scan and after this press any key to continue..."); Console.ReadKey(); await nubankClient.AutenticateWithQrCodeAsync(result.Code); } try { var savings = await nubankClient.GetSavingsAsync(); ConsoleTable .From(savings) .Write(Format.Alternative); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } var events = await nubankClient.GetEventsAsync(); ConsoleTable .From(events) .Write(Format.Alternative); Console.ReadKey(); }
public async Task ShouldThrowExceptionWhenLoginWasNotCalled() { MockDiscoveryRequest(); MockLoginRequest(); var getEventsResponse = new GetEventsResponse { Events = _events }; _mockRestClient .Setup(x => x.GetAsync <GetEventsResponse>( It.IsAny <string>(), It.IsAny <Dictionary <string, string> >() )) .ReturnsAsync(getEventsResponse); var nubankClient = new Nubank(_mockRestClient.Object, "login", "password"); var exception = await Assert.ThrowsAsync <InvalidOperationException>(() => nubankClient.GetEventsAsync()); }