public void ConnectToBadPoint() { MessageBus bus = new MessageBus(); using (RoomMap map = new RoomMap(bus)) using (RoomMap mapWrong = new RoomMap(bus)) { var rightP = map.Add(new TestRoom(bus)); var wrongP = mapWrong.Add(new TestRoom(bus)); Action act = () => rightP.ConnectTo(wrongP, "north"); act.Should().Throw <ArgumentException>() .WithMessage("The point is not part of this map.*") .Which.ParamName.Should().Be("target"); } }
public void GoAfterDispose() { MessageBus bus = new MessageBus(); List <string> messages = new List <string>(); bus.Subscribe <OutputMessage>(m => messages.Add(m.Text)); using (RoomMap map = new RoomMap(bus)) { RoomMap.Point p1 = map.Add(new TestRoom(bus, "red")); map.Start(p1); } bus.Send(new GoMessage("nowhere")); messages.Should().Equal("You are in a red test room."); }
public void ConnectRoomToItself() { MessageBus bus = new MessageBus(); List <string> messages = new List <string>(); bus.Subscribe <OutputMessage>(m => messages.Add(m.Text)); using (RoomMap map = new RoomMap(bus)) { var p1 = map.Add(new TestRoom(bus)); p1.ConnectTo(p1, "north"); map.Start(p1); bus.Send(new GoMessage(string.Empty)); bus.Send(new GoMessage("north")); messages.Should().Equal( "You are in a test room.", "You can't go that way.", "You are in a test room."); } }