Beispiel #1
0
        public async Task CanCancelBidByOrder()
        {
            Product cancelProductBid = new Product();

            cancelProductBid.Name = "CanCancelBidByOrder";
            cancelProductBid.AvailableEndDateTimeUtc = DateTime.Now.AddDays(5);
            cancelProductBid.ProductType             = ProductType.Auction;
            cancelProductBid.HighestBid    = 10;
            cancelProductBid.HighestBidder = "H";
            _productRepository.Insert(cancelProductBid);

            var productService = new Mock <IProductService>();

            productService.Setup(x => x.GetProductById(cancelProductBid.Id, false)).ReturnsAsync(cancelProductBid);
            var _cancelproductService = productService.Object;
            var _cancelauctionService = new AuctionService(_bidRepository, _cancelproductService, _productRepository, _cacheManager, _eventPublisher);

            Bid bid = new Bid();

            bid.Amount    = 1;
            bid.OrderId   = "o";
            bid.ProductId = cancelProductBid.Id;
            _bidRepository.Insert(bid);
            await _cancelauctionService.CancelBidByOrder("o");

            var found = await _cancelauctionService.GetBidsByProductId("CanCancelBidByOrder");

            var product = _productRepository.Table.Where(x => x.Name == "CanCancelBidByOrder").FirstOrDefault();

            Assert.AreEqual(0, found.Count);
            Assert.AreEqual(0, product.HighestBid);
            Assert.AreEqual("", product.HighestBidder);
            Assert.AreEqual(false, product.AuctionEnded);
        }