public void TestMessagingResponsUnicodeEncodingUTF8()
        {
            var response = this.GetVoiceResponse(UNICODE_CHARS);

            var result = new TwilioController().TwiML(response, Encoding.UTF8);

            Assert.Contains(UNICODE_CHARS, result.Data.ToString());
        }
        public void TestMessagingResponseUnicodeEncodingASCII()
        {
            var response = this.GetMessagingResponse(ASCII_CHARS);

            var result = new TwilioController().TwiML(response, Encoding.UTF8);

            Assert.Contains(ASCII_CHARS, result.Data.ToString());
        }
        public void TestMessagingResponseDefaultEncodingPass()
        {
            var response = this.GetMessagingResponse(ASCII_CHARS);

            var result = new TwilioController().TwiML(response);

            Assert.Contains(ASCII_CHARS, result.Data.ToString());
        }
        public void TestVoiceResponseDefaultEncodingPass()
        {
            var response = GetVoiceResponse(TwiMLResultTests.UnicodeChars);

            var result = new TwilioController().TwiML(response);

            Assert.Contains(TwiMLResultTests.UnicodeChars, result.Data.ToString());
        }
示例#5
0
        public static void FireAllTerminalsClosedEvent(int merchantId)
        {
            var      merchant       = MongoDBContext.FindMerchantById(merchantId);
            DateTime xctPostingDate = DateTime.Today;

            var xctSummaryMsg = BuildSummaryMessage(merchantId, xctPostingDate);

            TwilioController.SendSMSMessage(merchant.primary_contact.phone_no, xctSummaryMsg);
        }
        public void TestMessagingResponseDefaultEncodingFail()
        {
            var response = this.GetMessagingResponse(UNICODE_CHARS);

            Assert.ThrowsAny <Exception>(() =>
            {
                var result = new TwilioController().TwiML(response);
            });
        }
示例#7
0
        public static void SendWelcomeMessage(int merchantId)
        {
            var merchant = MongoDBContext.FindMerchantById(merchantId);

            var welcomeMsg = BuildWelcomeMessage(merchant);
            var configMsg  = BuildConfigMessage(merchant.merchant_id);

            //TwilioController.SendSMSMessage(merchant.primary_contact.phone_no, $"{welcomeMsg}\n{configMsg}");
            TwilioController.SendSMSMessage(merchant.primary_contact.phone_no, $"{welcomeMsg}");
        }
示例#8
0
        public void Config_ReturnsTwilioConfig()
        {
            // Arrange
            var controller = new TwilioController(_ctrlOptions);

            // Act
            var result = controller.Config();

            // Assert
            Assert.Equal(result.Value, _appSettings);
        }
示例#9
0
        public static void FireClosedEventsForAllMerchants()
        {
            for (int merchantId = 1; merchantId <= 8; merchantId++)
            {
                var      merchant       = MongoDBContext.FindMerchantById(merchantId);
                DateTime xctPostingDate = DateTime.Today;

                var xctSummaryMsg = BuildSummaryMessage(merchantId, xctPostingDate);

                TwilioController.SendSMSMessage(merchant.primary_contact.phone_no, xctSummaryMsg);
            }
        }
        public void Get_WithParams_ReturnsValidDeauthroizeResult()
        {
            // ARRANGE
            mockTwilioService  = new Mock <ITwilioService>();
            mockStorageService = new Mock <IStorageService>();
            _sut = new TwilioController(mockTwilioService.Object, mockStorageService.Object);

            // ACT
            var result = _sut.Deauthorize() as NoContentResult;

            // ASSERT
            Assert.True(typeof(NoContentResult) == result.GetType());
        }
示例#11
0
        public void Token_ReturnsATokenAndIdentity()
        {
            // Arrange
            var controller = new TwilioController(_ctrlOptions);

            // Act
            var result      = controller.Token();
            var tokenResult = (Dictionary <string, string>)result.Value;

            // Assert
            Assert.True(tokenResult.ContainsKey("token"));
            Assert.True(tokenResult.ContainsKey("identity"));
        }
        public void Get_WithNoParams_ReturnsValidAuthorizeResult()
        {
            // ARRANGE
            var accountSid = "AC24504e9f04164744a970e26bb81cb2e8";

            mockTwilioService  = new Mock <ITwilioService>();
            mockStorageService = new Mock <IStorageService>();
            _sut = new TwilioController(mockTwilioService.Object, mockStorageService.Object);

            // ACT
            var result = _sut.Authorize(accountSid) as NoContentResult;

            // ASSERT
            Assert.True(typeof(NoContentResult) == result.GetType());
        }
