Ejemplo n.º 1
0
        public void TestNullKeyGet()
        {
            ICache cache = new VelocityClient();

            cache.Put("nunit", "value");
            Thread.Sleep(100);
            object item = cache.Get(null);

            Assert.ShouldNotBeNull(item);
        }
Ejemplo n.º 2
0
        public async Task PerformAnalysisAsync_ForValidCreditCard_ReturnsAuthorized(VelocityClient sut, BraspagAuthClient authClient)
        {
            var authRequest = new AccessTokenRequest
            {
                GrantType    = OAuthGrantType.ClientCredentials,
                ClientId     = "5d85902e-592a-44a9-80bb-bdda74d51bce",
                ClientSecret = "mddRzd6FqXujNLygC/KxOfhOiVhlUr2kjKPsOoYHwhQ=",
                Scope        = "VelocityApp"
            };

            var authResponse = await authClient.CreateAccessTokenAsync(authRequest);

            Assert.Equal(HttpStatusCode.OK, authResponse.HttpStatus);

            var request = new AnalysisRequest
            {
                Transaction = new TransactionData
                {
                    OrderId = DateTime.Now.Ticks.ToString(),
                    Date    = "2018-09-15 13:30:00.860",
                    Amount  = 1000
                },
                Card = new CardData
                {
                    Holder     = "BJORN IRONSIDE",
                    Brand      = "visa",
                    Number     = "1000100010001000",
                    Expiration = "10/2025"
                },
                Customer = new CustomerData
                {
                    Name      = "Bjorn Ironside",
                    Identity  = "762.502.520-96",
                    IpAddress = "127.0.0.1",
                    Email     = "*****@*****.**"
                }
            };

            var response = await sut.PerformAnalysisAsync(request, new MerchantCredentials { AccessToken = authResponse.Token, MerchantId = "94E5EA52-79B0-7DBA-1867-BE7B081EDD97" });

            Assert.Equal(HttpStatusCode.Created, response.HttpStatus);
        }
        public static void Run()
        {
            Console.WriteLine("VELOCITY");
            Console.WriteLine("=====================================");

            /* Criação do Token de Acesso OAUTH via Braspag Auth */
            var braspagAuthClient = new BraspagAuthClient(new BraspagAuthClientOptions
            {
                Environment = Environment.Sandbox
            });

            var authRequest = new AccessTokenRequest
            {
                GrantType    = OAuthGrantType.ClientCredentials,
                ClientId     = "5d85902e-592a-44a9-80bb-bdda74d51bce",
                ClientSecret = "mddRzd6FqXujNLygC/KxOfhOiVhlUr2kjKPsOoYHwhQ=",
                Scope        = "VelocityApp"
            };

            var authResponse = braspagAuthClient.CreateAccessTokenAsync(authRequest).Result;

            /* Criação do Cliente Velocity */
            var velocityClient = new VelocityClient(new VelocityClientOptions
            {
                Environment = Environment.Sandbox,
                Credentials = new MerchantCredentials
                {
                    MerchantId  = "94E5EA52-79B0-7DBA-1867-BE7B081EDD97",
                    AccessToken = authResponse.Token
                }
            });

            /* Analisando uma transação com Velocity */
            var analysisResponse = PerformAnalysisAsync(velocityClient).Result;

            Console.WriteLine("Transaction analyzed");
            Console.WriteLine($"Score: {analysisResponse.AnalysisResult.Score}");
            Console.WriteLine($"Status: {analysisResponse.AnalysisResult.Status}");
            Console.WriteLine($"Accept By WhiteList: {analysisResponse.AnalysisResult.AcceptByWhiteList}");
            Console.WriteLine($"Reject By BlackList: {analysisResponse.AnalysisResult.RejectByBlackList}");
            Console.WriteLine();
        }
Ejemplo n.º 4
0
        public void TestNullKeyRemove()
        {
            ICache cache = new VelocityClient();

            cache.Remove(null);
        }
Ejemplo n.º 5
0
        public void TestNullValuePut()
        {
            ICache cache = new VelocityClient();

            Assert.Throws <ArgumentNullException>(() => cache.Put("nunit", null));
        }
Ejemplo n.º 6
0
        public void TestNullValuePut()
        {
            ICache cache = new VelocityClient();

            cache.Put("nunit", null);
        }
Ejemplo n.º 7
0
 public void TestEmptyProperties()
 {
     ICache cache = new VelocityClient("nunit", new Dictionary<string, string>());
     Assert.IsNotNull(cache);
 }
