public async Task ShouldAddPassengerSuccessfully() { passengerController.ControllerContext = new ControllerContext(); HttpResponseMessage createResult = await passengerController.AddPassenger(passenger); Assert.AreEqual(createResult.StatusCode, HttpStatusCode.Created, "Verify passenger created"); HttpResponseMessage getResult = await passengerController.GetPassenger(passengerId); Assert.AreEqual(getResult.StatusCode, HttpStatusCode.OK, "verify passenger get"); string json = await getResult.Content.ReadAsStringAsync(); Passenger newPassenger = JsonConvert.DeserializeObject <Passenger>(json); Assert.AreEqual(newPassenger.PassengerId, passengerId); Assert.AreEqual(newPassenger.PassengerFirstName, passengerFirstName); Assert.AreEqual(newPassenger.PassengerMiddleName, passengerMiddleName); Assert.AreEqual(newPassenger.PassengerLastName, passengerLastName); Assert.AreEqual(newPassenger.PNR, pnr); Assert.AreEqual(newPassenger.SeatNumber, seatNo); Assert.AreEqual(newPassenger.FlightNumber, flightNo); Assert.AreEqual(newPassenger.Address, address); Assert.AreEqual(newPassenger.EMail, email); Assert.AreEqual(newPassenger.Phone, phone); Assert.AreEqual(newPassenger.Remarks, remarks); Assert.AreEqual(newPassenger.Subscribed, subscribed); Assert.AreEqual(newPassenger.Luggages.Count, 1); }
public async Task ShouldGetAllLuggageForPassengerIdSuccessfully() { luggageController.ControllerContext = new ControllerContext(); HttpResponseMessage createResult = await luggageController.AddLuggage(luggage); Assert.AreEqual(createResult.StatusCode, HttpStatusCode.Created, "Verify luggage created"); string secondLuggageId = Guid.NewGuid().ToString(); Luggage luggage2 = new Luggage(secondLuggageId, "LuggageName"); HttpResponseMessage createResult2 = await luggageController.AddLuggage(luggage2); Assert.AreEqual(createResult2.StatusCode, HttpStatusCode.Created, "Verify 2nd luggage created"); UInt64 passengerId = 6969; Passenger passenger = new Passenger(passengerId, Guid.NewGuid().ToString(), "Passenger_First_Name", "Passenger_Last_Name"); List <Luggage> luggages = new List <Luggage>(); luggages.Add(luggage); luggages.Add(luggage2); passenger.Luggages = luggages; HttpResponseMessage createResult3 = await passengerController.AddPassenger(passenger); Assert.AreEqual(createResult3.StatusCode, HttpStatusCode.Created, "Verify passenger created"); HttpResponseMessage getResult = await passengerController.GetPassenger(passengerId); Assert.AreEqual(getResult.StatusCode, HttpStatusCode.OK, "verify passengers get"); string json = await getResult.Content.ReadAsStringAsync(); Passenger newPassenger = JsonConvert.DeserializeObject <Passenger>(json); Assert.AreEqual(newPassenger.Luggages.Count, 2); }