public void NotDuplicatePlayers() { // Arrange var fakeRoad = A.Fake <IAdventureLocation>(); var fakeDungeon = A.Fake <IDungeon>(); A.CallTo(() => fakeDungeon.GetStartingLocation()).Returns(fakeRoad); var fakeChatClient = A.Fake <IChatClient>(); var eventArgs = new ChatCommandEventArgs("!adv", new List <string>(), string.Empty, "PlayerOne", "Player1", string.Empty); var sut = new AdventureGame(fakeDungeon); // Act sut.HandleCommand(fakeChatClient, eventArgs); sut.HandleCommand(fakeChatClient, eventArgs); // Assert Assert.AreEqual(1, sut.Players.Count); }
public void AllowsMultiplePlayers() { // Arrange var fakeRoad = A.Fake <IAdventureLocation>(); var fakeDungeon = A.Fake <IDungeon>(); A.CallTo(() => fakeDungeon.GetStartingLocation()).Returns(fakeRoad); var fakeChatClient = A.Fake <IChatClient>(); var eventArgs1 = new ChatCommandEventArgs("!adv", new List <string>(), string.Empty, "Bill", "Player1", string.Empty); var eventArgs2 = new ChatCommandEventArgs("!adv", new List <string>(), string.Empty, "Bob", "Player2", string.Empty); var eventArgs3 = new ChatCommandEventArgs("!adv", new List <string>(), string.Empty, "Bill", "Player3", string.Empty); var sut = new AdventureGame(fakeDungeon); // Act sut.HandleCommand(fakeChatClient, eventArgs1); sut.HandleCommand(fakeChatClient, eventArgs2); sut.HandleCommand(fakeChatClient, eventArgs3); // Assert Assert.AreEqual(3, sut.Players.Count); }
public Task Execute(IChatClient chatClient, ChatCommandEventArgs e) { lock (_mutex) { if (chatClient.GetType().ToString() == e.ClientType) { if (_adventureGame is null) { _adventureGame = new AdventureGame(); } _adventureGame.HandleCommand(chatClient, e); } } return(null); }