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 ShouldGetVaildResponseForStepValidateRequest() { var request = new StepValidateRequest { StepText = "step_text_1", NumberOfParameters = 0 }; _mockStepRegistry.Setup(registry => registry.ContainsStep("step_text_1")).Returns(true); _mockStepRegistry.Setup(registry => registry.HasMultipleImplementations("step_text_1")).Returns(false); var processor = new StepValidationProcessor(_mockStepRegistry.Object); var response = processor.Process(request); Assert.AreEqual(true, response.IsValid); }
public void ShouldGetStepsFromReference(string stepText, string stepValue, string parameterizedStepValue) { var assemblies = new AssemblyLocater(new DirectoryWrapper(), new FileWrapper()).GetAllAssemblies(); var assemblyLoader = new AssemblyLoader(new AssemblyWrapper(), assemblies, new ReflectionWrapper(), new ActivatorWrapper(), new StepRegistry()); var stepValidationProcessor = new StepValidationProcessor(assemblyLoader.GetStepRegistry()); var message = new StepValidateRequest { StepText = stepText, StepValue = new ProtoStepValue { StepValue = stepValue, ParameterizedStepValue = parameterizedStepValue }, NumberOfParameters = 1, }; var result = stepValidationProcessor.Process(message); Assert.IsTrue(result.IsValid, $"Expected valid step text, got error: {result.ErrorMessage}"); }
public void ShouldGetStepsFromReference(string referenceType, string stepText, string stepValue, string parameterizedStepValue) { Environment.SetEnvironmentVariable("GAUGE_PROJECT_ROOT", TestUtils.GetIntegrationTestSampleDirectory(referenceType)); var path = new AssemblyLocater(new DirectoryWrapper()).GetTestAssembly(); var assemblyLoader = new AssemblyLoader(path, new GaugeLoadContext(path), new ReflectionWrapper(), new ActivatorWrapper(), new StepRegistry()); var stepValidationProcessor = new StepValidationProcessor(assemblyLoader.GetStepRegistry()); var message = new StepValidateRequest { StepText = stepText, StepValue = new ProtoStepValue { StepValue = stepValue, ParameterizedStepValue = parameterizedStepValue }, NumberOfParameters = 1, }; var result = stepValidationProcessor.Process(message); Assert.IsTrue(result.IsValid, $"Expected valid step text, got error: {result.ErrorMessage}"); }
public void ShouldGetErrorResponseForStepValidateRequestWhenMultipleStepImplFound() { var request = new StepValidateRequest { StepText = "step_text_1", NumberOfParameters = 0 }; _mockStepRegistry.Setup(registry => registry.ContainsStep("step_text_1")).Returns(true); _mockStepRegistry.Setup(registry => registry.HasMultipleImplementations("step_text_1")).Returns(true); var processor = new StepValidationProcessor(_mockStepRegistry.Object); var response = processor.Process(request); Assert.AreEqual(false, response.IsValid); Assert.AreEqual(StepValidateResponse.Types.ErrorType.DuplicateStepImplementation, response.ErrorType); Assert.AreEqual("Multiple step implementations found for : step_text_1", response.ErrorMessage); Assert.IsEmpty(response.Suggestion); }
public void ShouldGetErrorResponseForStepValidateRequestWhennNoImplFound() { var request = new StepValidateRequest { StepText = "step_text_1", NumberOfParameters = 0, StepValue = new ProtoStepValue { ParameterizedStepValue = "step_text_1", StepValue = "step_text_1" } }; var processor = new StepValidationProcessor(_mockStepRegistry.Object); var response = processor.Process(request); Assert.AreEqual(false, response.IsValid); Assert.AreEqual(StepValidateResponse.Types.ErrorType.StepImplementationNotFound, response.ErrorType); StringAssert.Contains("No implementation found for : step_text_1.", response.ErrorMessage); StringAssert.Contains("[Step(\"step_text_1\")]", response.Suggestion); }