diff --git a/ClassLibrary1/Entities/Menu.cs b/ClassLibrary1/Entities/Menu.cs new file mode 100644 index 0000000..050a767 --- /dev/null +++ b/ClassLibrary1/Entities/Menu.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using WhatShouldITest.Interfaces; +using WhatShouldITest.Utilities; + +namespace WhatShouldITest.Entities +{ + public class Menu + { + private readonly IMenuItemProvider _menuItemProvider; + + public Menu(IMenuItemProvider menuItemProvider) + { + _menuItemProvider = menuItemProvider; + DailySpecial = MenuUtilities.GetDailySpecial(DateTime.Now.DayOfWeek); + } + + IEnumerable Items { get; } + public string DailySpecial { get; } + } +} diff --git a/ClassLibrary1/Entities/MenuCategory.cs b/ClassLibrary1/Entities/MenuCategory.cs new file mode 100644 index 0000000..801d0c7 --- /dev/null +++ b/ClassLibrary1/Entities/MenuCategory.cs @@ -0,0 +1,12 @@ +namespace WhatShouldITest.Entities +{ + public enum MenuCategory + { + Appetizer, + Soup, + Salad, + Entree, + Dessert, + Drink + } +} diff --git a/ClassLibrary1/Entities/MenuItem.cs b/ClassLibrary1/Entities/MenuItem.cs new file mode 100644 index 0000000..be42028 --- /dev/null +++ b/ClassLibrary1/Entities/MenuItem.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WhatShouldITest.Entities +{ + public class MenuItem + { + public string Name { get; set; } + public string Description { get; set; } + public decimal Price { get; set; } + public MenuCategory Category { get; set; } + } +} diff --git a/ClassLibrary1/Interfaces/IMenuItemProvider.cs b/ClassLibrary1/Interfaces/IMenuItemProvider.cs new file mode 100644 index 0000000..2f32182 --- /dev/null +++ b/ClassLibrary1/Interfaces/IMenuItemProvider.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using WhatShouldITest.Entities; + +namespace WhatShouldITest.Interfaces +{ + public interface IMenuItemProvider + { + IEnumerable GetMenuItems(); + } +} \ No newline at end of file diff --git a/ClassLibrary1/Utilities/MenuUtilities.cs b/ClassLibrary1/Utilities/MenuUtilities.cs new file mode 100644 index 0000000..5f65ec8 --- /dev/null +++ b/ClassLibrary1/Utilities/MenuUtilities.cs @@ -0,0 +1,32 @@ +using System; +using System.Linq; + +namespace WhatShouldITest.Utilities +{ + public static class MenuUtilities + { + public static string GetDailySpecial(DayOfWeek dayOfWeek) + { + var _dailySpecials = new[]{ + new {DayOfWeek = DayOfWeek.Monday, + Special = "Half price tacos!" }, + new {DayOfWeek = DayOfWeek.Tuesday, + Special = "50 cent wings"}, + new {DayOfWeek = DayOfWeek.Wednesday, + Special = "2-for-1 Desserts"}, + new {DayOfWeek = DayOfWeek.Thursday, + Special = "5$ Burgers"}, + new {DayOfWeek = DayOfWeek.Friday, + Special = "All you can eat ribs" }, + new {DayOfWeek = DayOfWeek.Saturday, + Special = "Special Brunch" }, + new {DayOfWeek = DayOfWeek.Sunday, + Special = "Sunday, funday"} + }; + + return _dailySpecials.Where(s => s.DayOfWeek == dayOfWeek) + .Select(s => s.Special) + .First(); + } + } +} diff --git a/ClassLibrary1/WhatShouldITest.csproj b/ClassLibrary1/WhatShouldITest.csproj new file mode 100644 index 0000000..cb63190 --- /dev/null +++ b/ClassLibrary1/WhatShouldITest.csproj @@ -0,0 +1,7 @@ + + + + netcoreapp3.1 + + + diff --git a/GettingStarted/1_SimpleStarterTests.feature b/GettingStarted/1_SimpleStarterTests.feature index 2ae5f2b..76db88e 100644 --- a/GettingStarted/1_SimpleStarterTests.feature +++ b/GettingStarted/1_SimpleStarterTests.feature @@ -7,4 +7,9 @@ Scenario: Add two numbers - no variables Given I have entered the numbers 1 and 2 When I add 1 and 2 together - Then the result should be 3 \ No newline at end of file + Then the result should be 3 + +Scenario: Add two different numbers - no variables + Given I have entered the numbers 3 and 5 + When I add 3 and 5 together + Then the result should be 8 \ No newline at end of file diff --git a/GettingStarted/1_SimpleStarterTests.feature.cs b/GettingStarted/1_SimpleStarterTests.feature.cs index 3e3054e..52e7c24 100644 --- a/GettingStarted/1_SimpleStarterTests.feature.cs +++ b/GettingStarted/1_SimpleStarterTests.feature.cs @@ -130,6 +130,46 @@ public virtual void AddTwoNumbers_NoVariables() #line hidden #line 10 testRunner.Then("the result should be 3", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()] + [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("Add two different numbers - no variables")] + [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Add Two Numbers Together")] + public virtual void AddTwoDifferentNumbers_NoVariables() + { + string[] tagsOfScenario = ((string[])(null)); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Add two different numbers - no variables", null, ((string[])(null))); +#line 12 +this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 13 + testRunner.Given("I have entered the numbers 3 and 5", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 14 + testRunner.When("I add 3 and 5 together", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 15 + testRunner.Then("the result should be 8", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); #line hidden } this.ScenarioCleanup(); diff --git a/GettingStarted/2_TestAddingNumbersWithVariables.feature b/GettingStarted/2_TestAddingNumbersWithVariables.feature new file mode 100644 index 0000000..6a8dfe5 --- /dev/null +++ b/GettingStarted/2_TestAddingNumbersWithVariables.feature @@ -0,0 +1,19 @@ +Feature: TestAddingNumbersWithVariables + In order to avoid writing a lot of extra testing code + I want to be able to use variables in my SpecFlow tests + +@mytag +Scenario: Add 1 and 2 + Given I have the numbers 1 and 2 + When I add them together + Then they should add up to 3 + +Scenario: Add 3 and 4 + Given I have the numbers 3 and 4 + When I add them together + Then they should add up to 7 + +Scenario: Add 101 and 1332 + Given I have the numbers 101 and 1332 + When I add them together + Then they should add up to 1433 \ No newline at end of file diff --git a/GettingStarted/2_TestAddingNumbersWithVariables.feature.cs b/GettingStarted/2_TestAddingNumbersWithVariables.feature.cs new file mode 100644 index 0000000..c373b92 --- /dev/null +++ b/GettingStarted/2_TestAddingNumbersWithVariables.feature.cs @@ -0,0 +1,220 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by SpecFlow (http://www.specflow.org/). +// SpecFlow Version:3.1.0.0 +// SpecFlow Generator Version:3.1.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +#region Designer generated code +#pragma warning disable +namespace GettingStarted +{ + using TechTalk.SpecFlow; + using System; + using System.Linq; + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.1.0.0")] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute()] + public partial class TestAddingNumbersWithVariablesFeature + { + + private static TechTalk.SpecFlow.ITestRunner testRunner; + + private Microsoft.VisualStudio.TestTools.UnitTesting.TestContext _testContext; + + private string[] _featureTags = ((string[])(null)); + +#line 1 "2_TestAddingNumbersWithVariables.feature" +#line hidden + + public virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext TestContext + { + get + { + return this._testContext; + } + set + { + this._testContext = value; + } + } + + [Microsoft.VisualStudio.TestTools.UnitTesting.ClassInitializeAttribute()] + public static void FeatureSetup(Microsoft.VisualStudio.TestTools.UnitTesting.TestContext testContext) + { + testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); + TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "TestAddingNumbersWithVariables", "\tIn order to avoid writing a lot of extra testing code\r\n\tI want to be able to use" + + " variables in my SpecFlow tests", ProgrammingLanguage.CSharp, ((string[])(null))); + testRunner.OnFeatureStart(featureInfo); + } + + [Microsoft.VisualStudio.TestTools.UnitTesting.ClassCleanupAttribute()] + public static void FeatureTearDown() + { + testRunner.OnFeatureEnd(); + testRunner = null; + } + + [Microsoft.VisualStudio.TestTools.UnitTesting.TestInitializeAttribute()] + public virtual void TestInitialize() + { + if (((testRunner.FeatureContext != null) + && (testRunner.FeatureContext.FeatureInfo.Title != "TestAddingNumbersWithVariables"))) + { + global::GettingStarted.TestAddingNumbersWithVariablesFeature.FeatureSetup(null); + } + } + + [Microsoft.VisualStudio.TestTools.UnitTesting.TestCleanupAttribute()] + public virtual void TestTearDown() + { + testRunner.OnScenarioEnd(); + } + + public virtual void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioInitialize(scenarioInfo); + testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(_testContext); + } + + public virtual void ScenarioStart() + { + testRunner.OnScenarioStart(); + } + + public virtual void ScenarioCleanup() + { + testRunner.CollectScenarioErrors(); + } + + [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()] + [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("Add 1 and 2")] + [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "TestAddingNumbersWithVariables")] + [Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("mytag")] + public virtual void Add1And2() + { + string[] tagsOfScenario = new string[] { + "mytag"}; + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Add 1 and 2", null, new string[] { + "mytag"}); +#line 6 +this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 7 + testRunner.Given("I have the numbers 1 and 2", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 8 + testRunner.When("I add them together", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 9 + testRunner.Then("they should add up to 3", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()] + [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("Add 3 and 4")] + [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "TestAddingNumbersWithVariables")] + public virtual void Add3And4() + { + string[] tagsOfScenario = ((string[])(null)); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Add 3 and 4", null, ((string[])(null))); +#line 11 +this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 12 + testRunner.Given("I have the numbers 3 and 4", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 13 + testRunner.When("I add them together", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 14 + testRunner.Then("they should add up to 7", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()] + [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("Add 101 and 1332")] + [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "TestAddingNumbersWithVariables")] + public virtual void Add101And1332() + { + string[] tagsOfScenario = ((string[])(null)); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Add 101 and 1332", null, ((string[])(null))); +#line 16 +this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 17 + testRunner.Given("I have the numbers 101 and 1332", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 18 + testRunner.When("I add them together", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 19 + testRunner.Then("they should add up to 1433", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + } +} +#pragma warning restore +#endregion diff --git a/GettingStarted/3_TestToSeeIfOurStoreIsOpen.feature b/GettingStarted/3_TestToSeeIfOurStoreIsOpen.feature new file mode 100644 index 0000000..2a08af5 --- /dev/null +++ b/GettingStarted/3_TestToSeeIfOurStoreIsOpen.feature @@ -0,0 +1,26 @@ +Feature: Check to see if the store is open + As a potential customer + I want to know if your store is open + So I don't waste my time driving there if it isn't + Store Hours: + M-Th 8-10 + Fri 8-11 + Sat 10-8 + Sun 10-6 + +@mytag +Scenario: Check if store is open at 12/11/2019 5:00PM + Given It is currently 12/11/2019 at 5:00PM + Then The store is open + +Scenario: Check if store is open at 12/15/2019 11:00PM + Given It is currently 12/15/2019 at 11:00PM + Then The store is closed + +Scenario: Open time edge case - store opens at 8AM + Given It is currently 12/11/2019 at 8:00AM + Then The store is open + +Scenario: Close time edge case - store closes at 10:00PM + Given It is currently 12/11/2019 at 10:00PM + Then The store is closed \ No newline at end of file diff --git a/GettingStarted/3_TestToSeeIfOurStoreIsOpen.feature.cs b/GettingStarted/3_TestToSeeIfOurStoreIsOpen.feature.cs new file mode 100644 index 0000000..3c5bae6 --- /dev/null +++ b/GettingStarted/3_TestToSeeIfOurStoreIsOpen.feature.cs @@ -0,0 +1,249 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by SpecFlow (http://www.specflow.org/). +// SpecFlow Version:3.1.0.0 +// SpecFlow Generator Version:3.1.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +#region Designer generated code +#pragma warning disable +namespace GettingStarted +{ + using TechTalk.SpecFlow; + using System; + using System.Linq; + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.1.0.0")] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute()] + public partial class CheckToSeeIfTheStoreIsOpenFeature + { + + private static TechTalk.SpecFlow.ITestRunner testRunner; + + private Microsoft.VisualStudio.TestTools.UnitTesting.TestContext _testContext; + + private string[] _featureTags = ((string[])(null)); + +#line 1 "3_TestToSeeIfOurStoreIsOpen.feature" +#line hidden + + public virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext TestContext + { + get + { + return this._testContext; + } + set + { + this._testContext = value; + } + } + + [Microsoft.VisualStudio.TestTools.UnitTesting.ClassInitializeAttribute()] + public static void FeatureSetup(Microsoft.VisualStudio.TestTools.UnitTesting.TestContext testContext) + { + testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); + TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Check to see if the store is open", "\tAs a potential customer\r\n\tI want to know if your store is open\r\n\tSo I don\'t wast" + + "e my time driving there if it isn\'t\r\n\tStore Hours:\r\n\tM-Th 8-10\r\n\tFri 8-11\r\n\tSat " + + "10-8\r\n\tSun 10-6", ProgrammingLanguage.CSharp, ((string[])(null))); + testRunner.OnFeatureStart(featureInfo); + } + + [Microsoft.VisualStudio.TestTools.UnitTesting.ClassCleanupAttribute()] + public static void FeatureTearDown() + { + testRunner.OnFeatureEnd(); + testRunner = null; + } + + [Microsoft.VisualStudio.TestTools.UnitTesting.TestInitializeAttribute()] + public virtual void TestInitialize() + { + if (((testRunner.FeatureContext != null) + && (testRunner.FeatureContext.FeatureInfo.Title != "Check to see if the store is open"))) + { + global::GettingStarted.CheckToSeeIfTheStoreIsOpenFeature.FeatureSetup(null); + } + } + + [Microsoft.VisualStudio.TestTools.UnitTesting.TestCleanupAttribute()] + public virtual void TestTearDown() + { + testRunner.OnScenarioEnd(); + } + + public virtual void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioInitialize(scenarioInfo); + testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(_testContext); + } + + public virtual void ScenarioStart() + { + testRunner.OnScenarioStart(); + } + + public virtual void ScenarioCleanup() + { + testRunner.CollectScenarioErrors(); + } + + [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()] + [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("Check if store is open at 12/11/2019 5:00PM")] + [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Check to see if the store is open")] + [Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("mytag")] + public virtual void CheckIfStoreIsOpenAt12112019500PM() + { + string[] tagsOfScenario = new string[] { + "mytag"}; + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Check if store is open at 12/11/2019 5:00PM", null, new string[] { + "mytag"}); +#line 12 +this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 13 + testRunner.Given("It is currently 12/11/2019 at 5:00PM", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 14 + testRunner.Then("The store is open", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()] + [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("Check if store is open at 12/15/2019 11:00PM")] + [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Check to see if the store is open")] + public virtual void CheckIfStoreIsOpenAt121520191100PM() + { + string[] tagsOfScenario = ((string[])(null)); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Check if store is open at 12/15/2019 11:00PM", null, ((string[])(null))); +#line 16 +this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 17 + testRunner.Given("It is currently 12/15/2019 at 11:00PM", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 18 + testRunner.Then("The store is closed", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()] + [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("Open time edge case - store opens at 8AM")] + [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Check to see if the store is open")] + public virtual void OpenTimeEdgeCase_StoreOpensAt8AM() + { + string[] tagsOfScenario = ((string[])(null)); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Open time edge case - store opens at 8AM", null, ((string[])(null))); +#line 20 +this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 21 + testRunner.Given("It is currently 12/11/2019 at 8:00AM", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 22 + testRunner.Then("The store is open", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + + [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()] + [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("Close time edge case - store closes at 10:00PM")] + [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Check to see if the store is open")] + public virtual void CloseTimeEdgeCase_StoreClosesAt1000PM() + { + string[] tagsOfScenario = ((string[])(null)); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Close time edge case - store closes at 10:00PM", null, ((string[])(null))); +#line 24 +this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 25 + testRunner.Given("It is currently 12/11/2019 at 10:00PM", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 26 + testRunner.Then("The store is closed", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + } +} +#pragma warning restore +#endregion diff --git a/GettingStarted/AddTwoNumbersTogetherSteps.cs b/GettingStarted/AddTwoNumbersTogetherSteps.cs index a0159a3..401e35e 100644 --- a/GettingStarted/AddTwoNumbersTogetherSteps.cs +++ b/GettingStarted/AddTwoNumbersTogetherSteps.cs @@ -1,4 +1,5 @@ -using System; +using FluentAssertions; +using System; using TechTalk.SpecFlow; namespace GettingStarted @@ -6,22 +7,47 @@ namespace GettingStarted [Binding] public class AddTwoNumbersTogetherSteps { - [Given(@"I have entered the numbers (.*) and (.*)")] - public void GivenIHaveEnteredTheNumbersAnd(int p0, int p1) + int firstNumber; + int secondNumber; + int resultOfAddition; + + [Given(@"I have entered the numbers 1 and 2")] + public void GivenIHaveEnteredTheNumbersOneAndTwo() { - ScenarioContext.Current.Pending(); + firstNumber = 1; + secondNumber = 2; } - - [When(@"I add (.*) and (.*) together")] - public void WhenIAddAndTogether(int p0, int p1) + + [When(@"I add 1 and 2 together")] + public void WhenIAddOneAndTwoTogether() { - ScenarioContext.Current.Pending(); + resultOfAddition = firstNumber + secondNumber; } - - [Then(@"the result should be (.*)")] - public void ThenTheResultShouldBe(int p0) + + [Then(@"the result should be 3")] + public void ThenTheResultShouldBeThree() { - ScenarioContext.Current.Pending(); + resultOfAddition.Should().Be(3); } + + [Given(@"I have entered the numbers 3 and 5")] + public void GivenIHaveEnteredTheNumbersThreAndFive() + { + firstNumber = 3; + secondNumber = 5; + } + + [When(@"I add 3 and 5 together")] + public void WhenIAddThreeAndFiveTogether() + { + resultOfAddition = firstNumber + secondNumber; + } + + [Then(@"the result should be 8")] + public void ThenTheResultShouldBeEight() + { + resultOfAddition.Should().Be(8); + } + } } diff --git a/GettingStarted/CheckToSeeIfTheStoreIsOpenSteps.cs b/GettingStarted/CheckToSeeIfTheStoreIsOpenSteps.cs new file mode 100644 index 0000000..4e123e6 --- /dev/null +++ b/GettingStarted/CheckToSeeIfTheStoreIsOpenSteps.cs @@ -0,0 +1,32 @@ +using FluentAssertions; +using SomeStuffToTest; +using System; +using TechTalk.SpecFlow; + +namespace GettingStarted +{ + [Binding] + public class CheckToSeeIfTheStoreIsOpenSteps + { + DateTime currentTime; + + [Given(@"It is currently (.*) at (.*)")] + public void GivenItIsCurrentlyAt(string p0, string p1) + { + currentTime = DateTime.Parse($"{p0} {p1}"); + } + + [Then(@"The store is open")] + public void ThenTheStoreIsOpen() + { + currentTime.IsStoreOpen().Should().BeTrue(); + } + + [Then(@"The store is closed")] + public void ThenTheStoreIsClosed() + { + currentTime.IsStoreOpen().Should().BeFalse(); + } + + } +} diff --git a/GettingStarted/CheckToSeeIfTheStoreIsOpen_OutlineVersionSteps.cs b/GettingStarted/CheckToSeeIfTheStoreIsOpen_OutlineVersionSteps.cs new file mode 100644 index 0000000..1b315ac --- /dev/null +++ b/GettingStarted/CheckToSeeIfTheStoreIsOpen_OutlineVersionSteps.cs @@ -0,0 +1,32 @@ +using FluentAssertions; +using SomeStuffToTest; +using System; +using TechTalk.SpecFlow; + +namespace GettingStarted +{ + [Binding] + public class CheckToSeeIfTheStoreIsOpen_OutlineVersionSteps + { + DateTime dateToTest; + + [Given(@"it is a certain (.*) and (.*)")] + public void GivenItIsACertainAnd(string p0, string p1) + { + dateToTest = DateTime.Parse($"{p0} {p1}"); + } + + [Then(@"The store (.*) open at that time")] + public void ThenTheStoreOpen(string p0) + { + if (dateToTest.IsStoreOpen()) + { + p0.ToLower().Replace(" ", "").Should().Be("is"); + } + else + { + p0.ToLower().Replace(" ", "").Should().Be("isnot"); + } + } + } +} diff --git a/GettingStarted/GettingStarted.csproj b/GettingStarted/GettingStarted.csproj index a3a39a4..9012705 100644 --- a/GettingStarted/GettingStarted.csproj +++ b/GettingStarted/GettingStarted.csproj @@ -17,6 +17,10 @@ + + + + True diff --git a/GettingStarted/IsStoreOpenScenarioOutlineVersion.feature b/GettingStarted/IsStoreOpenScenarioOutlineVersion.feature new file mode 100644 index 0000000..816c6da --- /dev/null +++ b/GettingStarted/IsStoreOpenScenarioOutlineVersion.feature @@ -0,0 +1,24 @@ +Feature: Check to see if the store is open - outline version + As a potential customer + I want to know if your store is open + So I don't waste my time driving there if it isn't + Store Hours: + M-Th 8-10 + Fri 8-11 + Sat 10-8 + Sun 10-6 + +Scenario Outline: Testing multiple dates and times + Given it is a certain and