Ejemplo n.º 1
0
        public void ExecuteShould_ThrowArgumentExceptionIfParametersAreNotProvided()
        {
            var providerMock = new Mock <IPostgresDataProvider>();
            var writerMock   = new Mock <IWriter>();
            var command      = new BuyTicketsCommand(providerMock.Object, writerMock.Object);

            Assert.Throws <NullReferenceException>(() => command.Execute(null));
        }
Ejemplo n.º 2
0
        public void ExecuteShould_ClearTheScreenOneTIme()
        {
            var providerMock = new Mock <IPostgresDataProvider>();
            var writerMock   = new Mock <IWriter>();

            providerMock.Setup(p => p.Tickets.Find(It.IsAny <Expression <Func <Ticket, bool> > >())).Returns(new Ticket[] { It.IsAny <Ticket>() });

            var command = new BuyTicketsCommand(providerMock.Object, writerMock.Object);

            command.Execute(new List <string>()
            {
                "1"
            });

            writerMock.Verify(x => x.Clear(), Times.Once);
        }
Ejemplo n.º 3
0
        public void ExecuteShould_ReturnNoTicketsFoundIfIdDoesNotExistAndParameterIsProvided()
        {
            var ticketId     = "1";
            var providerMock = new Mock <IPostgresDataProvider>();
            var writerMock   = new Mock <IWriter>();

            providerMock.Setup(p => p.Tickets.Find(It.IsAny <Expression <Func <Ticket, bool> > >())).Returns(new Ticket[] { It.IsAny <Ticket>() });

            var command = new BuyTicketsCommand(providerMock.Object, writerMock.Object);

            string result = command.Execute(new List <string>()
            {
                ticketId
            });

            Assert.That(result.Contains($"Sorry no tickets with this Id: {ticketId} were found!"));
        }