public ActionResult <List <Quotation> > GetAll()
 {
     try
     {
         _logger.LogDebug("Fetching all quotations");
         List <Quotation> quotes = _quotationService.GetAll();
         if (quotes != null)
         {
             _logger.LogDebug("Quotation Fetch Operation Successful");
             return(Ok(quotes));
         }
         else
         {
             _logger.LogDebug("Quotation Fetch Operation Failed. No Invoices Found.");
             return(Conflict("No Invoices Found"));
         }
     }
     catch (Exception ex)
     {
         //Log error
         _logger.LogError("An Exception occured: {ex}", ex.Message);
         _logger.LogError("Stack Trace: {ex}", ex.StackTrace);
         return(BadRequest(ex));
     }
 }
Esempio n. 2
0
        public void GetAll_ReturnsEmptyEnumerations()
        {
            // Arrange
            Quotation[] quotations = { };

            var nasdaqRepository = new Mock <INasdaqRepository>();

            nasdaqRepository.Setup(rep => rep.ReadQuotations(It.IsAny <string>()))
            .Returns(quotations);

            var sut = new QuotationService(nasdaqRepository.Object);

            // Act
            var actual = sut.GetAll();

            // Assert
            actual.Should().BeEmpty()
            .And.NotBeNull();
        }
Esempio n. 3
0
        public void GetAll_ReturnsEnumerationOfQuotations()
        {
            // Arrange
            Quotation[] quotations =
            {
                new Quotation
                (
                    "Company 1",
                    123.45m,
                    "USD"
                ),
                new Quotation
                (
                    "Company 2",
                    67.8m,
                    "EUR"
                ),
                new Quotation
                (
                    "Company 3",
                    999m,
                    "USD"
                )
            };

            var nasdaqRepository = new Mock <INasdaqRepository>();

            nasdaqRepository.Setup(rep => rep.ReadQuotations(It.IsAny <string>()))
            .Returns(quotations);

            var sut = new QuotationService(nasdaqRepository.Object);

            // Act
            var actual = sut.GetAll();

            // Assert
            actual.Should().NotBeEmpty()
            .And.HaveSameCount(quotations)
            .And.BeEquivalentTo(quotations)
            .And.ContainItemsAssignableTo <Quotation>();
        }