public async Task UpdateTicketTest() { DbContextOptions <SWTDbContext> options = new DbContextOptionsBuilder <SWTDbContext>() .UseInMemoryDatabase("UpdateTicket") .Options; using SWTDbContext testContext = new SWTDbContext(options); Repo repo = new Repo(testContext); string create = await repo.CreateFlightTicket(ticket); Logic.FlightTicket newTicket = new Logic.FlightTicket { TicketID = 1, CustomerID = 2, FlightID = 3, Checkin = true, Price = 123.99, Luggage = 2 }; string update = await repo.UpdateFlightTicket(newTicket); int cusId = testContext.FlightTicket.Select(f => f.CustomerID).First(); int flightId = testContext.FlightTicket.Select(f => f.FlightID).First(); bool checkIn = testContext.FlightTicket.Select(f => f.Checkin).First(); int luggage = testContext.FlightTicket.Select(f => f.Luggage).First(); double price = testContext.FlightTicket.Select(f => f.Price).First(); Assert.Equal(newTicket.CustomerID, cusId); Assert.Equal(newTicket.FlightID, flightId); Assert.Equal(newTicket.Checkin, checkIn); Assert.Equal(newTicket.Luggage, luggage); Assert.Equal(newTicket.Price, price); }
//Map Business --> Entity public static FlightTicket MapFlightTicketToE(Logic.FlightTicket BFlightTicket) { return(new FlightTicket { FlightTicketID = BFlightTicket.TicketID, FlightID = BFlightTicket.FlightID, CustomerID = BFlightTicket.CustomerID, Price = BFlightTicket.Price, Checkin = BFlightTicket.Checkin, Luggage = BFlightTicket.Luggage }); }
public void FlightTicketTest() { Logic.FlightTicket ticket1 = new Logic.FlightTicket { TicketID = 1, CustomerID = 1, FlightID = 1, Price = 258.66, Checkin = true, Luggage = 2 }; Logic.FlightTicket ticket2 = new Logic.FlightTicket(1, 1, 1, 258.66, true, 2); Assert.Equal(ticket1.TicketID, ticket2.TicketID); Assert.Equal(ticket1.CustomerID, ticket2.CustomerID); Assert.Equal(ticket1.FlightID, ticket2.FlightID); Assert.Equal(ticket1.Checkin, ticket2.Checkin); Assert.Equal(ticket1.Luggage, ticket2.Luggage); Assert.Equal(ticket1.Price, ticket2.Price); }