Exemple #1
0
        public void Test_Api_NumberTextConvertedController_GetCurrencyWordConversion_When_ZeroValue_provided()
        {
            // Arrange
            NumberTextConverterController controller = new NumberTextConverterController();
            double testValue      = 0;
            string expectedString = "ZERO DOLLARS";
            string resultString   = string.Empty;

            // Act
            var result = controller.Get(testValue);

            resultString = result.Content.ReadAsStringAsync().Result;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
            Assert.IsInstanceOfType(result.Content, typeof(StringContent));
            Assert.AreEqual(expectedString, resultString);
        }
Exemple #2
0
        public void Test_Api_NumberTextConvertedController_GetCurrencyWordConversion_When_SixteenDigitValue_provided()
        {
            // Arrange
            NumberTextConverterController controller = new NumberTextConverterController();
            double testValue      = 1234567890123456;
            string expectedString = "Too big number. This function supports a value upto 15 digits.";
            string resultString   = string.Empty;

            // Act
            var result = controller.Get(testValue);

            resultString = result.Content.ReadAsStringAsync().Result;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(HttpStatusCode.BadRequest, result.StatusCode);
            Assert.IsInstanceOfType(result.Content, typeof(StringContent));
            Assert.AreEqual(expectedString, resultString);
        }
Exemple #3
0
        public void Test_Api_NumberTextConvertedController_GetCurrencyWordConversion_When_EightDigitValue_provided()
        {
            // Arrange
            NumberTextConverterController controller = new NumberTextConverterController();
            double testValue      = 12345678;
            string expectedString = "TWELVE MILLION THREE HUNDRED FOURTY FIVE THOUSAND SIX HUNDRED SEVENTY EIGHT DOLLARS";
            string resultString   = string.Empty;

            // Act
            var result = controller.Get(testValue);

            resultString = result.Content.ReadAsStringAsync().Result;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
            Assert.IsInstanceOfType(result.Content, typeof(StringContent));
            Assert.AreEqual(expectedString, resultString);
        }
Exemple #4
0
        public void Test_Api_NumberTextConvertedController_GetCurrencyWordConversion_When_FifteenDigitValue_provided()
        {
            // Arrange
            NumberTextConverterController controller = new NumberTextConverterController();
            double testValue      = 123456789012345;
            string expectedString = "ONE HUNDRED TWENTY THREE TRILLION FOUR HUNDRED FIFTY SIX BILLION SEVEN HUNDRED EIGHTY NINE MILLION ONE THOUSAND TWO THOUSAND THREE HUNDRED FOURTY FIVE DOLLARS";
            string resultString   = string.Empty;

            // Act
            var result = controller.Get(testValue);

            resultString = result.Content.ReadAsStringAsync().Result;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
            Assert.IsInstanceOfType(result.Content, typeof(StringContent));
            Assert.AreEqual(expectedString, resultString);
        }
Exemple #5
0
        public void Test_Api_NumberTextConvertedController_GetCurrencyWordConversion_When_InvalidValue_provided()
        {
            // Arrange
            NumberTextConverterController controller = new NumberTextConverterController();
            double testValue      = double.NaN;
            string expectedString = "Currency value is empty or invalid.\r\nParameter name: numericValue";
            string resultString   = string.Empty;

            // Act
            var result = controller.Get(testValue);

            resultString = result.Content.ReadAsStringAsync().Result;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(HttpStatusCode.BadRequest, result.StatusCode);
            Assert.IsInstanceOfType(result.Content, typeof(StringContent));
            Assert.AreEqual(expectedString, resultString);
        }