Exemplo n.º 1
0
        public void Add(TicketScanModel ticketScan)
        {
            if (_ticketScans.Count == MaxSize)
            {
                _ticketScans.Dequeue();
            }

            _ticketScans.Enqueue(ticketScan);
        }
        public async Task Handle_TicketScanValueResult_EventPublished()
        {
            // Arrange
            var identifier       = "09__blOoQm72n8Bf";
            var ticketScanResult = new TicketScanResult(true, "Benjamin Rich Swift");
            var ticketScanModel  = new TicketScanModel(identifier, new SeatModel(5, 'D'));
            var notification     = new TicketScanResultNotification(identifier, ticketScanResult);

            _ticketRepository.Setup(callTo => callTo.Find(identifier)).Returns(ticketScanModel);

            // Act
            await _ticketScanRelayer.Handle(notification, default);

            // Assert
            _eventAggregator.Verify(callTo => callTo.Publish(It.Is <TicketScanUpdated>(message => message.Identifier.Equals(identifier))), Times.Once);
        }
        public void RetrieveTicketScan_TicketScanExists_ResultIsSet()
        {
            // Arrange
            var identifier = "09__blOoQm72n8Bf";
            var ticketScan = new TicketScanModel(identifier, new SeatModel {
                Number = 1, Letter = 'C'
            });

            _ticketScans.Add(ticketScan);

            // Act
            _detailsViewModel.RetrieveTicketScan(identifier);

            // Assert
            Assert.That(_detailsViewModel.Result, Is.EqualTo(ticketScan));
        }
        public void RetrieveTicketScan_StatusStarted_MessageDetailNull()
        {
            // Arrange
            var identifier = "09__blOoQm72n8Bf";
            var ticketScan = new TicketScanModel(identifier, new SeatModel {
                Number = 1, Letter = 'C'
            });

            _ticketScans.Add(ticketScan);

            // Act
            _detailsViewModel.RetrieveTicketScan(identifier);

            // Assert
            Assert.That(_detailsViewModel.MessageDetail, Is.Null);
        }
        public void RetrieveTicketScan_StatusCompletedOwnsTicket_MessageDetailSetToName()
        {
            // Arrange
            var identifier = "09__blOoQm72n8Bf";
            var ticketScan = new TicketScanModel(identifier, new SeatModel {
                Number = 1, Letter = 'C'
            });
            var name = "Benjamin Rich Swift";

            ticketScan.SetScanResult(true, name);
            _ticketScans.Add(ticketScan);

            // Act
            _detailsViewModel.RetrieveTicketScan(identifier);

            // Assert
            Assert.That(_detailsViewModel.MessageDetail, Is.EqualTo(name));
        }
        public void RetrieveTicketScan_TicketScanStatusStarted_TicketScanUpdatedEventRaisesOnPropertyChanged()
        {
            // Arrange
            var eventRaised = false;
            var identifier  = "09__blOoQm72n8Bf";
            var ticketScan  = new TicketScanModel(identifier, new SeatModel {
                Number = 1, Letter = 'C'
            });

            _ticketScans.Add(ticketScan);
            _detailsViewModel.RetrieveTicketScan(identifier);

            _detailsViewModel.OnPropertyChanged += (s, e) => { eventRaised = true; };

            // Act
            _eventAggregator.Publish(new TicketScanUpdated(identifier));

            // Assert
            Assert.That(eventRaised, Is.True);

            _detailsViewModel.OnPropertyChanged -= (s, e) => { eventRaised = true; };
        }