Ejemplo n.º 1
0
        public void ShouldProcessMessage()
        {
            var message = new Message
            {
                MessageId   = 1234,
                MessageType = Message.Types.MessageType.StubImplementationCodeRequest,
                StubImplementationCodeRequest = new StubImplementationCodeRequest
                {
                    ImplementationFilePath = "New File",
                    Codes =
                    {
                        "method"
                    }
                }
            };

            var processor = new StubImplementationCodeProcessor();
            var result    = processor.Process(message);

            Assert.AreEqual("StepImplementation1.cs", Path.GetFileName(result.FileDiff.FilePath));
            Assert.AreEqual(1, result.FileDiff.TextDiffs.Count);
            Assert.True(result.FileDiff.TextDiffs[0].Content.Contains("namespace IntegrationTestSample"));
            Assert.True(result.FileDiff.TextDiffs[0].Content.Contains("class StepImplementation1"));
            Assert.AreEqual(result.FileDiff.TextDiffs[0].Span.Start, 0);
        }
Ejemplo n.º 2
0
        public void ShouldProcessMessageForExistingButEmptyFile()
        {
            var file    = Path.Combine(TestUtils.GetIntegrationTestSampleDirectory(), "Empty.cs");
            var message = new Message
            {
                MessageId   = 1234,
                MessageType = Message.Types.MessageType.StubImplementationCodeRequest,
                StubImplementationCodeRequest = new StubImplementationCodeRequest
                {
                    ImplementationFilePath = file,
                    Codes =
                    {
                        "Step Method"
                    }
                }
            };

            var processor = new StubImplementationCodeProcessor();
            var result    = processor.Process(message).FileDiff;

            Assert.AreEqual(1, result.TextDiffs.Count);
            Assert.True(result.TextDiffs[0].Content.Contains("namespace IntegrationTestSample"));
            Assert.True(result.TextDiffs[0].Content.Contains("class Empty"));
            StringAssert.Contains("Step Method", result.TextDiffs[0].Content);
            Assert.AreEqual(result.TextDiffs[0].Span.Start, 0);
        }
Ejemplo n.º 3
0
 private void InitializeMessageProcessors()
 {
     this.stepValidateRequestProcessor           = new StepValidationProcessor(_stepRegistry);
     this.stepNameRequestProcessor               = new StepNameProcessor(_stepRegistry);
     this.refactorRequestProcessor               = new RefactorProcessor(_stepRegistry);
     this.cacheFileRequestProcessor              = new CacheFileProcessor(_loader);
     this.stubImplementationCodeRequestProcessor = new StubImplementationCodeProcessor();
     this.stepPositionsRequestProcessor          = new StepPositionsProcessor(_stepRegistry);
     this.stepNamesRequestProcessor              = new StepNamesProcessor(_stepRegistry);
 }
        public void ShouldProcessMessageForExistingClass()
        {
            var file    = Path.Combine(TestUtils.GetIntegrationTestSampleDirectory(), "StepImplementation.cs");
            var message = new StubImplementationCodeRequest
            {
                ImplementationFilePath = file,
                Codes =
                {
                    "Step Method"
                }
            };

            var processor = new StubImplementationCodeProcessor();
            var result    = processor.Process(message);

            Assert.AreEqual(1, result.TextDiffs.Count);
            StringAssert.Contains("Step Method", result.TextDiffs[0].Content);
            Assert.AreEqual(result.TextDiffs[0].Span.Start, 115);
        }
Ejemplo n.º 5
0
        public void ShouldProcessMessageForExistingClass()
        {
            var file    = Path.Combine(_testProjectPath, "StepImplementation.cs");
            var message = new StubImplementationCodeRequest
            {
                ImplementationFilePath = file,
                Codes =
                {
                    "Step Method"
                }
            };

            var processor = new StubImplementationCodeProcessor();
            var result    = processor.Process(message);

            Assert.AreEqual(1, result.TextDiffs.Count);
            StringAssert.Contains("Step Method", result.TextDiffs[0].Content);
            Assert.AreEqual(107, result.TextDiffs[0].Span.Start);
        }
        public void ShouldProcessMessage()
        {
            var message = new StubImplementationCodeRequest
            {
                ImplementationFilePath = "New File",
                Codes =
                {
                    "method"
                }
            };

            var processor = new StubImplementationCodeProcessor();
            var result    = processor.Process(message);

            Assert.AreEqual("StepImplementation1.cs", Path.GetFileName(result.FilePath));
            Assert.AreEqual(1, result.TextDiffs.Count);
            Console.WriteLine(result.TextDiffs[0].Content);
            Assert.True(result.TextDiffs[0].Content.Contains("namespace Sample"));
            Assert.True(result.TextDiffs[0].Content.Contains("class StepImplementation1"));
            Assert.AreEqual(result.TextDiffs[0].Span.Start, 0);
        }
Ejemplo n.º 7
0
        public void ShouldProcessMessageForExistingButEmptyFile()
        {
            var file    = Path.Combine(_testProjectPath, "Empty.cs");
            var message = new StubImplementationCodeRequest
            {
                ImplementationFilePath = file,
                Codes =
                {
                    "Step Method"
                }
            };

            var processor = new StubImplementationCodeProcessor();
            var result    = processor.Process(message);

            Assert.AreEqual(1, result.TextDiffs.Count);
            Assert.True(result.TextDiffs[0].Content.Contains("namespace Sample"));
            Assert.True(result.TextDiffs[0].Content.Contains("class Empty"));
            StringAssert.Contains("Step Method", result.TextDiffs[0].Content);
            Assert.AreEqual(result.TextDiffs[0].Span.Start, 0);
        }