예제 #1
0
        public void NullQuestTest()
        {
            //Arrange
            StartQuestValidator validator = new StartQuestValidator();

            //Act
            ArgumentNullException ex = Assert.Throws <ArgumentNullException>(() => validator.Validate(null));

            //Assert
            Assert.IsNotNull(ex);
            Assert.AreEqual("quest", ex.ParamName);
        }
예제 #2
0
        public void ValidateSuccessfulTest()
        {
            //Arrange
            StartQuestValidator validator = new StartQuestValidator();
            Quest quest = QuestHelper.CreateQuest(State.Idle);

            //Act
            StringResponse result = validator.Validate(quest);

            //Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.IsSuccessful);
        }
예제 #3
0
        public void ValidateFailedQuestTest()
        {
            //Arrange
            StartQuestValidator validator = new StartQuestValidator();
            Quest quest = QuestHelper.CreateQuest(State.Failed);

            //Act
            StringResponse result = validator.Validate(quest);

            //Assert
            Assert.IsNotNull(result);
            Assert.IsFalse(result.IsSuccessful);
            Assert.AreEqual(1, result.Errors.Count);
            Assert.AreEqual("ERR_QUEST_ACT_WRONG_STATE", result.Errors[0]);
        }
예제 #4
0
        public void ValidateReadyQuestWithChildren()
        {
            //Arrange
            StartQuestValidator validator = new StartQuestValidator();
            Quest quest = QuestHelper.CreateQuest(State.Idle);

            quest.Children.Add(QuestHelper.CreateQuest(State.Idle));

            //Act
            StringResponse result = validator.Validate(quest);

            //Assert
            Assert.IsNotNull(result);
            Assert.IsFalse(result.IsSuccessful);
            Assert.AreEqual(1, result.Errors.Count);
            Assert.AreEqual("ERR_QUEST_ACT_HAS_CHILDREN", result.Errors[0]);
        }