コード例 #1
0
        public void BendingResistanceCalculationTest_RandomExamples_Success()
        {
            var parameters = _testEngine.ParameterRepository.GetAllParametersForScriptAsync(ID).Result.ToList();

            var parametersResource       = _testEngine.Mapper.Map <List <Parameter>, List <ParameterResource> >(parameters);
            var parametersForCalculation = new Dictionary <string, ParameterResource>(
                parametersResource.Where(p => (p.Context & ParameterOptions.Editable) != 0 &&
                                         (p.Context & ParameterOptions.Visible) != 0)
                .ToDictionary(p => p.Name, p => p));

            parametersForCalculation["f_y_"].Value = _testEngine.GetBigRandom();
            parametersForCalculation["h"].Value    = _testEngine.GetBigRandom();
            parametersForCalculation["b"].Value    = _testEngine.GetBigRandom();
            parametersForCalculation["t_f_"].Value = _testEngine.GetSmallRandom();
            parametersForCalculation["t_w_"].Value = _testEngine.GetSmallRandom();
            parametersForCalculation["Type"].Value =
                _testEngine.GetValueFromRange(parametersForCalculation["Type"].ValueOptions
                                              .Select(vo => vo.Value)
                                              .ToArray());
            parametersForCalculation["a"].Value = _testEngine.GetSmallRandom();
            parametersForCalculation["r"].Value = _testEngine.GetSmallRandom();

            Assert.DoesNotThrow(() => _testEngine.Calculate(ID, parametersForCalculation.Select(p => p.Value).ToList()),
                                String.Join(", ", parametersForCalculation.Select(p => $"{p.Value.Name}={p.Value.Value}")));
        }
        public void CompressiveStrengthOfConcreteAtAnAgeTests_RandomExamples_Success()
        {
            var parameters = _testEngine.ParameterRepository.GetAllParametersForScriptAsync(ID).Result.ToList();

            var parametersResource       = _testEngine.Mapper.Map <List <Parameter>, List <ParameterResource> >(parameters);
            var parametersForCalculation = new Dictionary <string, ParameterResource>(
                parametersResource.Where(p => (p.Context & ParameterOptions.Editable) != 0 &&
                                         (p.Context & ParameterOptions.Visible) != 0)
                .ToDictionary(p => p.Name, p => p));

            parametersForCalculation["f_ck_"].Value        = _testEngine.GetBigRandom();
            parametersForCalculation["f_cm_"].Value        = _testEngine.GetBigRandom();
            parametersForCalculation["cement_type_"].Value = _testEngine.GetValueFromRange(
                parametersForCalculation["cement_type_"].ValueOptions
                .Select(vo => vo.Value)
                .ToArray());
            parametersForCalculation["t"].Value = _testEngine.GetBigRandom(min: 3);

            Assert.DoesNotThrow(() => _testEngine.Calculate(ID, parametersForCalculation.Select(p => p.Value).ToList()),
                                String.Join(", ", parametersForCalculation.Select(p => $"{p.Value.Name}={p.Value.Value}")));
        }