-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#511 Add unit tests covering scenario
- Loading branch information
1 parent
2898de4
commit 131d562
Showing
2 changed files
with
57 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
namespace Catel.Fody.TestAssembly.Bugs.GH0511 | ||
{ | ||
using Catel.Data; | ||
using Catel.MVVM; | ||
|
||
public class AppSettingsModel : ModelBase | ||
{ | ||
public string SelectedThemeName { get; set; } | ||
} | ||
|
||
public class AppSettingsViewModel : ViewModelBase | ||
{ | ||
public AppSettingsViewModel(AppSettingsModel appSettings) | ||
{ | ||
AppSettings = appSettings; | ||
} | ||
|
||
public string ExpectedValue { get; set; } | ||
|
||
[Model] | ||
[Expose("SelectedThemeName")] | ||
public AppSettingsModel AppSettings { get; set; } | ||
|
||
private void OnSelectedThemeNameChanged() | ||
{ | ||
if (AppSettings.SelectedThemeName != ExpectedValue) | ||
{ | ||
throw new System.Exception($"Unexpected value '{AppSettings.SelectedThemeName}'"); | ||
} | ||
} | ||
} | ||
} |
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,25 @@ | ||
namespace Catel.Fody.Tests.Repros | ||
{ | ||
using System; | ||
using Catel.Reflection; | ||
using NUnit.Framework; | ||
|
||
[TestFixture] | ||
public class GH0511TestFixture | ||
{ | ||
[TestCase] | ||
public void Raises_PropertyChanged_With_Updated_Value() | ||
{ | ||
var modelType = AssemblyWeaver.Instance.Assembly.GetType("Catel.Fody.TestAssembly.Bugs.GH0511.AppSettingsModel"); | ||
var model = Activator.CreateInstance(modelType); | ||
|
||
var viewModelType = AssemblyWeaver.Instance.Assembly.GetType("Catel.Fody.TestAssembly.Bugs.GH0511.AppSettingsViewModel"); | ||
var viewModel = Activator.CreateInstance(viewModelType, model) as dynamic; | ||
viewModel.ExpectedValue = "test"; | ||
|
||
PropertyHelper.SetPropertyValue(model, "SelectedThemeName", "test"); | ||
|
||
Assert.That(viewModel.AppSettings.SelectedThemeName, Is.EqualTo("test")); | ||
} | ||
} | ||
} |