コード例 #1
0
        public void TestCanCreateRoomWithNullCode()
        {
            var chameleonGame = new Mock <IChameleonGame>();
            var roomJoiner    = new RoomJoiner(chameleonGame.Object);

            const string requestBody = "{\"PersonName\": \"Anita\", \"RoomCode\": null}";

            roomJoiner.Join(requestBody);

            chameleonGame.Verify(x => x.CreateRoom("Anita"), Times.Once);
        }
コード例 #2
0
        public void TestErrorsIfPersonNameIsEmpty()
        {
            var chameleonGame = new Mock <IChameleonGame>();
            var roomJoiner    = new RoomJoiner(chameleonGame.Object);

            const string requestBody = "{\"PersonName\": \"\", \"RoomCode\": \"ABCD\"}";

            Assert.Throws <PersonNameMustBeSpecifiedException>(() => { roomJoiner.Join(requestBody); });

            chameleonGame.Verify(x => x.CreateRoom(It.IsAny <string>()), Times.Never);
            chameleonGame.Verify(x => x.JoinRoom(It.IsAny <string>(), It.IsAny <string>()), Times.Never);
        }