public async Task EditAsync_WithCorrectData_ShouldSuccessfullyEdit()
        {
            var errorMessagePrefix = "ReservationsService EditAsync() method does not work properly.";

            // Arrange
            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var reservationRepository = new EfDeletableEntityRepository <Reservation>(context);
            var reservationsService   = this.GetReservationService(reservationRepository, context);
            var seeder = new ReservationsServiceTestsSeeder();
            await seeder.SeedReservationAsync(context);

            var reservation = context.Reservations.First();

            var model = new EditReservationViewModel
            {
                Id                  = reservation.Id,
                UserId              = context.Users.First().Id,
                StartDate           = new DateTime(2020, 4, 4),
                EndDate             = new DateTime(2020, 4, 8),
                Adults              = 2,
                Kids                = 1,
                ReservationStatusId = context.ReservationStatuses.First().Id,
                PaymentTypeId       = context.PaymentTypes.First().Id,
                TotalAmount         = 1000,
                TotalDays           = 4,
                AdvancedPayment     = 300,
                RoomId              = context.Rooms.First().Id,
            };

            // Act
            await reservationsService.EditAsync(model);

            var actualResult   = reservationRepository.All().First();
            var expectedResult = model;

            // Assert
            Assert.True(expectedResult.UserId == actualResult.UserId, errorMessagePrefix + " " + "User is not returned properly.");
            Assert.True(expectedResult.StartDate == actualResult.StartDate, errorMessagePrefix + " " + "Start date is not returned properly.");
            Assert.True(expectedResult.EndDate == actualResult.EndDate, errorMessagePrefix + " " + "End date is not returned properly.");
            Assert.True(expectedResult.Adults == actualResult.Adults, errorMessagePrefix + " " + "Adults is not returned properly.");
            Assert.True(expectedResult.Kids == actualResult.Kids, errorMessagePrefix + " " + "Kids is not returned properly.");
            Assert.True(expectedResult.TotalAmount == actualResult.TotalAmount, errorMessagePrefix + " " + "Total amount is not returned properly.");
            Assert.True(expectedResult.ReservationStatusId == actualResult.ReservationStatusId, errorMessagePrefix + " " + "Reservation status Id is not returned properly.");
            Assert.True(expectedResult.AdvancedPayment == actualResult.AdvancedPayment, errorMessagePrefix + " " + "Advanced payment is not returned properly.");
            Assert.True(expectedResult.TotalDays == actualResult.TotalDays, errorMessagePrefix + " " + "Total days is not returned properly.");
            Assert.True(expectedResult.PaymentTypeId == actualResult.PaymentTypeId, errorMessagePrefix + " " + "Payment type Id is not returned properly.");
            Assert.True(expectedResult.ReservationStatusId == actualResult.ReservationStatusId, errorMessagePrefix + " " + "Reservation status is not returned properly.");
        }
        public async Task GetAllOccupiedRooms_ShouldReturnCorrectCount()
        {
            // Arrange
            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var reservationRepository = new EfDeletableEntityRepository <Reservation>(context);
            var reservationsService   = this.GetReservationService(reservationRepository, context);
            var seeder = new ReservationsServiceTestsSeeder();
            await seeder.SeedReservationForGetReservedRoomsAsync(context);

            // Act
            var actualResult   = reservationsService.GetAllOccupiedRooms();
            var expectedResult = context.Rooms.Count();

            Assert.Equal(expectedResult, actualResult);
        }
        public async Task GetUnseenRequests_ShouldReturnCorrectCount()
        {
            // Arrange
            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var userRequestRepository = new EfDeletableEntityRepository <UserRequest>(context);
            var userRequestsService   = this.GetUserRequestService(userRequestRepository);
            var seeder = new UserRequestsTestsSeeder();
            await seeder.SeedUserRequestAsync(context);

            // Act
            var actualResult   = userRequestsService.GetUnseenRequests().Count();
            var expectedResult = context.UserRequests.Count();

            Assert.Equal(expectedResult, actualResult);
        }
