public void SupportsQueryCommand() { HomeState state = new HomeState(); state.CreateFurniture("sofa","room",new DateTime(2015,12,01)); Mock<TextWriter> writerMock = new Mock<TextWriter>(); CommandProcessor processor = new CommandProcessor(state, writerMock.Object); string command = "query -date 01.12.2015"; processor.Process(command); writerMock.Verify(w=>w.WriteLine(It.IsAny<string>())); }
public void CanCreateFurniture() { HomeState stateHolder = new HomeState(); DateTime date = new DateTime(2015, 01, 01); const string roomName = "bedroom"; const string furnitureName = "sofa"; stateHolder.CreateFurniture(furnitureName, roomName, date); Assert.AreEqual(1, stateHolder.GetRoomsList(date).Count); Assert.AreEqual(roomName, stateHolder.GetRoomsList(date).First().Name); Assert.AreEqual(1, stateHolder.GetRoomsList(date).First().GetFurnitures().Count); Assert.AreEqual(furnitureName, stateHolder.GetRoomsList(date).First().GetFurnitures().First().Type); stateHolder.CreateFurniture(furnitureName, roomName, date); Assert.AreEqual(1, stateHolder.GetRoomsList(date).Count); Assert.AreEqual(roomName, stateHolder.GetRoomsList(date).First().Name); Assert.AreEqual(2, stateHolder.GetRoomsList(date).First().GetFurnitures().Count); Assert.AreEqual(furnitureName, stateHolder.GetRoomsList(date).First().GetFurnitures().First().Type); Assert.AreEqual(furnitureName, stateHolder.GetRoomsList(date).First().GetFurnitures().Last().Type); }
public void CanGetHomeChangeDates() { HomeState stateHolder = new HomeState(); DateTime date = new DateTime(2015, 01, 01); const string roomName = "bedroom"; const string furnitureName = "sofa"; stateHolder.CreateFurniture(furnitureName, roomName, date); var dates = stateHolder.GetHomeChangeDates(); Assert.IsNotNull(dates); Assert.AreEqual(1, dates.Count); Assert.AreEqual(date, dates.First()); DateTime anotherDate = new DateTime(2015, 01, 02); stateHolder.CreateFurniture(furnitureName, roomName, anotherDate); dates = stateHolder.GetHomeChangeDates(); Assert.IsNotNull(dates); Assert.AreEqual(2, dates.Count); Assert.IsTrue(dates.Contains(date)); Assert.IsTrue(dates.Contains(anotherDate)); }
public void CanMoveFurniture() { HomeState stateHolder = new HomeState(); DateTime date = new DateTime(2015, 01, 01); const string roomName = "bedroom"; const string anotherRoom = "anotherRoom"; const string furnitureName = "sofa"; stateHolder.CreateFurniture(furnitureName, roomName, date); stateHolder.CreateRoom(anotherRoom, date); stateHolder.MoveFurniture(furnitureName, roomName, anotherRoom, date); }