コード例 #1
0
        /// <summary>
        /// Save Booking to the database
        /// </summary>
        public SwiftBooking SaveBooking(SwiftBooking booking)
        {
            bookingRepository.Add(booking);
            bookingRepository.SaveChanges();

            return(booking);
        }
コード例 #2
0
 public string Deliver(SwiftBooking request)
 {
     if (ModelState.IsValid)
     {
         return(bookingService.Deliver(request));
     }
     throw new InvalidOperationException("reqest invalid");
 }
コード例 #3
0
 public SwiftBooking SaveBooking(SwiftBooking request)
 {
     if (ModelState.IsValid)
     {
         return(bookingService.SaveBooking(request));
     }
     throw new InvalidOperationException("reqest invalid");
 }
コード例 #4
0
        public string Deliver(SwiftBooking booking)
        {
            RestRequest restRequest = new RestRequest {
                Method = Method.POST, RequestFormat = DataFormat.Json
            };

            restRequest.AddBody(booking.MapToApi());
            return(restClient.Execute(Path.Combine(ApiHostname, ApiEndpoint), restRequest).Content);
        }
コード例 #5
0
        public void SaveBookingTest()
        {
            //Setup
            var booking = new SwiftBooking
            {
                Address = "Perennial Dr",
                Id      = 0,
                Name    = "test"
            };

            bookingRepositoryMock.Setup(br => br.Add(booking));
            bookingRepositoryMock.Setup(br => br.SaveChanges());

            //Act
            var results = testSubject.SaveBooking(booking);

            //Assert
            bookingRepositoryMock.VerifyAll();
            swiftRestClientMock.VerifyAll();
            Assert.AreEqual(results.Name, booking.Name);
            Assert.AreEqual(results.Address, booking.Address);
        }