示例#1
0
        public void GetOneByCompanyName_WhenCompanyNameNotFound_ThrowCompanyNotFoundException()
        {
            // Arrange
            var companyName            = "company name";
            var notExistingCompanyName = "not a company name";
            var quotation = new Quotation
                            (
                companyName,
                123.45m,
                "USD"
                            );

            var nasdaqRepository = new Mock <INasdaqRepository>();

            nasdaqRepository.Setup(rep => rep.ReadQuotations(It.IsAny <string>()))
            .Returns(new[] { quotation });

            var sut = new QuotationService(nasdaqRepository.Object);

            // Act
            Action action = () => sut.GetOneByCompanyName(notExistingCompanyName);

            // Assert
            action.Should().Throw <CompanyNotFoundException>()
            .And.NotFoundCompanyName.Should().Be(notExistingCompanyName);
        }
示例#2
0
        public void GetOneByCompanyName_WhenExistingCompanyName_ReturnQuotation()
        {
            // Arrange
            var companyName = "company name";
            var quotation   = new Quotation
                              (
                companyName,
                123.45m,
                "USD"
                              );

            var nasdaqRepository = new Mock <INasdaqRepository>();

            nasdaqRepository.Setup(rep => rep.ReadQuotations(It.IsAny <string>()))
            .Returns(new[] { quotation });

            var sut = new QuotationService(nasdaqRepository.Object);

            // Act
            var actual = sut.GetOneByCompanyName(companyName);

            // Assert
            actual.Should().NotBeNull();
            actual.Should().BeEquivalentTo(quotation);
        }
示例#3
0
        public void GetOneByCompanyName_WhenCompanyNameIsEmpty_ThrowArgumentNullException()
        {
            // Arrange
            var sut = new QuotationService(null);

            // Act
            Action action = () => sut.GetOneByCompanyName(string.Empty);

            // Assert
            action.Should().Throw <ArgumentNullException>();
        }