Last active
December 20, 2015 23:29
-
-
Save jasondentler/6213057 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using TechTalk.SpecFlow; | |
| namespace DWH.Pricing.Tests | |
| { | |
| [Binding] | |
| public class FlexSpaceSteps | |
| { | |
| [Given(@"a selected flexspace (.*) ""(.*)""")] | |
| public void GivenASelectedFlexspace(string optionNumber, string description) | |
| { | |
| TestPriceRequest.Current.AddSelectedFlexSpace(optionNumber, description); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Feature: PlanRooms | |
| In order to calculate which options are available | |
| As a team member | |
| I want to calculate which rooms exist in a plan | |
| Scenario: Simple initial plan room | |
| Given a price request | |
| And an initial plan room of "Living Room" | |
| When priced | |
| Then the plan contains room "Living Room" | |
| And the plan contains 1 room | |
| Scenario: Flexspace changes plan rooms | |
| Given a price request | |
| And an initial plan room of "Third Bedroom" | |
| And a selected flexspace MEDIAROOM "Media Room instead of Third Bedroom" | |
| And an option plan room for MEDIAROOM that removes "Third Bedroom" | |
| And an option plan room for MEDIAROOM that adds "Media Room" | |
| When priced | |
| Then the plan contains 1 room | |
| And the plan contains room "Media Room" | |
| Scenario: Competing flex spaces | |
| Given a price request | |
| And an initial plan room of "Second Bedroom" | |
| And an initial plan room of "Third Bedroom" | |
| And a selected flexspace SECONDMASTER "Second master bedroom suite" | |
| And an option plan room for SECONDMASTER that adds "2nd Bedroom Walk In Closet" | |
| And an option plan room for SECONDMASTER that adds "2nd Bathroom" | |
| And an option plan room for SECONDMASTER that removes "Third Bedroom" | |
| And a selected flexspace SECONDMASTERTUB "Tub and Shower in 2nd Bathroom" | |
| #Smaller closet | |
| And an option plan room for SECONDMASTERTUB that removes "2nd Bedroom Walk In Closet" | |
| And an option plan room for SECONDMASTERTUB that adds "2nd Bedroom Closet" | |
| When priced | |
| Then the plan contains 3 rooms | |
| And the plan contains room "Second Bedroom" | |
| And the plan contains room "2nd Bathroom" | |
| And the plan contains room "2nd Bedroom Closet" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Linq; | |
| using Should; | |
| using TechTalk.SpecFlow; | |
| namespace DWH.Pricing.Tests | |
| { | |
| [Binding] | |
| public class PlanRoomSteps | |
| { | |
| [Given(@"an initial plan room of ""(.*)""")] | |
| public void GivenAnInitialPlanRoomOf(string room) | |
| { | |
| if (room == null) throw new ArgumentNullException("room"); | |
| TestPriceRequest.Current.AddPlanRoom(new PlanRoom() | |
| { | |
| OptionNumber = null, | |
| Change = PlanRoom.Changes.AddRoom, | |
| Room = room | |
| }); | |
| } | |
| [Given(@"an option plan room for (.*) that adds ""(.*)""")] | |
| public void GivenAnOptionPlanRoomForThatAdds(string optionNumber, string room) | |
| { | |
| if (optionNumber == null) throw new ArgumentNullException("optionNumber"); | |
| if (room == null) throw new ArgumentNullException("room"); | |
| TestPriceRequest.Current.AddPlanRoom(new PlanRoom() | |
| { | |
| Change = PlanRoom.Changes.AddRoom, | |
| OptionNumber = optionNumber, | |
| Room = room | |
| }); | |
| } | |
| [Given(@"an option plan room for (.*) that removes ""(.*)""")] | |
| public void GivenAnOptionPlanRoomForThatRemoves(string optionNumber, string room) | |
| { | |
| if (optionNumber == null) throw new ArgumentNullException("optionNumber"); | |
| if (room == null) throw new ArgumentNullException("room"); | |
| TestPriceRequest.Current.AddPlanRoom(new PlanRoom() | |
| { | |
| Change = PlanRoom.Changes.RemoveRoom, | |
| OptionNumber = optionNumber, | |
| Room = room | |
| }); | |
| } | |
| [Then(@"the plan contains (.*) rooms")] | |
| [Then(@"the plan contains (.*) room")] | |
| public void ThenThePlanContainsRooms(int numberOfRooms) | |
| { | |
| PriceSteps.Response.PlanRoomResponse.ActiveRooms.Count().ShouldEqual(numberOfRooms); | |
| } | |
| [Then(@"the plan contains room ""(.*)""")] | |
| public void ThenThePlanContainsRoom(string room) | |
| { | |
| PriceSteps.Response.PlanRoomResponse.ActiveRooms.ShouldContain(room); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using TechTalk.SpecFlow; | |
| namespace DWH.Pricing.Tests | |
| { | |
| [Binding] | |
| public class PriceSteps | |
| { | |
| public static PriceResponse Response | |
| { | |
| get { return ScenarioContext.Current.Get<PriceResponse>(); } | |
| private set { ScenarioContext.Current.Set(value); } | |
| } | |
| [Given(@"a price request")] | |
| public void GivenAPriceRequest() | |
| { | |
| TestPriceRequest.Current = new TestPriceRequest(); | |
| } | |
| [When(@"priced")] | |
| public void WhenPriced() | |
| { | |
| var service = new PriceService(new PlanRoomService()); | |
| Response = service.Price(TestPriceRequest.Current); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using TechTalk.SpecFlow; | |
| namespace DWH.Pricing.Tests | |
| { | |
| public class TestPriceRequest : IPriceRequest | |
| { | |
| private class Option : IOption | |
| { | |
| public string OptionNumber { get; set; } | |
| public string Description { get; set; } | |
| public bool IsIncluded { get; set; } | |
| } | |
| public static TestPriceRequest Current | |
| { | |
| get { return ScenarioContext.Current.Get<TestPriceRequest>(); } | |
| set { ScenarioContext.Current.Set(value); } | |
| } | |
| private readonly List<PlanRoom> _planRooms = new List<PlanRoom>(); | |
| private readonly Dictionary<string, int> _optionQuantity = new Dictionary<string, int>(); | |
| private readonly Dictionary<string, IOption> _options = new Dictionary<string, IOption>(); | |
| public void AddPlanRoom(PlanRoom planRoom) | |
| { | |
| if (planRoom == null) throw new ArgumentNullException("planRoom"); | |
| _planRooms.Add(planRoom); | |
| } | |
| public void AddSelectedFlexSpace(string optionNumber, string description) | |
| { | |
| if (optionNumber == null) throw new ArgumentNullException("optionNumber"); | |
| if (description == null) throw new ArgumentNullException("description"); | |
| _optionQuantity[optionNumber] = 1; | |
| _options[optionNumber] = new Option() | |
| { | |
| OptionNumber = optionNumber, | |
| Description = description, | |
| IsIncluded = false | |
| }; | |
| } | |
| public IEnumerable<PlanRoom> PlanRooms | |
| { | |
| get { return _planRooms.AsReadOnly(); } | |
| } | |
| public IEnumerable<IOption> Options | |
| { | |
| get { return _options.Values; } | |
| } | |
| public IDictionary<string, int> OptionQuantities | |
| { | |
| get { return _optionQuantity; } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment