public async Task RepoGetVacantShouldReturnAvailableRoomsBasedOnFilter()
        {
            var options = new DbContextOptionsBuilder <RoomServiceContext>()
                          .UseInMemoryDatabase("RepoGetVacantShouldReturnAvailableRoomsBasedOnFilter")
                          .Options;

            using var assembleContext = new RoomServiceContext(options);
            assembleContext.Database.EnsureCreated();
            var mapper = new DbMapper();

            var newRoom  = PresetEntityRoom(assembleContext);
            var newRoom2 = PresetEntityRoom2(assembleContext);

            assembleContext.Add(newRoom);
            assembleContext.Add(newRoom2);
            assembleContext.SaveChanges();

            var endDate = new DateTime(2001, 3, 15);

            using var actContext = new RoomServiceContext(options);
            var repo = new Repository(actContext, mapper);

            var filterRoom = await repo.GetVacantFilteredRoomsByGenderandEndDateAsync("Female", endDate);

            var assertContext = new RoomServiceContext(options);

            Assert.NotNull(filterRoom);

            Assert.Equal(_newRoomId.ToString(), filterRoom.FirstOrDefault(r => r.Item1 == _newRoomId).Item1.ToString());
        }
        public async Task RepoDeleteOneOfTwo()
        {
            var options = new DbContextOptionsBuilder <RoomServiceContext>()
                          .UseInMemoryDatabase("RepoDeleteOneOfTwo")
                          .Options;

            using var testContext = new RoomServiceContext(options);
            var mapper = new DbMapper();

            var newRoom1 = PresetEntityRoom(testContext);

            var newRoom2 = PresetEntityRoom2(testContext);

            testContext.Add(newRoom1);
            testContext.Add(newRoom2);
            testContext.SaveChanges();

            using var assertContext = new RoomServiceContext(options);
            var repo = new Repository(assertContext, mapper);

            await repo.DeleteRoomAsync(_newRoomId2);

            assertContext.SaveChanges();

            Assert.Null(assertContext.Room.Find(_newRoomId2));
        }
        public async Task RepoDeleteComplexRoomShouldDeleteAllRoomsInComplex()
        {
            var options = new DbContextOptionsBuilder <RoomServiceContext>()
                          .UseInMemoryDatabase("RepoDeleteComplexRoomShouldDeleteAllRoomsInComplex")
                          .Options;

            using var assembleContext = new RoomServiceContext(options);
            assembleContext.Database.EnsureCreated();
            //var mapper = new DBMapper(assembleContext);

            var mapper = new DbMapper();

            var newRoom  = PresetEntityRoom(assembleContext);
            var newRoom2 = PresetEntityRoom2(assembleContext);
            var newRoom3 = PresetEntityRoom3(assembleContext);

            assembleContext.Add(newRoom);
            assembleContext.Add(newRoom2);
            assembleContext.Add(newRoom3);
            assembleContext.SaveChanges();

            using var actContext = new RoomServiceContext(options);
            var repo = new Repository(actContext, mapper);

            var deleteComplexRooms = await repo.DeleteComplexRoomAsync(_newComplexId);

            await actContext.SaveChangesAsync();

            var assertContext = new RoomServiceContext(options);

            //The DeleteComplexRoomAsync method deletes all rooms based on the complex, it works
            //But we have 3 seeded room in our database that aren't in the same complex
            //so even after delete all the created rooms
            //we still have our seeded data.
            Assert.Equal(3, assertContext.Room.Count());
        }
        public async Task RepoReadCheckGenderTest()
        {
            var options = new DbContextOptionsBuilder <RoomServiceContext>()
                          .UseInMemoryDatabase("RepoReadCheckGenderTest")
                          .Options;

            using var testContext = new RoomServiceContext(options);
            testContext.Database.EnsureCreated();
            var mapper = new DbMapper();

            var newRoom = PresetEntityRoom2(testContext);

            testContext.Add(newRoom);
            testContext.SaveChanges();

            using var actContext = new RoomServiceContext(options);
            var repo = new Repository(actContext, mapper);

            var resultRoom = await repo.ReadRoomAsync(newRoom.RoomId);

            Assert.Equal("Male", resultRoom.Gender);
        }
        public async Task ReadRoomShouldReturnRoom()
        {
            var options = new DbContextOptionsBuilder <RoomServiceContext>()
                          .UseInMemoryDatabase("ReadRoomShouldReturnRoom")
                          .Options;

            using var testContext = new RoomServiceContext(options);
            var mapper = new DbMapper();

            testContext.Database.EnsureCreated();

            var newRoomEntity = PresetEntityRoom(testContext);

            testContext.Add(newRoomEntity);
            await testContext.SaveChangesAsync();

            using var assertContext = new RoomServiceContext(options);
            var repo = new Repository(assertContext, mapper);

            var resultRoom = await repo.ReadRoomAsync(_newRoomId);

            Assert.NotNull(resultRoom);
            Assert.Equal(_newRoomId, resultRoom.RoomId);
        }
        public async Task RepoGetFilterRoomShouldFilterBasedOnWhatYouGiveIt()
        {
            var options = new DbContextOptionsBuilder <RoomServiceContext>()
                          .UseInMemoryDatabase("RepoGetFilterRoomShouldFilterBasedOnWhatYouGiveIt")
                          .Options;

            using var assembleContext = new RoomServiceContext(options);
            assembleContext.Database.EnsureCreated();
            var mapper = new DbMapper();

            var newRoom  = PresetEntityRoom(assembleContext);
            var newRoom2 = PresetEntityRoom2(assembleContext);
            var newRoom3 = PresetEntityRoom3(assembleContext);

            assembleContext.Add(newRoom);
            assembleContext.Add(newRoom2);
            assembleContext.Add(newRoom3);
            assembleContext.SaveChanges();

            var endDate = new DateTime(2001, 3, 15);

            using var actContext = new RoomServiceContext(options);
            var repo = new Repository(actContext, mapper);

            //Returns 1 room because there is only 1 room that matches that room number
            var filterRoom1 = await repo.GetFilteredRoomsAsync(_newComplexId, _newRoomNumber, null, null, null, null, null);

            //Returns 2 rooms because there are 2 rooms that are labeld as "Male" gender
            var filterRoom2 = await repo.GetFilteredRoomsAsync(_newComplexId, null, _newNumOfBeds, null, "Male", null, null);

            //Returns 1 room because there is only one room labeled as room type TownHouse
            var filterRoom3 = await repo.GetFilteredRoomsAsync(_newComplexId, null, _newNumOfBeds, "TownHouse", null, null, null);

            //Returns 3 rooms because that is all the rooms witht that complex Id
            var filterRoom4 = await repo.GetFilteredRoomsAsync(_newComplexId, null, null, null, null, null, null);

            //Returns 3 rooms because there are 3 rooms with that many number of beds
            var filterRoom5 = await repo.GetFilteredRoomsAsync(_newComplexId, null, _newNumOfBeds, null, null, null, null);

            //Returns 0 rooms because there are no rooms whose lease are greater than the end date
            var filterRoom6 = await repo.GetFilteredRoomsAsync(_newComplexId, null, null, null, null, DateTime.Now, null);

            //Returns 1 room
            var filterRoom7 = await repo.GetFilteredRoomsAsync(_newComplexId, null, null, null, null, null, _newRoomId);

            Assert.Equal(_newRoomNumber, filterRoom1.FirstOrDefault(r => r.RoomNumber == _newRoomNumber).RoomNumber);

            Assert.Equal(2, filterRoom2.Count(r => r.Gender == "Male"));

            //Assert.Equal("TownHouse", filterRoom3.FirstOrDefault(r => r.RoomType == "TownHouse").RoomType);

            Assert.Equal(1, filterRoom3.Count(r => r.RoomType == "TownHouse"));

            //Assert.Equal(newComplexId, filterRoom4.FirstOrDefault(r => r.ComplexId == newComplexId).ComplexId);

            Assert.Equal(3, filterRoom4.Count(r => r.ComplexId == _newComplexId));

            Assert.Equal(3, filterRoom5.Count(r => r.NumberOfBeds == _newNumOfBeds));

            Assert.True(filterRoom6.Count() == 0);

            Assert.True(filterRoom7.Count() == 1);
        }