コード例 #1
0
        public void FindPrefix_NoMatchingSymbols_ReturnsEmptyList()
        {
            var companyInfoProvider = new CompanyInfoProvider(this.testData);
            var result = companyInfoProvider.FindPrefix("Z");

            Assert.Empty(result);
        }
コード例 #2
0
        public void FindPrefix_EmptyPrefix_ReturnsAll()
        {
            var companyInfoProvider = new CompanyInfoProvider(this.testData);
            var result = companyInfoProvider.FindPrefix("");

            Assert.Equal(this.testData, result);
        }
コード例 #3
0
        public void FindPrefix_OnlyOneSymbolMatchesExactly_ReturnsMatchedSymbol()
        {
            var companyInfoProvider = new CompanyInfoProvider(this.testData);
            var result         = companyInfoProvider.FindPrefix("B");
            var expectedResult = new List <SymbolDescription> {
                new SymbolDescription {
                    Symbol = "B"
                }
            };

            Assert.Equal(expectedResult, result);
        }
コード例 #4
0
        public void FindPrefix_NonzeroOffset_ReturnsAllMatchingSymbolsAfterOffset()
        {
            var companyInfoProvider = new CompanyInfoProvider(this.testData);
            var result         = companyInfoProvider.FindPrefix("AA", offset: 2);
            var expectedResult = new List <SymbolDescription>
            {
                new SymbolDescription {
                    Symbol = "AAZ"
                },
            };

            Assert.Equal(expectedResult, result);
        }
コード例 #5
0
        public void FindPrefix_NonzeroCount_ReturnsCountOfMatchingSymbols()
        {
            var companyInfoProvider = new CompanyInfoProvider(this.testData);
            var result         = companyInfoProvider.FindPrefix("AA", 2);
            var expectedResult = new List <SymbolDescription>
            {
                new SymbolDescription {
                    Symbol = "AA"
                },
                new SymbolDescription {
                    Symbol = "AAA"
                },
            };

            Assert.Equal(expectedResult, result);
        }
コード例 #6
0
        public void FindPrefix_PrefixMatchingMultipleSymbols_ReturnsAllMatchingSymbols()
        {
            var companyInfoProvider = new CompanyInfoProvider(this.testData);
            var result         = companyInfoProvider.FindPrefix("AA");
            var expectedResult = new List <SymbolDescription>
            {
                new SymbolDescription {
                    Symbol = "AA"
                },
                new SymbolDescription {
                    Symbol = "AAA"
                },
                new SymbolDescription {
                    Symbol = "AAZ"
                },
            };

            Assert.Equal(expectedResult, result);
        }
コード例 #7
0
        public void FindPrefix_OffsetIsOutOfRange_Throws()
        {
            var companyInfoProvider = new CompanyInfoProvider(this.testData);

            Assert.Throws <ArgumentOutOfRangeException>(() => companyInfoProvider.FindPrefix("A", offset: -1));
        }
コード例 #8
0
        public void FindPrefix_CountIsOutOfRange_Throws(int count)
        {
            var companyInfoProvider = new CompanyInfoProvider(this.testData);

            Assert.Throws <ArgumentOutOfRangeException>(() => companyInfoProvider.FindPrefix("A", count));
        }
コード例 #9
0
        public void FindPrefix_PrefixIsNull_Throws()
        {
            var companyInfoProvider = new CompanyInfoProvider(this.testData);

            Assert.Throws <ArgumentNullException>(() => companyInfoProvider.FindPrefix(null));
        }
コード例 #10
0
 public ValuesController(IStockProvider stockProvider, CompanyInfoProvider companyInfoProvider, IDistributedCache cache)
 {
     this.stockProvider       = stockProvider ?? throw new System.ArgumentNullException(nameof(stockProvider));
     this.companyInfoProvider = companyInfoProvider ?? throw new System.ArgumentNullException(nameof(companyInfoProvider));
     this.cache = cache ?? throw new System.ArgumentNullException(nameof(cache));
 }
コード例 #11
0
ファイル: UpdateParser.cs プロジェクト: davidmarek/stocksbot
 public UpdateParser(ITelegramBot telegramBot, IStockProvider stockProvider, CompanyInfoProvider companyInfoProvider)
 {
     this.telegramBot         = telegramBot ?? throw new ArgumentNullException(nameof(telegramBot));
     this.stockProvider       = stockProvider ?? throw new ArgumentNullException(nameof(stockProvider));
     this.companyInfoProvider = companyInfoProvider ?? throw new ArgumentNullException(nameof(companyInfoProvider));
 }