Ejemplo n.º 8
0
        public void TestEmptyProperties()
        {
            ICache cache = new VelocityClient("nunit", new Dictionary <string, string>());

            Assert.IsNotNull(cache);
        }
Ejemplo n.º 9
0
        public void TestNullKeyPut()
        {
            ICache cache = new VelocityClient();

            cache.Put(null, null);
        }
Ejemplo n.º 10
0
        public void TestDefaultConstructor()
        {
            ICache cache = new VelocityClient();

            Assert.IsNotNull(cache);
        }
Ejemplo n.º 11
0
        public void TestNoPropertiesConstructor()
        {
            ICache cache = new VelocityClient("nunit");

            Assert.IsNotNull(cache);
        }
Ejemplo n.º 12
0
        public void TestNullKeyRemove()
        {
            ICache cache = new VelocityClient();

            Assert.Throws <ArgumentNullException>(() => cache.Remove(null));
        }
Ejemplo n.º 13
0
 public void TestDefaultConstructor()
 {
     ICache cache = new VelocityClient();
     Assert.IsNotNull(cache);
 }
        public async Task PerformAnalysisAsync_ForValidCreditCard_ReturnsAuthorized(VelocityClient sut, BraspagAuthClient authClient)
        {
            var authRequest = new AccessTokenRequest
            {
                GrantType    = OAuthGrantType.ClientCredentials,
                ClientId     = "5d85902e-592a-44a9-80bb-bdda74d51bce",
                ClientSecret = "mddRzd6FqXujNLygC/KxOfhOiVhlUr2kjKPsOoYHwhQ=",
                Scope        = "VelocityApp"
            };

            var authResponse = await authClient.CreateAccessTokenAsync(authRequest);

            Assert.Equal(HttpStatusCode.OK, authResponse.HttpStatus);

            var request = new AnalysisRequest
            {
                Transaction = new TransactionData
                {
                    OrderId = DateTime.Now.Ticks.ToString(),
                    Date    = DateTime.UtcNow.ToString("O"),
                    Amount  = 1000
                },
                Card = new CardData
                {
                    Holder     = "BJORN IRONSIDE",
                    Brand      = "visa",
                    Number     = "1000100010001000",
                    Expiration = "10/2025"
                },
                Customer = new CustomerData
                {
                    Name      = "Bjorn Ironside",
                    Identity  = "76250252096",
                    IpAddress = "127.0.0.1",
                    Email     = "*****@*****.**",
                    BirthDate = "1982-06-30",
                    Phones    = new List <PhoneData>
                    {
                        new PhoneData
                        {
                            Type   = "Cellphone",
                            Number = "999999999",
                            Ddi    = "55",
                            Ddd    = "11"
                        }
                    },
                    Billing = new AddressData
                    {
                        Street       = "Alameda Xingu",
                        Number       = "512",
                        Neighborhood = "Alphaville",
                        City         = "Barueri",
                        State        = "SP",
                        Country      = "BR",
                        ZipCode      = "06455-030"
                    }
                }
            };

            var response = await sut.PerformAnalysisAsync(request, new MerchantCredentials { AccessToken = authResponse.Token, MerchantId = "94E5EA52-79B0-7DBA-1867-BE7B081EDD97" });

            Assert.Equal(HttpStatusCode.Created, response.HttpStatus);
            Assert.NotNull(response.AnalysisResult);
            Assert.NotNull(response.Transaction);
            Assert.NotNull(response.RequestId);
            Assert.Null(response.ErrorDataCollection);
        }
Ejemplo n.º 15
0
 public void TestNullValuePut()
 {
     ICache cache = new VelocityClient();
     Assert.Throws<ArgumentNullException>(() => cache.Put("nunit", null));
 }
Ejemplo n.º 16
0
 public void TestNullKeyRemove()
 {
     ICache cache = new VelocityClient();
     Assert.Throws<ArgumentNullException>(() => cache.Remove(null));
 }
Ejemplo n.º 17
0
 public void TestNullKeyGet()
 {
     ICache cache = new VelocityClient();
     cache.Put("nunit", "value");
     Thread.Sleep(1000);
     object item = cache.Get(null);
     Assert.IsNull(item);
 }
Ejemplo n.º 18
0
 public void TestNoPropertiesConstructor()
 {
     ICache cache = new VelocityClient("nunit");
     Assert.IsNotNull(cache);
 }