Пример #1
0
        public void Login_ValidCredentials_Authenticated()
        {
            var target = new BuxferClient ();
            target.Login ("*****@*****.**", "");

            Assert.IsTrue (target.Authenticated);
        }
Пример #2
0
        public void Login_InvalidCredentials_Exception()
        {
            var target = new BuxferClient ();

            ExceptionAssert.IsThrowing (new BuxferException ("Email or username does not match an existing account."), () => {
                target.Login ("*****@*****.**", "dohdoh");
            });
        }
Пример #3
0
        private static async Task <RawTransaction> LoadByTagAndId(BuxferClient target, int id, string tag)
        {
            var loadedTransactions = await target.GetRawTransactions(f => f.TagName = tag);

            var loadedTransaction = loadedTransactions.Entities.Should()
                                    .Contain(t => t.Id == id).Subject;

            return(loadedTransaction);
        }
Пример #4
0
        private static async Task <T> Load <T>(BuxferClient target, int id, string tag)
        {
            var loadedTransactions = await target.GetTransactions(f => f.TagName = tag);

            var loadedTransaction = loadedTransactions.Entities.Should()
                                    .Contain(t => t.Id == id).Subject;

            return(loadedTransaction.Should().BeOfType <T>().Subject);
        }
Пример #5
0
        public void Authenticator_InvalidCredentials_Exception()
        {
            var logger = LoggerFactory.Create(c => c.AddConsole()).CreateLogger <AuthTest>();
            var target = new BuxferClient("*****@*****.**", "bk", logger);

            Assert.ThrowsAsync(Is.TypeOf <BuxferException>()
                               .And.Message.Contain("Email or username does not match an existing account."),
                               async() => { await target.GetTransactions(); });
        }
Пример #6
0
        public void Login_InvalidCredentials_Exception()
        {
            var logger = LoggerFactory.Create(c => c.AddConsole()).CreateLogger <AuthTest>();
            var target = new BuxferClient("*****@*****.**", "dohdoh", logger);

            Assert.ThrowsAsync(Is.TypeOf <BuxferException>()
                               .And.Message.Contain("Email or username does not match an existing account."),
                               async() => await target.Login()
                               );
        }
Пример #7
0
        public async Task Login_ValidCredentials_Authenticated_And_returns_Token()
        {
            var logger = LoggerFactory.Create(c => c.AddConsole()).CreateLogger <AuthTest>();

            var target = new BuxferClient("*****@*****.**", SecretManager.LoadSettings().Password, logger);
            var token  = await target.Login();

            Console.WriteLine($"token is {token}");
            Assert.NotNull(token);
            Assert.IsTrue(target.Authenticated);
        }
Пример #8
0
        public async Task Login_withAPITokenWorks()
        {
            var logger = LoggerFactory.Create(c => c.AddConsole()).CreateLogger <AuthTest>();

            var apiToken = SecretManager.LoadSettings().APIToken;
            var target   = new BuxferClient(apiToken, logger);
            var token    = await target.Login();

            token.Should().Be(apiToken);

            Assert.IsTrue(target.Authenticated);
        }