コード例 #1
0
        public void GetProperties_PassDefaultPropertyCollection_ReturnsSameCollection()
        {
            var defaultProperties = A.Fake <IPropertyCollection>();
            var propertyHandler   = new PropertyHandler("username", defaultProperties, null);

            Assert.AreEqual(defaultProperties, propertyHandler.GetProperties());
        }
コード例 #2
0
 public void RegisterProperty()
 {
     // Checking if the property gets registered correctly
     PropertyHandler.RegisterProperty("UnitTest", ref testProp);
     Assert.Contains("UnitTest", PropertyHandler.GetProperties().Keys);
     Assert.Throws(typeof(PropertyHandlerException),
                   () => PropertyHandler.RegisterProperty("UnitTest", ref testProp));
     _registerPropertyTestRan = true;
 }
コード例 #3
0
        public void ResetDefaults()
        {
            var properties = PropertyHandler.GetProperties();

            foreach (var prop in properties)
            {
                prop.Value.ResetToFirstValue();
            }
            UpdateProperties();
        }
コード例 #4
0
        public IEnumerable <char> Run(params string[] args)
        {
            var output = new StringBuilder("Properties:");

            foreach (var prop in PropertyHandler.GetProperties().OrderBy(p => p.Key))
            {
                output.Append($"\n{prop.Key} ({prop.Value.Type.Name})");
            }

            return(output.ToString());
        }
コード例 #5
0
        public void UpdateProperties()
        {
            PropertyPanel.Children.Clear();

            var properties = PropertyHandler.GetProperties();

            foreach (var property in new Dictionary <string, Property>(properties))
            {
                var propertyName  = property.Key;
                var propertyValue = property.Value.Value.ToString();

                PropertyPanel.Children.Add(new PropertySettings(propertyName, propertyValue, true));
            }
        }
コード例 #6
0
        public void SaveProperties()
        {
            foreach (var child in PropertyPanel.Children)
            {
                var propertyControl = (PropertySettings)child;
                var name            = propertyControl.LabelPropertyName.Content.ToString();
                var property        = PropertyHandler.GetProperties().First(p => p.Key == name);

                if (propertyControl.TBCurrentValue.Text != property.Value.ToString())
                {
                    var value = propertyControl.TBCurrentValue.Text;
                    if (propertyControl.TBCurrentValue.Text.Contains(","))
                    {
                        value = value.Replace(",", ".");
                    }
                    CommandHandler.HandleInput($"set { name } { value }");
                    propertyControl.CurrentValue = propertyControl.TBCurrentValue.Text;
                }
            }
        }
コード例 #7
0
        public IEnumerable <char> Run(params string[] args)
        {
            if (args.Length < 1)
            {
                throw new CommandInputException("Invalid parameters");
            }

            var propName = args[0];

            // Getting property
            var properties = PropertyHandler.GetProperties().Where(p => p.Key == propName).ToArray();

            if (properties.Length == 0)
            {
                throw new CommandInputException($"Unknown property \"{propName}\"");
            }
            var property = properties[0].Value;

            // Returning the property value
            return($"{propName} = {property.Value} ({property.Type.Name})");
        }
コード例 #8
0
ファイル: CityParser.cs プロジェクト: TheKoen/SE1d3-KBS2
        public static City MakeCity(XmlDocument city, string name)
        {
            var properties = PropertyHandler.GetProperties();

            if (properties.ContainsKey("availableCars"))
            {
                PropertyHandler.ResetProperties();
            }

            var cityObject = new City(name);

            var root = city.DocumentElement;

            if (root == null)
            {
                throw new XmlException("Missing root node");
            }

            //selecting and adding roads to List
            var roads = city.SelectSingleNode("//City/Roads");

            if (roads == null)
            {
                throw new XmlException("Missing roads in city.");
            }
            foreach (var road in roads.ChildNodes)
            {
                cityObject.Roads.Add(ParseRoad((XmlNode)road));
            }

            //selecting and adding buildings to List
            var buildings = city.SelectSingleNode("//City/Buildings");

            if (buildings == null)
            {
                throw new XmlException("Missing buildings in city.");
            }
            foreach (var building in buildings.ChildNodes)
            {
                cityObject.Buildings.Add(ParseBuilding((XmlNode)building));
            }

            //selecting and adding intersections to list
            var intersections = city.SelectSingleNode("//City/Intersections");

            if (intersections == null)
            {
                throw new XmlException("Missing intersections in city.");
            }
            foreach (var intersection in intersections.ChildNodes)
            {
                cityObject.Intersections.Add(ParseIntersection((XmlNode)intersection));
            }

            try
            {
                NodeNetwork.GenerateNetwork(cityObject.Roads, cityObject.Intersections);
            }
            catch (Exception)
            {
                App.Console?.Print("Unable to load road network!", Colors.Red);
            }

            return(cityObject);
        }
コード例 #9
0
		public void GetProperties_PassDefaultPropertyCollection_ReturnsSameCollection() {
			var defaultProperties = A.Fake<IPropertyCollection>();
			var propertyHandler = new PropertyHandler("username", defaultProperties, null);
			Assert.AreEqual(defaultProperties, propertyHandler.GetProperties());
		}