public void NullChildrenNode_throw_exception_if_I_try_to_add_a_child()
        {
            var ncn = new NullChildrenNode(newDatabase())
            {
                Id = 6
            };
            var child = new NodeModel("child", "2584CCC2584", "NullChildrenNode");

            ncn.AddChild(child);
        }
        public void NullChildrenNode_cannot_have_child()
        {
            var ncn = new NullChildrenNode(newDatabase());

            Assert.AreEqual(false, ncn.CanHaveChild());
        }
Exemplo n.º 3
0
        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();
        }