Пример #4
0
        public async Task GetViewModelByIdAsync_WithNonExistentId_ShouldThrowArgumentNullException()
        {
            // Arrange
            MapperInitializer.InitializeMapper();
            var context             = HotelDbContextInMemoryFactory.InitializeContext();
            var roomsRepository     = new EfDeletableEntityRepository <Room>(context);
            var roomTypesRepository = new EfDeletableEntityRepository <RoomType>(context);
            var roomsService        = this.GetRoomsService(roomsRepository, roomTypesRepository, context);
            var nonExistentId       = Guid.NewGuid().ToString();

            // Act

            // Assert
            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
            {
                await roomsService.GetViewModelByIdAsync <EditRoomViewModel>(nonExistentId);
            });
        }
Пример #5
0
        public async Task GetPaymentByIdAsync_WithNonExistentId_ShouldThrowArgumentNullException()
        {
            // Arrange
            MapperInitializer.InitializeMapper();
            var context           = HotelDbContextInMemoryFactory.InitializeContext();
            var paymentRepository = new EfDeletableEntityRepository <Payment>(context);
            var paymentsService   = this.GetPaymentsService(paymentRepository);

            var nonExistentId = Guid.NewGuid().ToString();

            // Act

            // Assert
            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
            {
                await paymentsService.GetPaymentByIdAsync(nonExistentId);
            });
        }
        public async Task CreateAllAsync_ShouldShouldSuccessfullyCreate()
        {
            var errorMessagePrefix = "ReservationStatusesService CreateAllAsync() method does not work properly.";

            // Arrange
            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var reservationStatusRepository = new EfDeletableEntityRepository <ReservationStatus>(context);
            var reservationStatusesService  = this.GetReservationStatusesService(reservationStatusRepository, context);
            var seeder = new ReservationStatusesServiceTestsSeeder();
            await seeder.SeedReservationStatusesAsync(context);

            // Act
            var result = await reservationStatusesService.CreateAllAsync(new string[] { "Test-1", "Test-2", "Test-3" });

            // Assert
            Assert.True(result, errorMessagePrefix + " " + "Returns false.");
        }
Пример #7
0
        public async Task GetHotelByName_WithNonExistentName_ShouldThrowArgumentNullException()
        {
            // Arrange
            MapperInitializer.InitializeMapper();
            var context         = HotelDbContextInMemoryFactory.InitializeContext();
            var hotelRepository = new EfDeletableEntityRepository <HotelData>(context);
            var hotelsService   = this.GetHotelsService(hotelRepository);

            var nonExistentName = Guid.NewGuid().ToString();

            // Act

            // Assert
            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
            {
                hotelsService.GetHotelByName(nonExistentName);
            });
        }
Пример #8
0
        public async Task GetAllPaymentsForReservation_ShouldReturnCorrectCount()
        {
            // Arrange
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var seeder  = new PaymentsServiceTestsSeeder();
            await seeder.SeedPaymentAsync(context);

            var paymentRepository = new EfDeletableEntityRepository <Payment>(context);
            var paymentsService   = this.GetPaymentsService(paymentRepository);

            var reservation = context.Reservations.First();

            // Act
            var actualResult   = paymentsService.GetAllPaymentsForReservation(reservation.Id).ToList();
            var expectedResult = 1;

            Assert.Equal(expectedResult, actualResult.Count());
        }
        public async Task GetAllReservedRoomsId_ShouldReturnCorrectResult()
        {
            var errorMessagePrefix = "ReservationsService GetAllReservedRooms() method does not work properly.";

            // Arrange
            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var reservationRepository = new EfDeletableEntityRepository <Reservation>(context);
            var reservationsService   = this.GetReservationService(reservationRepository, context);
            var seeder = new ReservationsServiceTestsSeeder();
            await seeder.SeedReservationAsync(context);

            // Act
            var actualResult   = reservationsService.GetAllReservedRoomsId(new DateTime(2020, 4, 4), new DateTime(2020, 4, 8)).ToList();
            var expectedResult = new string[] { context.Rooms.First().Id, };

            Assert.True(expectedResult[0] == actualResult[0], errorMessagePrefix + " " + "Id is not returned properly.");
        }
