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 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_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());
        }