Beispiel #1
0
 public void CanRemoveRoomWithoutFurniture()
 {
     HomeState stateHolder = new HomeState();
     DateTime date = DateTime.Now;
     const string roomName = "bedroom";
     stateHolder.CreateRoom(roomName, date);
     stateHolder.RemoveRoom(roomName, null, date);
     Assert.AreEqual(0, stateHolder.GetHistory()[date].GetRooms().Count);
     stateHolder.CreateRoom(roomName, date);
     stateHolder.RemoveRoom(roomName, roomName, date);
     Assert.AreEqual(0, stateHolder.GetHistory()[date].GetRooms().Count);
 }
Beispiel #2
0
        public void CreateRoomShouldCreateNewStateIfDateNotExists()
        {
            HomeState stateHolder = new HomeState();
            const string roomName = "bedroom";
            DateTime date = new DateTime(2015, 01, 05);
            stateHolder.CreateRoom(roomName, date);
            var history = stateHolder.GetHistory();

            Assert.AreEqual(1, history.Count);

            Assert.AreEqual(date, history.First().Key);
            Assert.IsNotNull(history.First().Value);
            Assert.AreEqual(1, history.First().Value.GetRooms().Count);
            Assert.AreEqual(roomName, history.First().Value.GetRooms().First().Name);

            DateTime newDate = new DateTime(2015, 01, 06);
            stateHolder.CreateRoom(roomName, newDate);
            Assert.AreEqual(2, history.Count);

            newDate = new DateTime(2014, 01, 01);
            stateHolder.CreateRoom(roomName, newDate);
            Assert.AreEqual(3, history.Count);
        }
Beispiel #3
0
        public void CreateRoomShouldCreateRoomInExistingState()
        {
            HomeState stateHolder = new HomeState();
            const string roomName = "bedroom";
            DateTime date = new DateTime(2015, 01, 05);
            stateHolder.CreateRoom(roomName, date);
            var history = stateHolder.GetHistory();

            Assert.AreEqual(1, history.Count);
            stateHolder.CreateRoom(roomName, date);
            Assert.AreEqual(1, history.Count);
            Assert.AreEqual(2, history.First().Value.GetRooms().Count);
        }
Beispiel #4
0
        public void CreateRoomShouldContainAllRoomsFromPreviousState()
        {
            HomeState stateHolder = new HomeState();
            const string roomName = "bedroom";
            DateTime date = new DateTime(2015, 01, 05);
            stateHolder.CreateRoom(roomName, date);
            var history = stateHolder.GetHistory();

            Assert.AreEqual(1, history.Count);
            DateTime newDate = new DateTime(2015, 01, 06);
            stateHolder.CreateRoom(roomName, newDate);

            Assert.AreEqual(2, history.Count);
            Assert.AreEqual(2, history.Last().Value.GetRooms().Count);
        }