Пример #10
0
        public async Task GetPaymentTypeByName_WithIncorrectProperty_ShouldThrowArgumentNullException()
        {
            // Arrange
            MapperInitializer.InitializeMapper();
            var context         = HotelDbContextInMemoryFactory.InitializeContext();
            var hotelRepository = new EfDeletableEntityRepository <HotelData>(context);
            var hotelsService   = this.GetHotelsService(hotelRepository);

            string name = null;

            // Act

            // Assert
            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
            {
                hotelsService.GetHotelByName(name);
            });
        }
        public async Task GetReservationStatusByName_WithIncorrectProperty_ShouldThrowArgumentNullException()
        {
            // Arrange
            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var reservationStatusRepository = new EfDeletableEntityRepository <ReservationStatus>(context);
            var reservationStatusesService  = this.GetReservationStatusesService(reservationStatusRepository, context);

            string name = null;

            // Act

            // Assert
            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
            {
                reservationStatusesService.GetReserVationStatusByName(name);
            });
        }
        public async Task GetAllReservedRoomsId_ShouldReturnCorrectCount()
        {
            // Arrange
            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var reservationRepository = new EfDeletableEntityRepository <Reservation>(context);
            var reservationsService   = this.GetReservationService(reservationRepository, context);
            var seeder = new ReservationsServiceTestsSeeder();
            await seeder.SeedReservationAsync(context);

            // Act
            var actualResult   = reservationsService.GetAllReservedRoomsId(new DateTime(2020, 4, 4), new DateTime(2020, 4, 8)).ToList();
            var expectedResult = new Room[]
            {
                context.Rooms.First(),
            };

            Assert.Equal(expectedResult.Length, actualResult.Count());
        }
        public async Task CreateAllAsync_ShouldReturnCorrectCount()
        {
            var errorMessage = "ReservationStatusesService CreateAllAsync() method does not work properly.";

            // Arrange
            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var reservationStatusRepository = new EfDeletableEntityRepository <ReservationStatus>(context);
            var reservationStatusesService  = this.GetReservationStatusesService(reservationStatusRepository, context);

            // Act
            var reservationStatusesCount = reservationStatusRepository.All().Count();
            await reservationStatusesService.CreateAllAsync(new string[] { "Test-1" });

            var actualResult   = reservationStatusRepository.All().Count();
            var expectedResult = reservationStatusesCount + 1;

            // Assert
            Assert.True(actualResult == expectedResult, errorMessage + " " + "Reservation statuses count is not reduced.");
        }
Пример #14
0
        public async Task GetAllPaymentsForReservation_ShouldReturnCorrectResult()
        {
            var errorMessage = "PaymentsService GetAllPaymentsForReservation() method does not work properly.";

            // Arrange
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var seeder  = new PaymentsServiceTestsSeeder();
            await seeder.SeedPaymentAsync(context);

            var paymentRepository = new EfDeletableEntityRepository <Payment>(context);
            var paymentsService   = this.GetPaymentsService(paymentRepository);

            var reservation = context.Reservations.First();

            // Act
            var actualResult   = paymentsService.GetAllPaymentsForReservation(reservation.Id).ToList();
            var expectedResult = new string[] { paymentRepository.All().First().ReservationPayments.First().PaymentId };

            Assert.True(expectedResult[0] == actualResult[0], errorMessage + " " + "Id is not returned properly.");
        }
        public async Task DeleteByIdAsync_WithExistentId_ShouldReturnCorrectResult()
        {
            var errorMessagePrefix = "ReservationStatusesService DeleteByIdAsync() method does not work properly.";

            // Arrange
            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var reservationStatusRepository = new EfDeletableEntityRepository <ReservationStatus>(context);
            var reservationStatusesService  = this.GetReservationStatusesService(reservationStatusRepository, context);
            var seeder = new ReservationStatusesServiceTestsSeeder();
            await seeder.SeedReservationStatusesAsync(context);

            var reservationStatusId = reservationStatusRepository.All().First().Id;

            // Act
            var result = await reservationStatusesService.DeleteByIdAsync(reservationStatusId);

            // Assert
            Assert.True(result, errorMessagePrefix + " " + "Returns false.");
        }
