public void ShouldSaveVetBooking()
        {
            VetBooking savedVetBooking = null;

            _vetBookingRepositoryMock.Setup(x => x.Save(It.IsAny <VetBooking>()))
            .Callback <VetBooking>(vetBooking =>
            {
                savedVetBooking = vetBooking;
            });

            _processor.BookVet(_request);

            _vetBookingRepositoryMock.Verify(x => x.Save(It.IsAny <VetBooking>()), Times.Once);

            Assert.NotNull(savedVetBooking);
            Assert.Equal(_request.FirstName, savedVetBooking.FirstName);
            Assert.Equal(_request.LastName, savedVetBooking.LastName);
            Assert.Equal(_request.Email, savedVetBooking.Email);
            Assert.Equal(_request.Pet, savedVetBooking.Pet);
            Assert.Equal(_request.Date, savedVetBooking.Date);
            Assert.Equal(_availableVets.First().Id, savedVetBooking.VetId);
        }
Пример #2
0
        public void ShouldSaveTheVetBooking()
        {
            // Arrange
            var options = new DbContextOptionsBuilder <VetBookerContext>()
                          .UseInMemoryDatabase(databaseName: "ShouldSaveTheVetBooking")
                          .Options;

            var vetBooking = new VetBooking
            {
                FirstName = "Paul",
                LastName  = "Simons",
                Date      = new DateTime(2020, 1, 25),
                Email     = "*****@*****.**",
                Pet       = "Katinas",
                VetId     = 1
            };

            // Act
            using (var context = new VetBookerContext(options))
            {
                var repository = new VetBookingRepository(context);
                repository.Save(vetBooking);
            }

            // Assert
            using (var context = new VetBookerContext(options))
            {
                var bookings         = context.VetBooking.ToList();
                var storedVetBooking = Assert.Single(bookings);

                Assert.Equal(vetBooking.FirstName, storedVetBooking.FirstName);
                Assert.Equal(vetBooking.LastName, storedVetBooking.LastName);
                Assert.Equal(vetBooking.Email, storedVetBooking.Email);
                Assert.Equal(vetBooking.Pet, storedVetBooking.Pet);
                Assert.Equal(vetBooking.VetId, storedVetBooking.VetId);
                Assert.Equal(vetBooking.Date, storedVetBooking.Date);
            }
        }
Пример #3
0
 public void Save(VetBooking vetBooking)
 {
     _context.VetBooking.Add(vetBooking);
     _context.SaveChanges();
 }