コード例 #1
0
 private static void ReadComplexityRegulationStrategy(
     INeatExperiment <T> target, JsonElement jelem)
 {
     if (jelem.TryGetProperty("complexityRegulationStrategy", out JsonElement settingsElem))
     {
         target.ComplexityRegulationStrategy = ComplexityRegulationStrategyJsonReader.Read(settingsElem);
     }
 }
コード例 #2
0
        private static void ReadComplexityRegulationStrategy(
            INeatExperiment <T> target, JObject jobj)
        {
            JObject settingsJobj = (JObject)jobj["complexityRegulationStrategy"];

            if (settingsJobj != null)
            {
                target.ComplexityRegulationStrategy = ComplexityRegulationStrategyJsonReader.Read(settingsJobj);
            }
        }
        public void Read_NullStrategy()
        {
            JsonDocument jdoc = JsonDocument.Parse(
                @"{
    ""strategyName"": ""null""
}");

            IComplexityRegulationStrategy strategy = ComplexityRegulationStrategyJsonReader.Read(jdoc.RootElement);

            Assert.Equal("NullComplexityRegulationStrategy", strategy.GetType().Name);
        }
        public void Read_NullStrategy()
        {
            JObject jobj = JObject.Parse(
                @"{
    'strategyName': 'null'
}");

            IComplexityRegulationStrategy strategy = ComplexityRegulationStrategyJsonReader.Read(jobj);

            Assert.AreEqual("NullComplexityRegulationStrategy", strategy.GetType().Name);
        }
        public void Read_AbsoluteStrategy()
        {
            JsonDocument jdoc = JsonDocument.Parse(
                @"{
    ""strategyName"": ""absolute"",
    ""complexityCeiling"": 11,
    ""minSimplifcationGenerations"": 12
}");

            IComplexityRegulationStrategy strategy = ComplexityRegulationStrategyJsonReader.Read(jdoc.RootElement);

            Assert.Equal("AbsoluteComplexityRegulationStrategy", strategy.GetType().Name);

            // Read private variables with reflection.
            var    absoluteStrategy            = (AbsoluteComplexityRegulationStrategy)strategy;
            object complexityCeiling           = GetInstanceField(absoluteStrategy, "_complexityCeiling");
            object minSimplifcationGenerations = GetInstanceField(absoluteStrategy, "_minSimplifcationGenerations");

            Assert.Equal(11.0, complexityCeiling);
            Assert.Equal(12, minSimplifcationGenerations);
        }
        public void Read_AbsoluteStrategy()
        {
            JObject jobj = JObject.Parse(
                @"{
    'strategyName': 'absolute',
    'complexityCeiling': 11,
    'minSimplifcationGenerations': 12
}");

            IComplexityRegulationStrategy strategy = ComplexityRegulationStrategyJsonReader.Read(jobj);

            Assert.AreEqual("AbsoluteComplexityRegulationStrategy", strategy.GetType().Name);

            // Read private variables with reflection.
            var    absoluteStrategy            = (AbsoluteComplexityRegulationStrategy)strategy;
            object complexityCeiling           = GetInstanceField(absoluteStrategy, "_complexityCeiling");
            object minSimplifcationGenerations = GetInstanceField(absoluteStrategy, "_minSimplifcationGenerations");

            Assert.AreEqual(11.0, complexityCeiling);
            Assert.AreEqual(12, minSimplifcationGenerations);
        }