예제 #1
0
        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);
        }
예제 #2
0
        public void GetPassengerById1()
        {
            // Arrange
            var passenger = new PassengerView();

            passenger.P_No   = 1;
            passenger.F_Name = "Harhsil";
            passenger.L_Name = "Sheth";
            passenger.Phone  = 123456789;

            // Act
            var responseObj = mockDtaRepository.Setup(x => x.GetPassenger(passenger.P_No)).Returns(passenger);
            var result      = _passengerController.GetPassenger(passenger.P_No);

            // Assert
            Assert.NotNull(result);
        }
        public void GetPassengerById_with_notNull_output()
        {
            // Arrange
            var passenger = new PassengerView();

            passenger.P_No   = 1;
            passenger.F_Name = "Dhruvi";
            passenger.L_Name = "Bavaria";
            passenger.Phone  = 90876534;

            // Act
            var responseObj = mockDtaRepository.Setup(x => x.GetPassenger(passenger.P_No)).Returns(passenger);
            var result      = _passengerController.GetPassenger(passenger.P_No);

            // Assert
            Assert.NotNull(result);
        }
예제 #4
0
        public void Test_GetUserById()
        {
            //Arrange
            var passenger = new Passenger();

            passenger.PassengerId = Convert.ToInt32(DateTime.Now.Ticks.ToString());

            var resultType = mockDataRepo.Setup(x => x.getPassengerByPassengerId(passenger.PassengerId.ToString())).Returns(passenger);
            //Act
            var result = _passengerController.GetPassenger(passenger.PassengerId.ToString());

            //Assert
            Assert.NotNull(result);
        }
예제 #5
0
        public void Test_GetUserById()
        {
            // Arrange
            var passenger = new Passenger();

            passenger.PNumber = new System.Guid("3CDBC747-DB0A-4EF1-9353-6A1110DC05B9");
            var resultType = mockDataRepo.Setup(x => x.getPassengerByexID(passenger.PNumber.ToString())).Returns(passenger);

            // Act
            var result = _passengerController.GetPassenger(passenger.PNumber.ToString());

            // Assert
            var isNull = Assert.IsType <OkNegotiatedContentResult <Passenger> >(result);

            Assert.NotNull(isNull);
        }
예제 #6
0
        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);
        }