Esempio n. 1
0
        public void AskQuestion_WithInvalidUserId_ShouldReturnErrorResult()
        {
            //---------------Arrange----------------------

            var question = new QuestionBuilder().Build();

            var command = new AskQuestionCommandBuilder()
                          .WithInvalidUserId("")
                          .Build();

            //---------------Act--------------------------
            var notFound = Assert.ThrowsAsync <Exception>(() => command.AskQuestion(question, new CancellationToken()));

            //---------------Assert-----------------------
            Assert.That(notFound.Message, Is.EqualTo("User not found"));
        }
Esempio n. 2
0
        public void AskQuestion_WithExistingTitle_ShouldReturnErrorResult()
        {
            //---------------Arrange----------------------
            const string title  = "where to buy a strong";
            const string userId = "22";

            var question  = new QuestionBuilder().WithTitle(title).Build();
            var questions = new List <Question>
            {
                new QuestionBuilder().WithTitle(title).Build(),
                new QuestionBuilder().WithTitle(title).Build()
            };

            var command = new AskQuestionCommandBuilder()
                          .WithExistingQuestionTitle(questions).WithInvalidUserId(userId)
                          .Build();

            //---------------Act--------------------------
            var notFound = Assert.ThrowsAsync <Exception>(() => command.AskQuestion(question, new CancellationToken()));

            //---------------Assert-----------------------
            Assert.That(notFound.Message, Is.EqualTo("Title already exist!"));
        }