Implement test to delete child element and make it pass.
This commit is contained in:
parent
60296602a9
commit
1205958eb1
@ -127,6 +127,32 @@ namespace Tests.ViewModels
|
|||||||
"Settings' Element collection still contains the element model.");
|
"Settings' Element collection still contains the element model.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void DeleteChildElement()
|
||||||
|
{
|
||||||
|
Settings settings = new Settings();
|
||||||
|
settings.AddElement(new SelectFirstDay(new Items()));
|
||||||
|
settings.AddElement(new SelectEachDay());
|
||||||
|
settings.AddElement(new SelectLastDay());
|
||||||
|
SettingsViewModel settingsVM = new SettingsViewModel(settings);
|
||||||
|
ControlElementViewModel parent = ((ControlElementViewModel)settingsVM.Elements.First());
|
||||||
|
int oldCount = parent.Elements.Count;
|
||||||
|
ElementViewModel elementVM = ((ControlElementViewModel)settingsVM.Elements.First())
|
||||||
|
.Elements.First();
|
||||||
|
ElementBase element = elementVM.RevealModelObject() as ElementBase;
|
||||||
|
Assert.IsTrue(((ControlElementBase)settings.Elements[0]).FormatElements.Contains(element),
|
||||||
|
"Settings object does not contain the model that the VM revealed?!");
|
||||||
|
elementVM.IsSelected = true;
|
||||||
|
Assert.IsTrue(settingsVM.DeleteElementCommand.CanExecute(null),
|
||||||
|
"DeleteElementCommand should be enabled.");
|
||||||
|
settingsVM.DeleteElementCommand.Execute(null);
|
||||||
|
Assert.AreEqual(oldCount - 1, parent.Elements.Count);
|
||||||
|
Assert.IsFalse(parent.Elements.Contains(elementVM),
|
||||||
|
"Elements collection still contains the deleted element view model.");
|
||||||
|
Assert.IsFalse(((ControlElementBase)settings.Elements[0]).FormatElements.Contains(element),
|
||||||
|
"Settings' collection of FormatElement children still contains the element model.");
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void CopyElement()
|
public void CopyElement()
|
||||||
{
|
{
|
||||||
|
@ -135,6 +135,7 @@ namespace zaaReloaded2.ViewModels
|
|||||||
vm = new ControlElementViewModel(element as ControlElementBase);
|
vm = new ControlElementViewModel(element as ControlElementBase);
|
||||||
foreach (FormatElementViewModel childVM in ((ControlElementViewModel)vm).Elements)
|
foreach (FormatElementViewModel childVM in ((ControlElementViewModel)vm).Elements)
|
||||||
{
|
{
|
||||||
|
childVM.Parent = vm as ControlElementViewModel;
|
||||||
childVM.PropertyChanged += ElementViewModel_PropertyChanged;
|
childVM.PropertyChanged += ElementViewModel_PropertyChanged;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user