Пример #16
0
        public async Task DeleteByIdAsync_WithExistentId_ShouldReturnCorrectResult()
        {
            var errorMessage = "PaymentTypeService DeleteByIdAsync() method does not work properly.";

            // Arrange
            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var paymentTypeRepository = new EfDeletableEntityRepository <PaymentType>(context);
            var paymentTypesService   = this.GetPaymentTypesService(paymentTypeRepository);
            var seeder = new PaymentTypesServiceTestsSeeder();
            await seeder.SeedPaymentTypesAsync(context);

            var paymentTypeId = paymentTypeRepository.All().First().Id;

            // Act
            var result = await paymentTypesService.DeleteByIdAsync(paymentTypeId);

            // Assert
            Assert.True(result, errorMessage + " " + "Returns false.");
        }
Пример #17
0
        public async Task GetAllPaymentTypesCountAsync_ShouldReturnCorrectResult()
        {
            var errorMessage = "PaymentTypesService GetAllPaymentTypesCountAsync() method does not work properly.";

            // Arrange
            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var paymentTypeRepository = new EfDeletableEntityRepository <PaymentType>(context);
            var paymentTypesService   = this.GetPaymentTypesService(paymentTypeRepository);
            var seeder = new PaymentTypesServiceTestsSeeder();
            await seeder.SeedPaymentTypesAsync(context);

            // Act
            var actualResult = await paymentTypesService.GetAllPaymentTypesCountAsync();

            var expectedResult = paymentTypeRepository.All().Count();

            // Assert
            Assert.True(actualResult == expectedResult, errorMessage + " " + "PaymentTypesService GetAllRoomTypesCountAsync() method does not work properly.");
        }
        public async Task GetAllReservationStatusesCountAsync_ShouldReturnCorrectResult()
        {
            var errorMessagePrefix = "ReservationStatusesService GetAllReservationStatusesCountAsync() method does not work properly.";

            // Arrange
            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var reservationStatusRepository = new EfDeletableEntityRepository <ReservationStatus>(context);
            var reservationStatusesService  = this.GetReservationStatusesService(reservationStatusRepository, context);
            var seeder = new ReservationStatusesServiceTestsSeeder();
            await seeder.SeedReservationStatusesAsync(context);

            // Act
            var actualResult = await reservationStatusesService.GetAllReservationStatusesCountAsync();

            var expectedResult = reservationStatusRepository.All().Count();

            // Assert
            Assert.True(actualResult == expectedResult, errorMessagePrefix + " " + "ReservationStatusesService GetAllReservationStatusesCountAsync() method does not work properly.");
        }
Пример #19
0
        public async Task AddPaymentTypeAsync_WithCorrectData_ShouldReturnCorrectResult()
        {
            var errorMessagePrefix = "PaymentTypesService AddPaymentTypeAsync() method does not work properly.";

            // Arrange
            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var paymentTypeRepository = new EfDeletableEntityRepository <PaymentType>(context);
            var paymentTypesService   = this.GetPaymentTypesService(paymentTypeRepository);

            var paymentTypeModel = new PaymentType
            {
                Name = "Test",
            };

            // Act
            var result = await paymentTypesService.AddPaymentTypeAsync(paymentTypeModel);

            // Assert
            Assert.True(result, errorMessagePrefix + " " + "Returns false.");
        }
        public async Task AddReservationStatusAsync_WithCorrectData_ShouldReturnCorrectResult()
        {
            var errorMessage = "ReservationsService AddReservationStatusAsync() method does not work properly.";

            // Arrange
            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var reservationStatusRepository = new EfDeletableEntityRepository <ReservationStatus>(context);
            var reservationStatusesService  = this.GetReservationStatusesService(reservationStatusRepository, context);

            var reservationStatusModel = new ReservationStatus
            {
                Name = "Test",
            };

            // Act
            var result = await reservationStatusesService.AddReservationStatusAsync(reservationStatusModel);

            // Assert
            Assert.True(result, errorMessage + " " + "Returns false.");
        }
