Пример #1
0
        public void GetBestQuoteWithAvailableVolume_NoQuotesFound()
        {
            var repository = new Mock <IRepository>();

            repository.Setup(x => x.GetAllAvailableBySymbol(It.IsAny <string>())).Returns(new List <IQuote>());

            var sut = new QuoteManagerClass(repository.Object);
            var res = sut.GetBestQuoteWithAvailableVolume("ABC");

            Assert.AreEqual(null, res);
        }
Пример #2
0
        public void AddOrUpdateQuote_QuoteDoesNotExist()
        {
            var repository = new Mock <IRepository>();
            var quote      = new Mock <IQuote>();

            var sut = new QuoteManagerClass(repository.Object);

            sut.AddOrUpdateQuote(quote.Object);
            repository.Verify(x => x.Contains(It.IsAny <Guid>()));
            repository.Verify(x => x.Add(It.IsAny <IQuote>()));
        }
Пример #3
0
        public void ExecuteTrade_NoAvailableQuotes()
        {
            var repository = new Mock <IRepository>();

            repository.Setup(x => x.GetAllAvailableBySymbol(It.IsAny <string>())).Returns(new List <IQuote>());

            var sut = new QuoteManagerClass(repository.Object);
            var res = sut.ExecuteTrade("DEF", 1000);

            Assert.AreEqual(null, res);
        }
Пример #4
0
        public void GetBestQuoteWithAvailableVolume_ReturnLowestPrice()
        {
            var repository = new Mock <IRepository>();

            repository.Setup(x => x.GetAllAvailableBySymbol(It.IsAny <string>())).Returns(quotes);

            var sut = new QuoteManagerClass(repository.Object);
            var res = sut.GetBestQuoteWithAvailableVolume("ABC");

            Assert.AreEqual(quote3.Symbol, res.Symbol);
            Assert.AreEqual(quote3.Price, res.Price);
            Assert.AreEqual(quote3.Id, res.Id);
        }
Пример #5
0
        public void AddOrUpdateQuote_QuoteExists()
        {
            var repository = new Mock <IRepository>();
            var quote      = new Mock <IQuote>();

            repository.Setup(x => x.Contains(It.IsAny <Guid>())).Returns(true);

            var sut = new QuoteManagerClass(repository.Object);

            sut.AddOrUpdateQuote(quote.Object);
            repository.Verify(x => x.Contains(It.IsAny <Guid>()));
            repository.Verify(x => x.Update(It.IsAny <IQuote>()));
        }
Пример #6
0
        public void ExecuteTrade_DidNotReachRequestedVolume()
        {
            var repository = new Mock <IRepository>();

            repository.Setup(x => x.GetAllAvailableBySymbol(It.IsAny <string>())).Returns(quotes);

            var sut = new QuoteManagerClass(repository.Object);
            var res = sut.ExecuteTrade("DEF", 5000);

            Assert.AreEqual(res.VolumeExecuted, (uint)4200);
            Assert.AreEqual(res.VolumeRequested, (uint)5000);
            Assert.AreEqual(res.Symbol, "DEF");
            Assert.AreEqual(res.VolumeWeightedAveragePrice, 9.583333333333334);
        }