Exemplo n.º 1
0
        public void CreateTariffCalculator_Always_ReturnCorrectType(string tariffType, System.Type type)
        {
            ILoggerManager loggerManager = Substitute.For <ILoggerManager>();
            var            current       = TariffCalculatorFactory.CreateTariffCalculator(loggerManager, tariffType);

            Assert.IsType(type, current);
        }
Exemplo n.º 2
0
        public void CreateTariffCalculator_InvalidTypeParameter_ReturnNull()
        {
            ILoggerManager loggerManager = Substitute.For <ILoggerManager>();
            var            current       = TariffCalculatorFactory.CreateTariffCalculator(loggerManager, null);

            Assert.Null(current);
        }
Exemplo n.º 3
0
        public void CreateTariffCalculator_InvalidString_ReturnNull(string input, object expected)
        {
            ILoggerManager loggerManager = Substitute.For <ILoggerManager>();
            var            current       = TariffCalculatorFactory.CreateTariffCalculator(loggerManager, input);

            Assert.True(expected == current);
        }
Exemplo n.º 4
0
        public void CreateTariffCalculator_ValidStringParameter_ReturnTariffCalculator()
        {
            int            expected      = 0;
            ILoggerManager loggerManager = Substitute.For <ILoggerManager>();
            var            current       = TariffCalculatorFactory.CreateTariffCalculator(loggerManager, "OTS");

            Assert.Equal(expected, current.Type);
        }
        private bool InitComputeM1()
        {
            trace.Write(TraceLevel.Info, "InitComputeM1");

            bool fnResult = false;

            try
            {
                string tariffParam = paramLoader.GetParam(PARAM_TARIFF);
                if (tariffParam == null)
                {
                    throw new InvalidOperationException("Could not get system tariff");
                }

                trace.Write(TraceLevel.Info, $"SELECTED TARIFF: {tariffParam}");

                tariffCalculator = TariffCalculatorFactory.CreateTariffCalculator(loggerManager, tariffParam);
                if (tariffCalculator == null)
                {
                    throw new InvalidOperationException("Could not create tariff calculator");
                }

                string traceM1Param = paramLoader.GetParam(PARAM_TRACE_M1) ?? "FALSE";
                tariffCalculator.SetTracerEnabled(traceM1Param.ToUpper() == "TRUE");

                string subTariffParam = paramLoader.GetParam(PARAM_SUBTARIFF);
                if (subTariffParam == null)
                {
                    throw new InvalidOperationException("Could not get system subtariff");
                }

                trace.Write(TraceLevel.Info, $"SELECTED SUBTARIFF: {subTariffParam}");

                if (!tariffCalculator.SelectSubtariff(subTariffParam))
                {
                    trace.Write(TraceLevel.Error, $"{subTariffParam} is not a valid subtariff");
                }

                string defaultArticleDef = paramLoader.GetParam(PARAM_DEFAULT_ARTICLE_DEF);
                if (String.IsNullOrEmpty(defaultArticleDef))
                {
                    throw new InvalidOperationException("Could not get system default article definition");
                }
                this.defaultArticleDef = int.Parse(defaultArticleDef);
                trace.Write(TraceLevel.Info, $"DEFAULT ARTICLE DEF : {defaultArticleDef}");

                string minCoin = paramLoader.GetParam(PARAM_MIN_COIN);
                if (String.IsNullOrEmpty(minCoin))
                {
                    throw new InvalidOperationException("Could not get PDM min coin");
                }
                trace.Write(TraceLevel.Info, $"PDM Min Coin: {minCoin}");
                tariffCalculator.SetMinCoinValue(long.Parse(minCoin));

                string lookOtherGroups = paramLoader.GetParam(PARAM_LOOK_OTHER_GROUPS);
                if (!String.IsNullOrEmpty(lookOtherGroups))
                {
                    this.lookOtherGroups = bool.Parse(lookOtherGroups);
                }

                string systemIdentifier = paramLoader.GetParam(PARAM_SYSTEM_IDENTIFIER);
                if (String.IsNullOrEmpty(systemIdentifier))
                {
                    throw new InvalidOperationException("Could not get System Identifier");
                }
                trace.Write(TraceLevel.Info, $"System Identifier {systemIdentifier}");

                GeneralParams.SystemId = int.Parse(systemIdentifier);

                fnResult = true;
            }
            catch (Exception error)
            {
                trace.Write(TraceLevel.Error, error.ToLogString());
            }

            return(fnResult);
        }