Пример #21
0
        public async Task AddPaymentTypeAsync_WithIncorrectProperty_ShouldThrowArgumentNullException()
        {
            // Arrange
            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var paymentTypeRepository = new EfDeletableEntityRepository <PaymentType>(context);
            var paymentTypesService   = this.GetPaymentTypesService(paymentTypeRepository);

            var paymentTypeModel = new PaymentType
            {
                Name = null,
            };

            // Act

            // Assert
            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
            {
                await paymentTypesService.AddPaymentTypeAsync(paymentTypeModel);
            });
        }
Пример #22
0
        public async Task EditAsync_WithCorrectData_ShouldSuccessfullyEdit()
        {
            var errorMessage = "PaymentsService EditAsync() method does not work properly.";

            // Arrange
            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var seeder  = new PaymentsServiceTestsSeeder();
            await seeder.SeedPaymentAsync(context);

            var paymentRepository = new EfDeletableEntityRepository <Payment>(context);
            var paymentsService   = this.GetPaymentsService(paymentRepository);

            var payment = context.Payments.First();

            var model = new EditPaymentViewModel
            {
                Id                  = payment.Id,
                DateOfPayment       = DateTime.Now.Date,
                Amount              = 300,
                PaymentTypeId       = context.PaymentTypes.First().Id,
                ReservationPayments = new List <ReservationPayment>
                {
                    new ReservationPayment {
                        ReservationId = context.Reservations.First().Id
                    }
                },
            };

            // Act
            await paymentsService.EditAsync(model);

            var actualResult   = paymentRepository.All().First();
            var expectedResult = model;

            // Assert
            Assert.True(expectedResult.DateOfPayment == actualResult.DateOfPayment, errorMessage + " " + "Date of payment is not returned properly.");
            Assert.True(expectedResult.Amount == actualResult.Amount, errorMessage + " " + "Amount is not returned properly.");
            Assert.True(expectedResult.PaymentTypeId == actualResult.PaymentTypeId, errorMessage + " " + "payment type id is not returned properly.");
        }
Пример #23
0
        public async Task EditAsync_WithCorrectData_ShouldSuccessfullyEdit()
        {
            var errorMessagePrefix = "RoomTypeService EditAsync() method does not work properly.";

            // Arrange
            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var seeder  = new RoomTypesServiceTestsSeeder();
            await seeder.SeedRoomTypeAsync(context);

            var roomTypeRepository = new EfDeletableEntityRepository <RoomType>(context);
            var roomTypesService   = this.GetRoomTypesService(roomTypeRepository, context);

            var roomType = context.RoomTypes.First();

            var model = new EditRoomTypeViewModel
            {
                Id             = roomType.Id,
                Name           = "Test-2-Edited",
                Price          = 130,
                CapacityAdults = 1,
                CapacityKids   = 0,
                Image          = "test2-edited.jpg",
                Description    = "Description2-edited",
            };

            // Act
            await roomTypesService.EditAsync(model);

            var actualResult   = roomTypeRepository.All().First();
            var expectedResult = model;

            // Assert
            Assert.True(expectedResult.Name == actualResult.Name, errorMessagePrefix + " " + "Name is not returned properly.");
            Assert.True(expectedResult.Price == actualResult.Price, errorMessagePrefix + " " + "Price is not returned properly.");
            Assert.True(expectedResult.CapacityAdults == actualResult.CapacityAdults, errorMessagePrefix + " " + "Capacity Adults is not returned properly.");
            Assert.True(expectedResult.CapacityKids == actualResult.CapacityKids, errorMessagePrefix + " " + "Capacity Kids is not returned properly.");
            Assert.True(expectedResult.Image == actualResult.Image, errorMessagePrefix + " " + "Image is not returned properly.");
            Assert.True(expectedResult.Description == actualResult.Description, errorMessagePrefix + " " + "Description is not returned properly.");
        }
        public async Task AddReservationAsync_WithCorrectData_ShouldReturnCorrectResult()
        {
            var errorMessagePrefix = "ReservationsService  AddReservationAsync() method does not work properly.";

            // Arrange
            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var reservationRepository = new EfDeletableEntityRepository <Reservation>(context);
            var reservationsService   = this.GetReservationService(reservationRepository, context);
            var seeder = new ReservationsServiceTestsSeeder();
            await seeder.SeedDataForAddAsyncMethodAsync(context);

            var reservation = new Reservation
            {
                UserId              = context.Users.First().Id,
                StartDate           = new DateTime(2020, 4, 4),
                EndDate             = new DateTime(2020, 4, 8),
                Adults              = 2,
                Kids                = 1,
                ReservationStatusId = context.ReservationStatuses.First().Id,
                PaymentTypeId       = context.PaymentTypes.First().Id,
                TotalAmount         = 1000,
                PricePerDay         = 250,
                TotalDays           = 4,
                AdvancedPayment     = 300,
                ReservationRooms    = new List <ReservationRoom> {
                    new ReservationRoom {
                        RoomId = context.Rooms.First().Id
                    }
                },
            };

            // Act
            var result = await reservationsService.AddReservationAsync(reservation);

            // Assert
            Assert.True(result, errorMessagePrefix + " " + "Returns false.");
        }
