Exemple #1
0
        public EngineTests()
        {
            var outputWriterMock = new Mock <IQaApiPublisher>();

            outputWriterMock.Setup(o => o.Publish(It.IsAny <QaApiContent>()))
            .Callback <QaApiContent>(content => _lastResult = content);

            _sut = new Engine(outputWriterMock.Object);
        }
Exemple #2
0
        public void SkipUpdateQuestionWhenOlder()
        {
            const int qId = 1;

            _sut.UpsertQuestion(qId, 2, 0, "question v2");

            _sut.AddAnswer(qId, 0, "a1");
            _sut.AddAnswer(qId, 0, "a2");

            _sut.UpsertQuestion(qId, 1, 0, "oldest one");

            var expected = new QaApiContent
            {
                QuestionId = qId.ToString(),
                Question   = "question v2",
                Answers    = new List <string> {
                    "a1",
                    "a2"
                }
            };

            _lastResult.Should().BeEquivalentTo(expected);
        }
Exemple #3
0
        public void UpdateQuestionText()
        {
            const int qId = 1;

            _sut.UpsertQuestion(qId, 1, 0, "How to build a project?");

            _sut.AddAnswer(qId, 0, "Press F6");
            _sut.AddAnswer(qId, 0, "Right click on solution and then click Build.");

            _sut.UpsertQuestion(qId, 2, 0, "How to build a solution?");

            var expected = new QaApiContent
            {
                QuestionId = qId.ToString(),
                Question   = "How to build a solution?",
                Answers    = new List <string> {
                    "Press F6",
                    "Right click on solution and then click Build."
                }
            };

            _lastResult.Should().BeEquivalentTo(expected);
        }
Exemple #4
0
        public void Publish(QaApiContent content)
        {
            var filepath = Path.Combine(_configuration.PublicationPath, "Questions", content.QuestionId);

            File.WriteAllText(filepath, JsonConvert.SerializeObject(content));
        }