public async Task EditAsync_WithCorrectData_ShouldReturnCorrectResult()
        {
            var errorMessage = "ReservationStatusesService EditAsync() 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);

            var reservationStatus = context.ReservationStatuses.First();

            var model = new EditReservationStatusViewModel
            {
                Id   = reservationStatus.Id,
                Name = "Test-1-Edited",
            };

            // Act
            var result = await reservationStatusesService.EditAsync(model);

            // Assert
            Assert.True(result, errorMessage + " " + "Returns false.");
        }
        public async Task GetAllReservationStatuses_ShouldReturnCorrectResult()
        {
            var errorMessagePrefix = "ReservationStatusesService GetAllReservationStatuses() 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
            var actualResult   = reservationStatusesService.GetAllReservationStatuses <DetailsReservationStatusViewModel>().ToList();
            var expectedResult = new DetailsReservationStatusViewModel[]
            {
                new DetailsReservationStatusViewModel
                {
                    Id   = reservationStatusRepository.All().First().Id,
                    Name = reservationStatusRepository.All().First().Name,
                },
            };

            Assert.True(expectedResult[0].Id == actualResult[0].Id, errorMessagePrefix + " " + "Id is not returned properly.");
            Assert.True(expectedResult[0].Name == actualResult[0].Name, errorMessagePrefix + " " + "Name is not returned properly.");
        }
        public async Task GetReservationStatusByIdAsync_WithExistentId_ShouldReturnCorrectResult()
        {
            var errorMessagePrefix = "ReservationStatusesService GetReservationStatusByIdAsync() 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 actualResult = await reservationStatusesService.GetReservationStatusByIdAsync(reservationStatusId);

            var expectedResult = await reservationStatusRepository
                                 .All()
                                 .SingleOrDefaultAsync(x => x.Id == reservationStatusId);

            // 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.");
        }
        public async Task EditAsync_WithCorrectData_ShouldSuccessfullyEdit()
        {
            var errorMessagePrefix = "ReservationStatusesService EditAsync() 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);

            var reservationStatus = context.ReservationStatuses.First();

            var model = new EditReservationStatusViewModel
            {
                Id   = reservationStatus.Id,
                Name = "Test-1-Edited",
            };

            // Act
            await reservationStatusesService.EditAsync(model);

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

            // Assert
            Assert.True(expectedResult.Name == actualResult.Name, errorMessagePrefix + " " + "Name is not returned properly.");
        }
        public async Task EditAsync_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 reservationStatus = context.ReservationStatuses.First();

            var model = new EditReservationStatusViewModel
            {
                Id   = reservationStatus.Id,
                Name = null,
            };

            // Act

            // Assert
            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
            {
                await reservationStatusesService.EditAsync(model);
            });
        }
        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.");
        }
        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.");
        }
        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.");
        }
        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.");
        }
        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());
        }