コード例 #1
0
        public async Task CreateShouldSucceed()
        {
            // Arrange
            var id               = Guid.NewGuid();
            var name             = "name";
            var description      = "description";
            var icon             = Guid.NewGuid();
            var shuffleQuestions = false;
            var tag              = new Tag("tag");

            var questionId            = Guid.NewGuid();
            var quesitonChecklistId   = id;
            var questionContent       = "content";
            var questionIntroduction  = "introduction";
            var questionImage         = "image";
            var questionVideo         = "video";
            var questionSequence      = true;
            var questionShuffleAnswer = false;
            var questionRequired      = false;
            var questionLinksTo       = Guid.NewGuid();
            var question = new Question(id, quesitonChecklistId, questionContent, questionIntroduction, questionImage, questionVideo, QuestionType.SingleChoice, questionSequence, questionShuffleAnswer, questionRequired, questionLinksTo);

            var checklist = new Checklist(id, name, description, icon, shuffleQuestions);

            checklist.AddTag(tag);
            checklist.AddQuestion(question);

            // Act
            await _repository.CreateAsync(checklist);

            // Assert
            var data = RepositoryHelper.ForChecklist.GetChecklists();

            data.Should().HaveCount(1);
            var result = data.First();

            result.Name.Should().Be(name);
            result.Description.Should().Be(description);
            result.Icon.Should().Be(icon);
            result.ShuffleQuestions.Should().Be(shuffleQuestions);
            result.Tags.Should().NotBeNull();
            result.Tags.Count().Should().Be(1);
            result.Tags.First().Should().Be(tag);

            result.Questions.Should().NotBeNull();
            result.Questions.Count().Should().Be(1);
            result.Questions.First().Should().Be(question);
        }