コード例 #1
0
        public void ReservationService_DeleteByUserIdProjectionId_ReturnsListOfDeletedReservations()
        {
            //Arrange

            List <Reservation> reservationList = new List <Reservation>();

            reservationList.Add(_reservation);
            IEnumerable <Reservation>         reservations = reservationList;
            Task <IEnumerable <Reservation> > responseTask = Task.FromResult(reservations);

            int expectedResultCount = 1;
            ReservationService reservationService = new ReservationService(_mockReservationsRepository.Object);

            _mockReservationsRepository.Setup(x => x.DeleteByUserIdProjectionId(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(responseTask);

            //Act
            var resultAction = reservationService.DeleteByUserIdProjectionId(_reservation.UserId, _reservation.ProjectionId).ConfigureAwait(false).GetAwaiter().GetResult().ToList();


            //Assert
            Assert.AreEqual(resultAction.Count, expectedResultCount);
            Assert.AreEqual(resultAction[0].UserId, _reservation.UserId);
            Assert.AreEqual(resultAction[0].ProjectionId, _reservation.ProjectionId);
            Assert.IsInstanceOfType(resultAction[0], typeof(ReservationDomainModel));
            Assert.IsNotNull(resultAction);
        }
コード例 #2
0
        public void ReservationService_DeleteByUserIdProjectionId_RepositoryReturnsNull_ReturnsNull()
        {
            //Arrange
            IEnumerable <Reservation>         reservations = null;
            Task <IEnumerable <Reservation> > responseTask = Task.FromResult(reservations);

            ReservationService reservationService = new ReservationService(_mockReservationsRepository.Object);

            _mockReservationsRepository.Setup(x => x.DeleteByUserIdProjectionId(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(responseTask);

            //Act
            var resultAction = reservationService.DeleteByUserIdProjectionId(_reservation.UserId, _reservation.ProjectionId).ConfigureAwait(false).GetAwaiter().GetResult();


            //Assert
            Assert.IsNull(resultAction);
        }