-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #133 from MRCollective/html-helper-for-method
Ability to change the context of a form model
- Loading branch information
Showing
29 changed files
with
1,028 additions
and
61 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ _ReSharper.* | |
~$* | ||
*~ | ||
*.log | ||
packages | ||
packages | ||
*.received.* |
This file contains 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
This file contains 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
This file contains 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
50 changes: 50 additions & 0 deletions
50
ChameleonForms.AcceptanceTests/ModelBinding/ChangingContextTests.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using ChameleonForms.AcceptanceTests.Helpers; | ||
using ChameleonForms.AcceptanceTests.ModelBinding.Pages; | ||
using NUnit.Framework; | ||
using TestStack.Seleno.Configuration; | ||
|
||
namespace ChameleonForms.AcceptanceTests.ModelBinding | ||
{ | ||
[TestFixture] | ||
class ChangingContextShould | ||
{ | ||
[Test] | ||
public void Post_different_view_model_and_bind_on_postback() | ||
{ | ||
var enteredViewModel = ObjectMother.ChangingContextViewModels.DifferentViewModel; | ||
|
||
var page = Host.Instance.NavigateToInitialPage<HomePage>() | ||
.GoToChangingContextPage2() | ||
.PostDifferentModel(enteredViewModel); | ||
|
||
Assert.That(page.ReadDifferentModel(), IsSame.ViewModelAs(enteredViewModel)); | ||
Assert.That(page.HasValidationErrors(), Is.False, "There are validation errors on the page"); | ||
} | ||
|
||
[Test] | ||
public void Post_child_view_model_and_bind_on_postback() | ||
{ | ||
var enteredViewModel = ObjectMother.ChangingContextViewModels.ChildViewModel; | ||
|
||
var page = Host.Instance.NavigateToInitialPage<HomePage>() | ||
.GoToChangingContextPage2() | ||
.PostChildModel(enteredViewModel); | ||
|
||
Assert.That(page.ReadChildModel(), IsSame.ViewModelAs(enteredViewModel)); | ||
Assert.That(page.HasValidationErrors(), Is.False, "There are validation errors on the page"); | ||
} | ||
|
||
[Test] | ||
public void Post_child_view_model_and_bind_to_parent_on_postback() | ||
{ | ||
var enteredViewModel = ObjectMother.ChangingContextViewModels.ParentViewModel; | ||
|
||
var page = Host.Instance.NavigateToInitialPage<HomePage>() | ||
.GoToChangingContextPage2() | ||
.PostParentModel(enteredViewModel); | ||
|
||
Assert.That(page.ReadParentModel(), IsSame.ViewModelAs(enteredViewModel)); | ||
Assert.That(page.HasValidationErrors(), Is.False, "There are validation errors on the page"); | ||
} | ||
} | ||
} |
This file contains 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
56 changes: 56 additions & 0 deletions
56
ChameleonForms.AcceptanceTests/ModelBinding/Pages/ChangingContextPage.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using ChameleonForms.Example.Controllers; | ||
using OpenQA.Selenium; | ||
|
||
namespace ChameleonForms.AcceptanceTests.ModelBinding.Pages | ||
{ | ||
public class ChangingContextPage : ChameleonFormsPage<ParentViewModel> | ||
{ | ||
public BasicViewModel ReadDifferentModel() | ||
{ | ||
return GetComponent<PageAsDifferentModel>().GetFormValues(); | ||
} | ||
|
||
public ChangingContextPage PostDifferentModel(BasicViewModel vm) | ||
{ | ||
GetComponent<PageAsDifferentModel>().Input(vm); | ||
return Navigate.To<ChangingContextPage>(By.CssSelector("button[type=submit].different-model")); | ||
} | ||
|
||
public ChildViewModel ReadChildModel() | ||
{ | ||
return GetComponent<PageAsChildModel>().GetFormValues(); | ||
} | ||
|
||
public ChangingContextPage PostChildModel(ChildViewModel vm) | ||
{ | ||
GetComponent<PageAsChildModel>().Input(vm); | ||
return Navigate.To<ChangingContextPage>(By.CssSelector("button[type=submit].child-model")); | ||
} | ||
|
||
public ParentViewModel ReadParentModel() | ||
{ | ||
return GetFormValues(); | ||
} | ||
|
||
public ChangingContextPage PostParentModel(ParentViewModel vm) | ||
{ | ||
InputModel(vm); | ||
return Navigate.To<ChangingContextPage>(By.CssSelector("button[type=submit].parent-model")); | ||
} | ||
|
||
public class PageAsDifferentModel : ChameleonFormsPage<BasicViewModel> | ||
{ | ||
public void Input(BasicViewModel vm) | ||
{ | ||
InputModel(vm); | ||
} | ||
} | ||
public class PageAsChildModel : ChameleonFormsPage<ChildViewModel> | ||
{ | ||
public void Input(ChildViewModel vm) | ||
{ | ||
InputModel(vm); | ||
} | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.