private static int SaveKeyValue(string outputFile, TokenResponse accessToken) { try { var contents = new StringBuilder(); foreach (var prop in accessToken.GetType().GetProperties()) { if (prop.GetValue(accessToken) == null) { contents.AppendLine($"{ prop.Name }="); continue; } if (prop.PropertyType == typeof(DateTime)) { contents.AppendLine($"{prop.Name}={((DateTime)prop.GetValue(accessToken)).ToString("yyyy-MM-dd HH:mm:ss")}"); } else { contents.AppendLine($"{prop.Name}={prop.GetValue(accessToken)}"); } } File.WriteAllText(outputFile, contents.ToString()); return(-1); } catch (Exception ex) { Console.Error.WriteLine($"Error while saving the output file:\r\n { ex.Message }"); return(-1); } }
public void CardExecute_MustReturnOk() { var address = new Address() { Number = "13", State = "CX", City = "Puebla", Street = "Desconocida", ZipCode = "73310", Country = "MEX", Apartment = "123" }; var result = req.Cards.Create(new Token() { Card = new Card() { Address = address, CardNumber = "341192111079623", SecurityCode = "4375", HolderName = "Pancho Lopez", ExpYear = "19", ExpMonth = "03" }, MiddleName = "Lopez", FirstName = "Pancho", LastName = "Perez", Email = "*****@*****.**", Phone = "5527251902" }); Type a = result.GetType(); var b = new Error(); var x = new TokenResponse(); bool validateErrorType = result.GetType() == b.GetType(); bool validateDuplicatedToken = ((Error)result).Description.ToLower().Contains("card is already tokenized"); //If error but Assert.IsTrue((validateErrorType && validateDuplicatedToken) || result.GetType() == x.GetType()); }