Exemple #1
0
        public void ConvertCurrenyWords_PositiveTest4()
        {
            // Arrange
            var expectedOutput = "Twelve Thousand Four Hundred Eleven Dollars and Ten Cents Only";
            IConvertRepository convertRepository = new ConvertRepository();
            var model = new ConvertWordsModel()
            {
                Currency = 12411.10m, Name = "John Smith"
            };

            // Act
            string result = convertRepository.ConvertCurrenyWords(model.Currency);

            //Assert
            Assert.AreEqual(expectedOutput, result);
        }
Exemple #2
0
        public void ConvertCurrenyWords_PositiveTest5()
        {
            // Arrange
            var expectedOutput = "Eighteen Thousand Four Hundred Seventeen Dollars and Sixteen Cents Only";
            IConvertRepository convertRepository = new ConvertRepository();
            var model = new ConvertWordsModel()
            {
                Currency = 18417.16m, Name = "John Smith"
            };

            // Act
            string result = convertRepository.ConvertCurrenyWords(model.Currency);

            //Assert
            Assert.AreEqual(expectedOutput, result);
        }
Exemple #3
0
        public void ConvertCurrenyWords_PositiveTest3()
        {
            // Arrange
            var expectedOutput = "One Hundred Seventy One Thousand Four Hundred Thirteen Dollars and Fifteen Cents Only";
            IConvertRepository convertRepository = new ConvertRepository();
            var model = new ConvertWordsModel()
            {
                Currency = 171413.15m, Name = "John Smith"
            };

            // Act
            string result = convertRepository.ConvertCurrenyWords(model.Currency);

            //Assert
            Assert.AreEqual(expectedOutput, result);
        }
Exemple #4
0
        public void ConvertCurrenyWords_PositiveTest2()
        {
            // Arrange
            var expectedOutput = "Nine Million Six Hundred Seventy Eight Thousand Five Hundred Fourty Nine Dollars and Twenty Four Cents Only";
            IConvertRepository convertRepository = new ConvertRepository();
            var model = new ConvertWordsModel()
            {
                Currency = 9678549.24m, Name = "John Smith"
            };

            // Act
            string result = convertRepository.ConvertCurrenyWords(model.Currency);

            //Assert
            Assert.AreEqual(expectedOutput, result);
        }
Exemple #5
0
        public void ConvertCurrenyWords_PositiveTest()
        {
            // Arrange
            var expectedOutput = "One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Six Dollars and Ninety Eight Cents Only";
            IConvertRepository convertRepository = new ConvertRepository();
            var model = new ConvertWordsModel()
            {
                Currency = 1234566.98m, Name = "John Smith"
            };

            // Act
            string result = convertRepository.ConvertCurrenyWords(model.Currency);

            //Assert
            Assert.AreEqual(expectedOutput, result);
        }
Exemple #6
0
        public void ConvertCurrenyWords_PositiveTest6()
        {
            // Arrange
            var expectedOutput = "Four Billion Five Hundred Sixty Five Million Six Hundred Eighteen Thousand Four Hundred Fourteen Dollars and Nineteen Cents Only";
            IConvertRepository convertRepository = new ConvertRepository();
            var model = new ConvertWordsModel()
            {
                Currency = 4565618414.19m, Name = "John Smith"
            };

            // Act
            string result = convertRepository.ConvertCurrenyWords(model.Currency);

            //Assert
            Assert.AreEqual(expectedOutput, result);
        }
 public IHttpActionResult ConvertWords([FromBody] ConvertWordsModel model)
 {
     try
     {
         return(Ok(new ConvertWordsResult()
         {
             Success = true,
             Name = model.Name,
             CurrencyWords = _convertRepository.ConvertCurrenyWords(model.Currency)
         }));
     }
     catch (Exception ex)
     {
         return(Ok(new ConvertWordsResult()
         {
             Success = false,
             ErrorMessage = ex.Message
         }));
     }
 }
        public void ConvertWord_Negative_Test()
        {
            //Arrange
            Mock <IConvertRepository> mockRepository = new Mock <IConvertRepository>();

            mockRepository.Setup(m => m.ConvertCurrenyWords(It.IsAny <decimal>()))
            .Throws(new Exception());
            ConvertController controller = new ConvertController(mockRepository.Object);
            var model = new ConvertWordsModel()
            {
                Currency = 12345.98m, Name = "John Smith"
            };

            // Act
            IHttpActionResult result = controller.ConvertWords(model) as IHttpActionResult;
            var contentResult        = result as OkNegotiatedContentResult <ConvertWordsResult>;

            //Assert
            Assert.AreEqual(false, contentResult != null && contentResult.Content.Success);
            Assert.AreEqual(null, contentResult.Content.CurrencyWords);
        }
        public void ConvertWord_Positive_Test()
        {
            //Arrange
            var expectedOutput = "One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Six Dollars and Ninety Eight Cents Only";
            Mock <IConvertRepository> mockRepository = new Mock <IConvertRepository>();

            mockRepository.Setup(m => m.ConvertCurrenyWords(It.IsAny <decimal>()))
            .Returns(expectedOutput);
            ConvertController controller = new ConvertController(mockRepository.Object);
            var model = new ConvertWordsModel()
            {
                Currency = 1234566.98m, Name = "John Smith"
            };

            // Act
            IHttpActionResult result = controller.ConvertWords(model) as IHttpActionResult;
            var contentResult        = result as OkNegotiatedContentResult <ConvertWordsResult>;

            //Assert
            Assert.AreEqual(true, contentResult != null && contentResult.Content.Success);
            Assert.AreEqual(expectedOutput, contentResult.Content.CurrencyWords);
        }