Ejemplo n.º 1
0
        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.Login();

            var actualEvents = await nubankClient.GetEvents();

            Assert.Equal(_events, actualEvents);
            _mockRestClient.Verify(x => x.GetAsync <GetEventsResponse>(
                                       It.IsAny <string>(),
                                       It.IsAny <Dictionary <string, string> >()
                                       ), Times.Once());
        }
Ejemplo n.º 2
0
        static async Task Main(string[] args)
        {
            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.Write(result.GetQrCodeAsAscii());
                Console.WriteLine();
                Console.ReadKey();

                await nubankClient.AutenticateWithQrCode(result.Code);
            }
            var events = await nubankClient.GetEvents();

            ConsoleTable
            .From <Event>(events)
            .Write(Format.Alternative);

            Console.ReadKey();
        }
Ejemplo n.º 3
0
        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.GetEvents());
        }