private void AuctioneerOnAuctionStarted(object sender, AuctionEventArgs auctionEventArgs)
 {
     try
     {
         AuctionsDataGrid.Dispatcher.Invoke(new Action(() => AuctionsDataGrid.Items.Refresh()));
     }
     catch (InvalidOperationException ioex)
     {
         Debug.WriteLine($"OnAuctionStarted: {ioex.Message}");
     }
 }
        public void Auction_WhenStarted_EventIsRaised()
        {
            var repo       = new InMemoryMainRepository();
            var auctioneer = new Auctioneer(repo);

            var auction = CreateAndStoreAuction(repo, DateTime.UtcNow.AddHours(-1), DateTime.UtcNow.AddHours(1));

            AuctionEventArgs raisedArgs = null;

            auctioneer.AuctionStarted += (sender, args) => raisedArgs = args;

            auctioneer.DoAllWork();

            Assert.NotNull(raisedArgs);
            Assert.NotNull(raisedArgs.Auction);
            Assert.AreEqual(auction, raisedArgs.Auction);
        }
        public void Auction_WhenEnded_EventIsRaised()
        {
            var repo       = new InMemoryMainRepository();
            var auctioneer = new Auctioneer(repo);

            var auction = CreateAndStoreAuction(repo, DateTime.UtcNow.AddHours(-1), DateTime.UtcNow.AddHours(1));

            AuctionEventArgs raisedArgs = null;

            auctioneer.AuctionEnded += (sender, args) => raisedArgs = args;

            // Turn back the time
            auction.EndDateTimeUtc = DateTime.UtcNow;

            auctioneer.DoAllWork();

            Assert.NotNull(raisedArgs);
            Assert.NotNull(raisedArgs.Auction);
            Assert.NotNull(raisedArgs.IsSuccessful);
        }
        public void AuctionStartedAndEndedInThePast_AuctioneerRuns_DontGetsStarted()
        {
            var repo       = new InMemoryMainRepository();
            var auctioneer = new Auctioneer(repo);

            AuctionEventArgs raisedArgs = null;

            auctioneer.AuctionStarted += (sender, args) => raisedArgs = args;

            var auction = CreateAndStoreAuction(repo, DateTime.UtcNow.AddHours(-2), DateTime.UtcNow.AddHours(-1));

            auction.IsRunning = false;
            auction.IsClosed  = true;

            auctioneer.DoAllWork();

            Assert.IsNull(raisedArgs);
            Assert.IsTrue(auction.IsClosed);
            Assert.IsFalse(auction.IsRunning);
        }
Exemple #5
0
 private void auctioneer_AuctionEnded(object sender, AuctionEventArgs auctionEventArgs)
 {
     this.loadAuctions();
 }
        private void AuctioneerOnAuctionClosed(object sender, AuctionEventArgs auctionEventArgs)
        {
            var allAuctionsFromService = this.auctionService.GetAll();

            this.Auctions = new ObservableCollection <Auction>(allAuctionsFromService);
        }
Exemple #7
0
 protected virtual void OnAuctionStarted(AuctionEventArgs e)
 {
     this.AuctionStarted?.Invoke(this, e);
 }