Exemplo n.º 1
0
        public void GetAccountsAutonomousScope()
        {
            // Given
            RecognizedUserInfo recognizedUserInfo = RecognizedUserInfo.Current();
            IFluentClient      client             = AspenClient.Initialize()
                                                    .RoutingTo(this.autonomousAppInfoProvider)
                                                    .WithIdentity(this.autonomousAppInfoProvider)
                                                    .Authenticate()
                                                    .GetClient();

            // When
            List <IAccountInfo> accounts = client.Financial.GetAccounts(recognizedUserInfo.DocType, recognizedUserInfo.DocNumber).ToList();

            PrintOutput("Accounts", accounts);

            // Then
            Assert.That(accounts.Count(), NUnit.Framework.Is.EqualTo(1));
            List <AccountProperty> properties = accounts.First().Properties.ToList();

            Assert.That(properties.Count(), NUnit.Framework.Is.EqualTo(4));
            Assert.That(properties.SingleOrDefault(p => p.Key == "LastTranName"), NUnit.Framework.Is.Not.Null);
            Assert.That(properties.SingleOrDefault(p => p.Key == "LastTranDate"), NUnit.Framework.Is.Not.Null);
            Assert.That(properties.SingleOrDefault(p => p.Key == "LastTranCardAcceptor"), NUnit.Framework.Is.Not.Null);
            Assert.That(properties.SingleOrDefault(p => p.Key == "CardStatusName"), NUnit.Framework.Is.Not.Null);
        }
Exemplo n.º 2
0
        public void GetStatementsAutonomousScope()
        {
            // Given
            RecognizedUserInfo recognizedUserInfo = RecognizedUserInfo.Current();
            IFluentClient      client             = AspenClient.Initialize()
                                                    .RoutingTo(this.autonomousAppInfoProvider)
                                                    .WithIdentity(this.autonomousAppInfoProvider)
                                                    .Authenticate()
                                                    .GetClient();

            // When
            var statements = client.Financial.GetStatements(recognizedUserInfo.DocType, recognizedUserInfo.DocNumber, recognizedUserInfo.AccountId).ToList();

            PrintOutput("Statements", statements);

            // Then
            Assert.That(statements.Count(), NUnit.Framework.Is.EqualTo(5));
            const string AccountTypesPattern = "^80|81|82|83|84|85$";

            foreach (var statement in statements)
            {
                Assert.That(statement.AccountTypeId, NUnit.Framework.Is.Not.Null.And.Match(AccountTypesPattern));
                Assert.That(statement.Amount, NUnit.Framework.Is.AssignableTo(typeof(decimal)));
                Assert.That(statement.CardAcceptor, NUnit.Framework.Is.Not.Null);
                Assert.That(statement.TranName, NUnit.Framework.Is.Not.Null);
                Assert.That(statement.TranType, NUnit.Framework.Is.Not.Null);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Obtiene la información del usuario configurado en el ambiente.
        /// </summary>
        /// <returns>Instancia de <see cref="RecognizedUserInfo"/> a partir de la información en el ambiente.</returns>
        /// <exception cref="InvalidOperationException">Missing environment variable Aspen:RecognizedUserInfo</exception>
        public static RecognizedUserInfo Current()
        {
            if (current != null)
            {
                return(current);
            }

            string     userInfo  = Environment.GetEnvironmentVariable("Aspen:RecognizedUserInfo");
            const char Separator = '|';

            if (string.IsNullOrWhiteSpace(userInfo))
            {
                throw new InvalidOperationException("Missing info for Aspen:RecognizedUserInfo");
            }

            string[] values = userInfo.Split(Separator);

            current = new RecognizedUserInfo()
            {
                DocType   = values[0],
                DocNumber = values?[1],
                AccountId = values?[2]
            };

            return(current);
        }
Exemplo n.º 4
0
        public void GetBalancesAutonomousScope()
        {
            // Given
            RecognizedUserInfo recognizedUserInfo = RecognizedUserInfo.Current();
            IFluentClient      client             = AspenClient.Initialize()
                                                    .RoutingTo(this.autonomousAppInfoProvider)
                                                    .WithIdentity(this.autonomousAppInfoProvider)
                                                    .Authenticate()
                                                    .GetClient();

            // When
            List <IBalanceInfo> balances = client.Financial.GetBalances(recognizedUserInfo.DocType, recognizedUserInfo.DocNumber, recognizedUserInfo.AccountId).ToList();

            // Then
            Assert.That(balances.Count(), NUnit.Framework.Is.EqualTo(5));
        }
Exemplo n.º 5
0
        public void GetBalancesDelegatedScope()
        {
            // Given
            RecognizedUserInfo recognizedUserInfo = RecognizedUserInfo.Current();
            DelegatedUserInfo  userCredentials    = GetDelegatedUserCredentials();
            IFluentClient      client             = AspenClient.Initialize(AppScope.Delegated)
                                                    .RoutingTo(this.delegatedAppInfoProvider)
                                                    .WithIdentity(this.delegatedAppInfoProvider)
                                                    .Authenticate(userCredentials)
                                                    .GetClient();

            // When
            List <IBalanceInfo> balances = client.Financial.GetBalances(recognizedUserInfo.AccountId).ToList();

            // Then
            Assert.That(balances.Count(), NUnit.Framework.Is.EqualTo(5));
        }