コード例 #1
0
        public void ReservingTicket()
        {
            var UoW = new Mock <UnitOfWork>();

            UoW.Object.DeleteDB();

            var UserLogic      = new UserLogic(UoW.Object);
            var TransportLogic = new TransportLogic(UoW.Object);

            UserLogic.AddUser(new BLL.DTOs.UserDTO("Liza", BLL.DTOs.UserType.User, "Bril", "Login", "Password"));
            TransportLogic.AddTransport(new BLL.DTOs.TransportDTO("Bus", "Kyiv", DateTimeOffset.Parse("22.10.18 11:15"), "Krakow", DateTimeOffset.Parse("22.10.18 23:45")), 30, 150);

            UserLogic.ReserveTicket(1, 1, 1);

            var User = UserLogic.GetAllUsers().First(u => u.Id == 1);

            //Assert.That(User.TransportTickets.Count == 1);
            //Assert.That(User.TransportTickets[0].TransportType == "Bus");
            //Assert.That(User.TransportTickets[0].PassangerName == "Liza");
            //Assert.That(User.TransportTickets[0].PassangerSurname == "Bril");
            //Assert.That(User.TransportTickets[0].NumberOfSeat == 1);
            //Assert.That(User.TransportTickets[0].DeparturePoint == "Kyiv");
            //Assert.That(User.TransportTickets[0].DepartureTime == DateTimeOffset.Parse("22.10.18 11:15"));
            //Assert.That(User.TransportTickets[0].ArrivalPoint == "Krakow");
            //Assert.That(User.TransportTickets[0].ArrivalTime == DateTimeOffset.Parse("22.10.18 23:45"));
            //Assert.That(User.TransportTickets[0].Price == 150);

            Assert.That(TransportLogic.GetAllTransport().First(t => t.Id == 1).TransportPlaces.First(r => r.Id == 1).IsBooked);
            Assert.Throws <AlreadyBookedItemException>(delegate { UserLogic.ReserveTicket(1, 1, 1); });
        }
コード例 #2
0
        public void AddingTransport()
        {
            var UoW = new Mock <UnitOfWork>();

            UoW.Object.DeleteDB();

            var TransportLogic = new TransportLogic(UoW.Object);
            var UserLogic      = new UserLogic(UoW.Object);

            UserLogic.AddUser(new BLL.DTOs.UserDTO("Liza", BLL.DTOs.UserType.Manager, "Bril", "Login", "Password"));
            UserLogic.Login("Login", "Password");

            TransportLogic.AddTransport(new BLL.DTOs.TransportDTO("Bus", "Kyiv", DateTimeOffset.Parse("22.10.18 11:15"), "Krakow", DateTimeOffset.Parse("22.10.18 23:45")), 30, 150);

            var Transport = TransportLogic.GetAllTransport().ToList()[0];

            Assert.That(TransportLogic.GetAllTransport().Count() == 1);
            Assert.That(Transport.Type == "Bus");
            Assert.That(Transport.DeparturePoint == "Kyiv");
            Assert.That(Transport.DepartureTime == DateTimeOffset.Parse("22.10.18 11:15"));
            Assert.That(Transport.ArrivalPoint == "Krakow");
            Assert.That(Transport.ArrivalTime == DateTimeOffset.Parse("22.10.18 23:45"));
            Assert.That(Transport.TransportPlaces.Count == 30);
            Assert.That(Transport.TransportPlaces[0].Number == 1);
            Assert.That(Transport.TransportPlaces[0].Price == 150);
            Assert.That(Transport.TransportPlaces[0].Transport.Id == Transport.Id);
        }
コード例 #3
0
        public void AddingTransport()
        {
            var UoW = new Mock <UnitOfWork>();

            UoW.Object.DeleteDB();

            var TransportLogic = new TransportLogic(UoW.Object);
            var UserLogic      = new UserLogic(UoW.Object);

            UserLogic.AddUser(new Logic.DTOs.UserDTO("Dimon", Logic.DTOs.UserType.Manager, "Cherneckii", "Login", "Password"));
            UserLogic.Login("Login", "Password");

            TransportLogic.AddTransport(new Logic.DTOs.TransportDTO("Bus", "Kyiv", DateTimeOffset.Parse("21.12.15 21:15"), "odessacity", DateTimeOffset.Parse("22.12.15 9:15")), 30, 150);

            var Transport = TransportLogic.GetAllTransport().ToList()[0];

            Assert.That(TransportLogic.GetAllTransport().Count() == 1);
            Assert.That(Transport.Type == "Bus");
            Assert.That(Transport.DeparturePoint == "Kyiv");
            Assert.That(Transport.DepartureTime == DateTimeOffset.Parse("21.12.15 21:15"));
            Assert.That(Transport.ArrivalPoint == "odessacity");
            Assert.That(Transport.ArrivalTime == DateTimeOffset.Parse("22.12.15 9:15"));
            Assert.That(Transport.TransportPlaces.Count == 30);
            Assert.That(Transport.TransportPlaces[0].Number == 1);
            Assert.That(Transport.TransportPlaces[0].Price == 150);
            Assert.That(Transport.TransportPlaces[0].Transport.Id == Transport.Id);
        }
コード例 #4
0
        public ActionResult Add(Transport transport)
        {
            ResponseMsg response = new ResponseMsg();

            TransportLogic.AddTransport(transport);
            response.IsSuccess = true;
            return(Json(response));
        }
コード例 #5
0
        public void DeletingTransport()
        {
            var UoW = new Mock <UnitOfWork>();

            UoW.Object.DeleteDB();

            var TransportLogic = new TransportLogic(UoW.Object);
            var UserLogic      = new UserLogic(UoW.Object);

            UserLogic.AddUser(new BLL.DTOs.UserDTO("Liza", BLL.DTOs.UserType.Manager, "Bril", "Login", "Password"));
            UserLogic.Login("Login", "Password");

            TransportLogic.AddTransport(new BLL.DTOs.TransportDTO("Bus", "Kyiv", DateTimeOffset.Parse("22.10.18 11:15"), "Krakow", DateTimeOffset.Parse("22.10.18 23:45")), 30, 150);
            var Transport = TransportLogic.GetAllTransport().ToList()[0];

            Assert.That(TransportLogic.GetAllTransport().Count() == 1);

            TransportLogic.DeleteTransport(1);

            Assert.That(TransportLogic.GetAllTransport().Count() == 0);
        }
コード例 #6
0
        public void DeletingTransport()
        {
            var UoW = new Mock <UnitOfWork>();

            UoW.Object.DeleteDB();

            var TransportLogic = new TransportLogic(UoW.Object);
            var UserLogic      = new UserLogic(UoW.Object);

            UserLogic.AddUser(new Logic.DTOs.UserDTO("Sasha", Logic.DTOs.UserType.Manager, "Veklych", "Login", "Password"));
            UserLogic.Login("Login", "Password");

            TransportLogic.AddTransport(new Logic.DTOs.TransportDTO("Bus", "Kyiv", DateTimeOffset.Parse("21.12.15 21:15"), "Hust", DateTimeOffset.Parse("22.12.15 9:15")), 30, 150);

            var Transport = TransportLogic.GetAllTransport().ToList()[0];

            Assert.That(TransportLogic.GetAllTransport().Count() == 1);

            TransportLogic.DeleteTransport(1);

            Assert.That(TransportLogic.GetAllTransport().Count() == 0);
        }