示例#13
0
        static void DisplayMenu()
        {
            // display options menu
            ConsoleColor defaultColor = ConsoleColor.Gray;

            System.Console.ForegroundColor = defaultColor;

            System.Console.Clear();
            System.Console.ForegroundColor = ConsoleColor.Blue;
            System.Console.WriteLine("=============================================");
            System.Console.WriteLine("   Hackathon Test Methods");
            System.Console.WriteLine("=============================================");
            System.Console.ForegroundColor = defaultColor;
            System.Console.WriteLine();
            System.Console.ForegroundColor = ConsoleColor.Magenta;
            System.Console.WriteLine("=== SMS Test Messages =======================");
            System.Console.ForegroundColor = defaultColor;
            System.Console.WriteLine("1.1   Test Message to Tom's Phone");
            System.Console.WriteLine("");
            System.Console.ForegroundColor = ConsoleColor.Magenta;
            System.Console.WriteLine("=== Generate Xcts ===========================");
            System.Console.ForegroundColor = defaultColor;
            System.Console.WriteLine("2.1   Clear Xcts");
            System.Console.WriteLine("2.2   Generate Purchases");
            System.Console.WriteLine("2.3   Generate Returns");
            System.Console.WriteLine("2.4   Generate Chargebacks");
            System.Console.WriteLine("2.5   Fire All Terminals Closed Event");
            System.Console.WriteLine("2.6   Fire Closed Event for all Merchants");
            System.Console.WriteLine("");
            System.Console.ForegroundColor = ConsoleColor.Magenta;
            System.Console.WriteLine("=== Support ===========================");
            System.Console.ForegroundColor = defaultColor;
            System.Console.WriteLine("3.1   Load Merchant");
            System.Console.WriteLine("3.2   Load ALL Merchants");
            System.Console.WriteLine("3.3   Send Welcome Message");
            System.Console.WriteLine("");
            System.Console.WriteLine();
            System.Console.Write("Enter # or 0 to Exit");
            System.Console.ForegroundColor = ConsoleColor.Green;
            System.Console.Write(" > ");
            System.Console.ForegroundColor = defaultColor;
            var     selectionString = System.Console.ReadLine();
            decimal selection       = !string.IsNullOrEmpty(selectionString.Trim()) ? decimal.Parse(selectionString) : 0;

            int merchantId = 0;

            switch (selection)
            {
            case 1.1M:      // Test Message to Tom's Phone
                TwilioController.SendTestSMSMessage(GeneralConstants.TOMS_PHONE_NO);
                break;

            case 2.1M:      // Clear Purchaes for Merchant N
                System.Console.Write("MerchantId:> ");
                merchantId = Int32.Parse(System.Console.ReadLine());
                MerchantController.ResetAllXctsForMerchantDate(merchantId, DateTime.Today);
                break;

            case 2.2M:      // Purchases for Merchant N
                System.Console.Write("MerchantId:> ");
                merchantId = Int32.Parse(System.Console.ReadLine());
                MerchantController.GenerateRandomPurchaseXcts(merchantId);
                break;

            case 2.3M:      // Generate refunds
                System.Console.Write("MerchantId:> ");
                merchantId = Int32.Parse(System.Console.ReadLine());
                MerchantController.GenerateRefundXcts(merchantId);
                break;

            case 2.4M:      // Generate chargebacks
                System.Console.Write("MerchantId:> ");
                merchantId = Int32.Parse(System.Console.ReadLine());
                MerchantController.GenerateChargebacksXcts(merchantId);
                break;

            case 2.5M:      // Fire all terminals closed event
                System.Console.Write("MerchantId:> ");
                merchantId = Int32.Parse(System.Console.ReadLine());
                MerchantController.FireAllTerminalsClosedEvent(merchantId);
                break;

            case 2.6M:      // Fire all terminals closed event
                System.Console.Write("MerchantId:> ");
                merchantId = Int32.Parse(System.Console.ReadLine());
                MerchantController.FireClosedEventsForAllMerchants();
                break;

            case 3.1M:      // Create Merchant
                System.Console.Write("MerchantId:> ");
                merchantId = Int32.Parse(System.Console.ReadLine());
                MerchantController.CreateMerchant(merchantId);
                break;

            case 3.2M:      // Create All Merchants
                MerchantController.CreateAllMerchants();
                break;

            case 3.3M:      // Send Welcome Message
                System.Console.Write("MerchantId:> ");
                merchantId = Int32.Parse(System.Console.ReadLine());
                MerchantController.SendWelcomeMessage(merchantId);
                break;

            default:
                break;
            }

            if (selection != 0)
            {
                DisplayMenu();
            }
        }