Beispiel #1
0
        public void GetNonExistentMarkdownReturnsZero()
        {
            Mock <IDataAccessor <Markdown> > mockMarkdownDataAccessor = new Mock <IDataAccessor <Markdown> >();

            mockMarkdownDataAccessor.Setup(x => x.GetAmountByProductName(nonExistentMarkdownWithExistingPrice.ProductName))
            .Returns(0);

            MarkdownController markdownController = new MarkdownController(mockMarkdownDataAccessor.Object);

            string productName = "Bananas";

            var result        = markdownController.GetMarkdown(productName);
            var contentResult = result as ActionResult <float>;

            Assert.AreEqual(contentResult.Value, 0);
        }
Beispiel #2
0
        public void GetExistentMarkdownReturnsMarkdown()
        {
            Mock <IDataAccessor <Markdown> > mockMarkdownDataAccessor = new Mock <IDataAccessor <Markdown> >();

            mockMarkdownDataAccessor.Setup(x => x.GetAmountByProductName(validMarkdown.ProductName))
            .Returns(validMarkdown.Amount);

            MarkdownController markdownController = new MarkdownController(mockMarkdownDataAccessor.Object);

            string productName = "Can of soup";

            var result        = markdownController.GetMarkdown(productName);
            var contentResult = result as ActionResult <float>;

            Assert.AreEqual(contentResult.Value, 0.45f);
        }