public void SaveTicketMustAddTicketInBase()
        {
            var ticketServiceTest = new TicketService();
            var newTicket         = new Ticket(300, "Test ticket", 1000);

            ticketServiceTest.SaveTicket(newTicket);

            var allTicketsAfterAddingNewTicket = ticketServiceTest.GetAllTickets();

            CollectionAssert.Contains(allTicketsAfterAddingNewTicket, newTicket);

            ticketServiceTest.DeleteTicket(newTicket);

            var allTicketsAfterDeletingNewTicket = ticketServiceTest.GetAllTickets();

            CollectionAssert.DoesNotContain(allTicketsAfterDeletingNewTicket, newTicket);
        }
Esempio n. 2
0
        public void SaveTicketMustAddTicketInBase()
        {
            var ticketServiceTest = new TicketService();
            var newTicket         = new Ticket(300, "Test ticket", 1000);

            ticketServiceTest.SaveTicket(newTicket);

            var allTicketsAfterAddingNewTicket = ticketServiceTest.GetAllTickets();

            NUnit.Framework.CollectionAssert.Contains(allTicketsAfterAddingNewTicket, newTicket);

            PrivateObject obj = new PrivateObject(ticketServiceTest);

            obj.Invoke("DeleteTicket", newTicket);

            var allTicketsAfterDeletingNewTicket = ticketServiceTest.GetAllTickets();

            NUnit.Framework.CollectionAssert.DoesNotContain(allTicketsAfterDeletingNewTicket, newTicket);
        }
        public void SaveTicketMustAddTicketInBase()
        {
            var ticketServiceTest = new TicketService();
            var newTicket         = new Ticket(300, "Test ticket", 1000);

            ticketServiceTest.SaveTicket(newTicket);

            var allTicketsAfterAddingNewTicket = ticketServiceTest.GetAllTickets();

            NUnit.Framework.CollectionAssert.Contains(allTicketsAfterAddingNewTicket, newTicket);

            // для тестирования методом Private Object метод DeleteTicket стал приватным и больше не виден здесь
            //ticketServiceTest.DeleteTicket(newTicket);
            // вместо него из фреймворка MSTest создаётся класс типа PrivateObject на основе ticketServiceTest
            PrivateObject obj = new PrivateObject(ticketServiceTest);

            obj.Invoke("DeleteTicket", newTicket);

            var allTicketsAfterDeletingNewTicket = ticketServiceTest.GetAllTickets();

            NUnit.Framework.CollectionAssert.DoesNotContain(allTicketsAfterDeletingNewTicket, newTicket);
        }
        public void GeTicketPriceMustReturnNotNullableTicket()
        {
            var ticketServiceTest = new TicketService();

            Assert.IsNotNull(ticketServiceTest.GetTicketPrice(1));
        }
        public void GeTicketPriceMustThrowException()
        {
            var ticketServiceTest = new TicketService();

            Assert.Throws <TicketNotFoundException>(() => ticketServiceTest.GetTicketPrice(100));
        }