Ejemplo n.º 1
0
        public void BooksPrice_ReturnsResult_Test()
        {
            string[] names = new string[] { "name" };
            _store.Setup(x => x.Buy(names)).Returns(It.IsAny <double>);

            var result = _service.BooksPrice(names);

            Assert.IsNotNull(result);
        }
        public IHttpActionResult GetPrice([FromUri] string[] bookNames)
        {
            double result = 0;

            try
            {
                result = _bookStoreService.BooksPrice(bookNames);
            }
            catch (NotEnoughInventoryException neix)
            {
                return(BadRequest($"Invalid shopping cart.Could not calculate price.See errors below.{neix.Message}"));
            }
            return(Ok(result));
        }
Ejemplo n.º 3
0
        public void BookStoreService_WhenBuy_ReturnsExpectedresult(string[] books, double expectedResult)
        {
            double result = _bookStoreService.BooksPrice(books);

            Assert.IsTrue(result == expectedResult);
        }