public void TestSetUp() { var connection = @"Server=DESKTOP-DMYTRO\SQLEXPRESS;Initial Catalog=Academy;Trusted_Connection=True;ConnectRetryCount=0"; DbContextOptionsBuilder <MyContext> t = new DbContextOptionsBuilder <MyContext>(); t.UseSqlServer(connection); mc = new MyContext(t.Options); CrewRepository crewRepository = new CrewRepository(mc); PilotRepository pilotRepository = new PilotRepository(mc); StewardessRepository stewardessRepository = new StewardessRepository(mc); FlightRepository flightRepository = new FlightRepository(mc); TicketRepository ticketRepository = new TicketRepository(mc); TakeOffRepository takeOffRepository = new TakeOffRepository(mc); PlaneRepository planeRepository = new PlaneRepository(mc); PlaneTypeRepository planeTypeRepository = new PlaneTypeRepository(mc); UnitOfWork unitOfWork = new UnitOfWork(crewRepository, flightRepository, pilotRepository, planeRepository, planeTypeRepository, stewardessRepository, takeOffRepository, ticketRepository, mc); CrewService crewService = new CrewService(unitOfWork); FlightService flightService = new FlightService(unitOfWork); StewardessService stewardessService = new StewardessService(unitOfWork); PilotService pilotService = new PilotService(unitOfWork); TicketService ticketService = new TicketService(unitOfWork); TakeOffService takeOffService = new TakeOffService(unitOfWork); PlaneService planeService = new PlaneService(unitOfWork); PlaneTypeService planeTypeService = new PlaneTypeService(unitOfWork); pilotController = new PilotController(pilotService); flightController = new FlightController(flightService); }
public TakeOffs() { this.InitializeComponent(); tos = new TakeOffService(); list = tos.GetAll().Result; Add.Click += (sender, e) => Create(); }
public void TakeOffCreate() { TakeOffService takeOffService = new TakeOffService(unitOfWork); TakeOffDTO takeOffDTO = new TakeOffDTO() { Date = new DateTime(1, 2, 3), FlightNum = new FlightDTO() { DeperturePlace = "testing", ArrivalPlace = "test", DepartureTime = new DateTime(1, 4, 3), ArrivalTime = new DateTime(1, 3, 4) }, PlaneId = new PlaneDTO() { Name = "test", Made = new DateTime(1, 2, 3), Exploitation = new TimeSpan(0, 1, 2), Type = new PlaneTypeDTO() { Model = "test", CarryCapacity = 12, Places = 15 } }, CrewId = new CrewDTO() { PilotId = new PilotDTO() { Name = "pilotCreateTest", Surname = "pilotCreateTest", Birth = new DateTime(1990, 1, 1), Experience = new TimeSpan(1, 2, 3) }, StewardessIds = new StewardessDTO[] { new StewardessDTO() { Name = "stewCreateTest1", Surname = "stewCreateTest1", Birth = new DateTime(1990, 1, 1) }, new StewardessDTO() { Name = "stewCreateTest2", Surname = "stewCreateTest2", Birth = new DateTime(1990, 1, 1) } } } }; takeOffService.CreateTakeOff(takeOffDTO); TakeOff takeOff = fakeTakeOffRepository.Get(1); Assert.AreEqual(takeOff.Date, takeOffDTO.Date); Assert.AreEqual(takeOff.PlaneId.Name, takeOffDTO.PlaneId.Name); Assert.AreEqual(takeOff.CrewId.PilotId.Name, takeOffDTO.CrewId.PilotId.Name); }