示例#1
0
        public void CanMoveFurnitureToAnotherRoom()
        {
            int removeEventsInvokedCount = 0;
            Room room = new Room("bedroom", null, (sender, remoed, newRoom) =>
            {
                removeEventsInvokedCount += 1;
            });

            const string sofaType = "Sofa";
            room.CreateFurniture(sofaType);
            room.CreateFurniture(sofaType);
            const string wardrobeType = "Wardrobe";
            room.CreateFurniture(wardrobeType);
            IList<Furniture> furnitures = room.GetFurnitures();
            Assert.AreEqual(3, furnitures.Count);

            Room anotherRoom = new Room("living room", null, null);
            room.Move(sofaType, anotherRoom);
            Assert.AreEqual(1, removeEventsInvokedCount--, "There are no event invoked when furniture was moved");
            IList<Furniture> anotherRoomfurnitures = anotherRoom.GetFurnitures();
            Assert.AreEqual(2, furnitures.Count);
            Assert.AreEqual(1, anotherRoomfurnitures.Count);

            room.Move(sofaType, anotherRoom);
            Assert.AreEqual(1, removeEventsInvokedCount--, "There are no event invoked when furniture was moved");
            Assert.AreEqual(1, furnitures.Count);
            Assert.AreEqual(2, anotherRoomfurnitures.Count);

            room.Move(wardrobeType, anotherRoom);
            Assert.AreEqual(1, removeEventsInvokedCount--, "There are no event invoked when furniture was moved");
            Assert.AreEqual(0, furnitures.Count);
            Assert.AreEqual(3, anotherRoomfurnitures.Count);
        }
示例#2
0
 public void CantMoveNotExistentFurniture()
 {
     Room room = new Room("bedroom", null, null);
     Room anotherRoom = new Room("room", null, null);
     room.Move("nonexistent furniture", anotherRoom);
 }
示例#3
0
 public void NothingHappendWhenMovingFurnitureToSameRoom()
 {
     int addEventsInvokedCount = 0;
     int removeEventsInvokedCount = 0;
     Room room = new Room("bedroom", (sender, added) =>
     {
         addEventsInvokedCount += 1;
     }, (sender, remoed, newRoom) =>
     {
         removeEventsInvokedCount += 1;
     });
     const string sofaType = "Sofa";
     room.CreateFurniture(sofaType);
     room.Move(sofaType, room);
     Assert.AreEqual(1, addEventsInvokedCount);
     Assert.AreEqual(0, removeEventsInvokedCount);
 }