Пример #25
0
        public async Task GetViewModelByIdAsync_WithExistentId_ShouldReturnCorrectResult()
        {
            var errorMessagePrefix = "RoomTypesService GetViewModelByIdAsync() method does not work properly.";

            // Arrange
            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var seeder  = new RoomTypesServiceTestsSeeder();
            await seeder.SeedRoomTypesAsync(context);

            var roomTypeRepository = new EfDeletableEntityRepository <RoomType>(context);
            var roomTypesService   = this.GetRoomTypesService(roomTypeRepository, context);

            var roomTypeId = roomTypeRepository.All().First().Id;

            // Act
            var actualResult = await roomTypesService.GetViewModelByIdAsync <EditRoomTypeViewModel>(roomTypeId);

            var expectedResult = new EditRoomTypeViewModel
            {
                Id             = roomTypeId,
                Name           = roomTypeRepository.All().First().Name,
                CapacityAdults = roomTypeRepository.All().First().CapacityAdults,
                CapacityKids   = roomTypeRepository.All().First().CapacityKids,
                Image          = roomTypeRepository.All().First().Image,
                Description    = roomTypeRepository.All().First().Description,
                Price          = roomTypeRepository.All().First().Price,
            };

            // Assert
            Assert.True(expectedResult.Id == actualResult.Id, errorMessagePrefix + " " + "Id is not returned properly.");
            Assert.True(expectedResult.Name == actualResult.Name, errorMessagePrefix + " " + "Name is not returned properly.");
            Assert.True(expectedResult.Price == actualResult.Price, errorMessagePrefix + " " + "Price is not returned properly.");
            Assert.True(expectedResult.CapacityAdults == actualResult.CapacityAdults, errorMessagePrefix + " " + "Capacity Adults is not returned properly.");
            Assert.True(expectedResult.CapacityKids == actualResult.CapacityKids, errorMessagePrefix + " " + "Capacity Kids is not returned properly.");
            Assert.True(expectedResult.Image == actualResult.Image, errorMessagePrefix + " " + "Image is not returned properly.");
            Assert.True(expectedResult.Description == actualResult.Description, errorMessagePrefix + " " + "Description is not returned properly.");
        }
        public async Task AddReservationAsync_WithIncorrectProperty_ShouldThrowArgumentNullException()
        {
            // Arrange
            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var reservationRepository = new EfDeletableEntityRepository <Reservation>(context);
            var reservationsService   = this.GetReservationService(reservationRepository, context);
            var seeder = new ReservationsServiceTestsSeeder();
            await seeder.SeedDataForAddAsyncMethodAsync(context);

            var reservation = new Reservation
            {
                UserId              = null,
                StartDate           = new DateTime(2020, 4, 4),
                EndDate             = new DateTime(2020, 4, 8),
                Adults              = 2,
                Kids                = 1,
                ReservationStatusId = null,
                PaymentTypeId       = null,
                TotalAmount         = 1000,
                PricePerDay         = 250,
                TotalDays           = 4,
                AdvancedPayment     = 300,
                ReservationRooms    = new List <ReservationRoom> {
                    new ReservationRoom {
                        RoomId = context.Rooms.First().Id
                    }
                },
            };

            // Act

            // Assert
            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
            {
                await reservationsService.AddReservationAsync(reservation);
            });
        }
        public async Task GetAllReservationStatuses_ShouldReturnCorrectCount()
        {
            // Arrange
            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var reservationStatusRepository = new EfDeletableEntityRepository <ReservationStatus>(context);
            var reservationStatusesService  = this.GetReservationStatusesService(reservationStatusRepository, context);
            var seeder = new ReservationStatusesServiceTestsSeeder();
            await seeder.SeedReservationStatusAsync(context);

            // Act
            var actualResult   = reservationStatusesService.GetAllReservationStatuses <DetailsReservationStatusViewModel>().ToList();
            var expectedResult = new DetailsReservationStatusViewModel[]
            {
                new DetailsReservationStatusViewModel
                {
                    Id   = reservationStatusRepository.All().First().Id,
                    Name = reservationStatusRepository.All().First().Name,
                },
            };

            Assert.Equal(expectedResult.Length, actualResult.Count());
        }
        public async Task AddReservationStatusAsync_WithCorrectData_ShouldSuccessfullyCreate()
        {
            var errorMessagePrefix = "ReservationService AddReservationStatusAsync() method does not work properly.";

            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var reservationStatusRepository = new EfDeletableEntityRepository <ReservationStatus>(context);
            var reservationStatusesService  = this.GetReservationStatusesService(reservationStatusRepository, context);

            var reservationStatusModel = new ReservationStatus
            {
                Name = "Test",
            };

            // Act
            await reservationStatusesService.AddReservationStatusAsync(reservationStatusModel);

            var actualResult   = reservationStatusRepository.All().First();
            var expectedResult = reservationStatusModel;

            // Assert
            Assert.True(expectedResult.Name == actualResult.Name, errorMessagePrefix + " " + "Name is not returned properly.");
        }
        public async Task AddReservationStatusAsync_WithIncorrectProperty_ShouldThrowArgumentNullException()
        {
            // Arrange
            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var reservationStatusRepository = new EfDeletableEntityRepository <ReservationStatus>(context);
            var reservationStatusesService  = this.GetReservationStatusesService(reservationStatusRepository, context);
            var seeder = new ReservationStatusesServiceTestsSeeder();
            await seeder.SeedReservationStatusAsync(context);

            var reservationStatusModel = new ReservationStatus
            {
                Name = null,
            };

            // Act

            // Assert
            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
            {
                await reservationStatusesService.AddReservationStatusAsync(reservationStatusModel);
            });
        }
        public async Task CreateAllAsync_ShouldReturnCorrectResult()
        {
            var errorMessage = "ReservationStatusesService CreateAllAsync() method does not work properly.";

            // Arrange
            MapperInitializer.InitializeMapper();
            var context = HotelDbContextInMemoryFactory.InitializeContext();
            var reservationStatusRepository = new EfDeletableEntityRepository <ReservationStatus>(context);
            var reservationStatusesService  = this.GetReservationStatusesService(reservationStatusRepository, context);
            var seeder = new ReservationStatusesServiceTestsSeeder();
            await seeder.SeedReservationStatusAsync(context);

            // Act
            await reservationStatusesService.CreateAllAsync(new string[] { "Test-1" });

            var actualResult = new ReservationStatus {
                Name = "Test-1"
            };
            var expectedResult = reservationStatusRepository.All().First();

            // Assert
            Assert.True(expectedResult.Name == actualResult.Name, errorMessage + " " + "Name is not returned properly.");
        }