public void MultiChildrenNode_lazy_initialization_list_of_children() { var mcn = new MultiChildrenNode(newDatabase()) { Id = 1 }; Assert.AreEqual(false, mcn.WereChildrenLoaded()); Assert.AreEqual(3, mcn.Children.Count); Assert.AreEqual(true, mcn.WereChildrenLoaded()); }
public void MultiChildrenNode_can_have_child() { var mcn = new MultiChildrenNode(newDatabase()); Assert.AreEqual(true, mcn.CanHaveChild()); }
private void SaveNewChild_Click(object sender, RoutedEventArgs e) { switch (node.GetType().Name) { case "MultiChildrenNode": var multiNode = new MultiChildrenNode(_database); multiNode.Id = node.Id; multiNode.properties.Brand = NodeBrand.Text; multiNode.properties.Model = NodeModel.Text; if (NodePrice.Text.Length > 0 && double.TryParse(NodePrice.Text, out double mPrice)) { multiNode.properties.Price = mPrice; } if (Maintenance.Text.Length > 0 && int.TryParse(Maintenance.Text, out int maintenance)) { multiNode.properties.FreeMaintenance = maintenance; } _database.UpdateProperties(multiNode); break; case "SingleChildrenNode": var singleNode = new SingleChildrenNode(_database); singleNode.Id = node.Id; singleNode.properties.Brand = NodeBrand.Text; singleNode.properties.Model = NodeModel.Text; if (NodePrice.Text.Length > 0 && double.TryParse(NodePrice.Text, out double sPrice)) { singleNode.properties.Price = sPrice; } if (Maintenance.Text.Length > 0 && int.TryParse(Warranty.Text, out int warranty)) { singleNode.properties.WarrantyPeriod = warranty; } _database.UpdateProperties(singleNode); break; case "NullChildrenNode": var nullNode = new NullChildrenNode(_database); nullNode.Id = node.Id; nullNode.properties.Brand = NodeBrand.Text; nullNode.properties.Model = NodeModel.Text; if (NodePrice.Text.Length > 0 && double.TryParse(NodePrice.Text, out double nPrice)) { nullNode.properties.Price = nPrice; } nullNode.properties.Material = Material.Text; if (Maintenance.Text.Length > 0 && int.TryParse(Warranty.Text, out int year)) { nullNode.properties.Year = year; } _database.UpdateProperties(nullNode); break; default: throw new ArgumentException("Unknown type!"); } Cleaning(); this.Close(); }