public async Task Execute_Invokes_All_StepMethods() { //arrange. var featureInstance = new FeatureWithStepMethodsToInvoke(); var sut = new Scenario(String.Empty, new List <StepMethod> { StepMethod.FromStepMethodInfo(StepMethodInfo.FromMethodInfo(featureInstance.GetType().GetMethod(nameof(FeatureWithStepMethodsToInvoke.ScenarioStep1)), featureInstance), new Gherkin.Ast.Step(null, "Given", FeatureWithStepMethodsToInvoke.ScenarioStep1Text, null)), StepMethod.FromStepMethodInfo(StepMethodInfo.FromMethodInfo(featureInstance.GetType().GetMethod(nameof(FeatureWithStepMethodsToInvoke.ScenarioStep2)), featureInstance), new Gherkin.Ast.Step(null, "And", FeatureWithStepMethodsToInvoke.ScenarioStep2Text, null)), StepMethod.FromStepMethodInfo(StepMethodInfo.FromMethodInfo(featureInstance.GetType().GetMethod(nameof(FeatureWithStepMethodsToInvoke.ScenarioStep3)), featureInstance), new Gherkin.Ast.Step(null, "When", FeatureWithStepMethodsToInvoke.ScenarioStep3Text, null)), StepMethod.FromStepMethodInfo(StepMethodInfo.FromMethodInfo(featureInstance.GetType().GetMethod(nameof(FeatureWithStepMethodsToInvoke.ScenarioStep4)), featureInstance), new Gherkin.Ast.Step(null, "Then", FeatureWithStepMethodsToInvoke.ScenarioStep4Text, null)) }); var output = new Mock <IScenarioOutput>(); //act. await sut.ExecuteAsync(featureInstance, output.Object); //assert. Assert.NotNull(featureInstance.CallStack); Assert.Equal(4, featureInstance.CallStack.Count); Assert.Equal(nameof(FeatureWithStepMethodsToInvoke.ScenarioStep1), featureInstance.CallStack[0]); output.Verify(o => o.StepPassed("Given " + FeatureWithStepMethodsToInvoke.ScenarioStep1Text), Times.Once); Assert.Equal(nameof(FeatureWithStepMethodsToInvoke.ScenarioStep2), featureInstance.CallStack[1]); output.Verify(o => o.StepPassed("And " + FeatureWithStepMethodsToInvoke.ScenarioStep2Text), Times.Once); Assert.Equal(nameof(FeatureWithStepMethodsToInvoke.ScenarioStep3), featureInstance.CallStack[2]); output.Verify(o => o.StepPassed("When " + FeatureWithStepMethodsToInvoke.ScenarioStep3Text), Times.Once); Assert.Equal(nameof(FeatureWithStepMethodsToInvoke.ScenarioStep4), featureInstance.CallStack[3]); output.Verify(o => o.StepPassed("Then " + FeatureWithStepMethodsToInvoke.ScenarioStep4Text), Times.Once); }
public async Task Execute_Invokes_Successfult_StepMethods_And_Skips_The_Rest() { //arrange. var featureInstance = new FeatureWithStepMethodsToInvoke_And_Throwing(); var sut = new Scenario(String.Empty, new List <StepMethod> { StepMethod.FromStepMethodInfo(StepMethodInfo.FromMethodInfo(featureInstance.GetType().GetMethod(nameof(FeatureWithStepMethodsToInvoke_And_Throwing.ScenarioStep1)), featureInstance), new Gherkin.Ast.Step(null, "Given", FeatureWithStepMethodsToInvoke_And_Throwing.ScenarioStep1Text, null)), StepMethod.FromStepMethodInfo(StepMethodInfo.FromMethodInfo(featureInstance.GetType().GetMethod(nameof(FeatureWithStepMethodsToInvoke_And_Throwing.ScenarioStep2)), featureInstance), new Gherkin.Ast.Step(null, "And", FeatureWithStepMethodsToInvoke_And_Throwing.ScenarioStep2Text, null)), StepMethod.FromStepMethodInfo(StepMethodInfo.FromMethodInfo(featureInstance.GetType().GetMethod(nameof(FeatureWithStepMethodsToInvoke_And_Throwing.ScenarioStep3)), featureInstance), new Gherkin.Ast.Step(null, "When", FeatureWithStepMethodsToInvoke_And_Throwing.ScenarioStep3Text, null)), StepMethod.FromStepMethodInfo(StepMethodInfo.FromMethodInfo(featureInstance.GetType().GetMethod(nameof(FeatureWithStepMethodsToInvoke_And_Throwing.ScenarioStep4)), featureInstance), new Gherkin.Ast.Step(null, "Then", FeatureWithStepMethodsToInvoke_And_Throwing.ScenarioStep4Text, null)) }); var output = new Mock <IScenarioOutput>(); //act. var exception = await Assert.ThrowsAsync <TargetInvocationException>(async() => await sut.ExecuteAsync(featureInstance, output.Object)); Assert.IsType <InvalidOperationException>(exception.InnerException); //assert. Assert.NotNull(featureInstance.CallStack); Assert.Equal(2, featureInstance.CallStack.Count); Assert.Equal(nameof(FeatureWithStepMethodsToInvoke_And_Throwing.ScenarioStep1), featureInstance.CallStack[0]); output.Verify(o => o.StepPassed("Given " + FeatureWithStepMethodsToInvoke_And_Throwing.ScenarioStep1Text), Times.Once); Assert.Equal(nameof(FeatureWithStepMethodsToInvoke_And_Throwing.ScenarioStep2), featureInstance.CallStack[1]); output.Verify(o => o.StepFailed("And " + FeatureWithStepMethodsToInvoke_And_Throwing.ScenarioStep2Text), Times.Once); output.Verify(o => o.StepSkipped("When " + FeatureWithStepMethodsToInvoke_And_Throwing.ScenarioStep3Text), Times.Once); output.Verify(o => o.StepSkipped("Then " + FeatureWithStepMethodsToInvoke_And_Throwing.ScenarioStep4Text), Times.Once); }
private void btnRunAnalize_Click(object sender, RoutedEventArgs e) { StepMethod sm = new StepMethod(); Statement state = sm.Analise(txtFirstProg.Text, txtSecondProg.Text, int.Parse(txtBoxNgramm.Text)); lblShingle.Content = (Math.Round(state.ShingleMethod * 100, 2)).ToString() + "%"; lblVagnerFischer.Content = (Math.Round(state.LevenshteynMethod * 100, 2)).ToString() + "%"; }
//// Saved image and Windows command //public Step( // string instruction, // string picturePath, // byte[] picture, // string command) //{ // SetDefaults(); // Instruction = instruction; // PicturePath = picturePath; // Picture = picture; // Command = command; //} // Method determines passing criteria public Step( string instruction, string picturePath, StepMethod method) { SetDefaults(); Instruction = instruction; PicturePath = picturePath; Method = method; }
// Method determines passing criteria public Step( string instruction, string picturePath, StepMethod method) { SetDefaults(); Instruction = instruction; PicturePath = picturePath; Method = method; }
public void FromStepMethodInfo_Throws_When_Method_Cannot_Match_Pattern() { //arrange. var featureInstance = new Feature_For_FromStepMethodInfo(); var stepMethodInfo = StepMethodInfo.FromMethodInfo( featureInstance.GetType().GetMethod(nameof(Feature_For_FromStepMethodInfo.Step_With_Multiple_Patterns)), featureInstance ); //act / assert. Assert.Throws <InvalidOperationException>(() => StepMethod.FromStepMethodInfo(stepMethodInfo, new Gherkin.Ast.Step(null, "Given", "something else NOT", null))); }
public void Ctor_Initializes_Properties() { //arrange. var featureInstance = new Feature_For_Ctor_Test(); var stepMethodInfo = StepMethodInfo.FromMethodInfo(featureInstance.GetType().GetMethod(nameof(Feature_For_Ctor_Test.But_This_Method)), featureInstance); var stepText = "some step text"; var sut = new StepMethod(stepMethodInfo, stepText); //act. Assert.Same(stepText, sut.StepText); Assert.Equal(stepMethodInfo.Kind, sut.Kind); }
public void ResetState() { //Destroy(gameObject); Prize.gameObject.SetActive(false); gameObject.SetActive(false); Id = 0; Removing = false; transform.parent = null; transform.position = Vector3.zero; transform.rotation = Quaternion.identity; OnRemoved = null; }
private void Switch(StepMethod method) { if (_weapons == null || _weapons.Count == 0) { return; } _weapons[_indexOfActive].gameObject.SetActive(false); method(); _weapons[_indexOfActive].gameObject.SetActive(true); }
public async Task ExecuteAsync_Executes_StepMethodInfo() { //arrange. var featureInstance = new Feature_For_ExecuteAsync_Test(); var stepMethodInfo = StepMethodInfo.FromMethodInfo(featureInstance.GetType().GetMethod(nameof(Feature_For_ExecuteAsync_Test.But_This_Method)), featureInstance); var sut = new StepMethod(stepMethodInfo, "some step text"); //act. await sut.ExecuteAsync(); //assert. Assert.True(featureInstance.Called); }
public async Task ExecuteAsync_Executes_StepMethodInfo() { //arrange. var featureInstance = new Feature_For_ExecuteAsync_Test(); var stepMethodInfo = StepMethodInfo.FromMethodInfo(featureInstance.GetType().GetMethod(nameof(Feature_For_ExecuteAsync_Test.But_This_Method)), featureInstance); var sut = StepMethod.FromStepMethodInfo(stepMethodInfo, new Gherkin.Ast.Step(null, "But", "what 123 exactly", null)); //act. await sut.ExecuteAsync(); //assert. Assert.True(featureInstance.Called); Assert.Equal(123, featureInstance.Value); }
public void FromStepMethodInfo_Creates_Instance() { //arrange. var featureInstance = new Feature_For_FromStepMethodInfo(); var stepMethodInfo = StepMethodInfo.FromMethodInfo( featureInstance.GetType().GetMethod(nameof(Feature_For_FromStepMethodInfo.Step_With_Multiple_Patterns)), featureInstance ); //act. var sut = StepMethod.FromStepMethodInfo(stepMethodInfo, new Gherkin.Ast.Step(null, "Given", "something 123 else", null)); //assert. Assert.NotNull(sut); Assert.Equal(stepMethodInfo.ScenarioStepPatterns[1].Kind, sut.Kind); Assert.Equal(stepMethodInfo.ScenarioStepPatterns[1].Pattern, sut.Pattern); Assert.Equal("something 123 else", sut.StepText); }
public static SagaStep <T> Create(StepMethod <T> executeMethod) { return(new SagaStep <T>(executeMethod, (ctx) => Task.FromResult(ctx))); }
public static SagaStep <T> Create(StepMethod <T> executeMethod, StepMethod <T> rollbackMethod) { return(new SagaStep <T>(executeMethod, rollbackMethod)); }
public SagaStep(StepMethod <T> executeMethod, StepMethod <T> rollbackMethod) : base(executeMethod, rollbackMethod) { }
public ISagaStep <StepMethod <T> > AddStep(StepMethod <T> step) { return(this.AddStep(SagaStep <T> .Create(step))); }