Esempio n. 1
0
        public HttpResponseMessage GetReasons(string reason)
        {
            var dateStart = DateTime.Now;

            _performancelog.Debug($"Start,ReasonController,GetReasons,{string.Empty},{dateStart:hh.mm.ss.ffffff}");

            if (!string.IsNullOrEmpty(reason))
            {
                reason = reason.Replace(" ", "");
            }
            ReasonType reasonType;

            Enum.TryParse(reason, true, out reasonType);
            var reasons    = _reasonManager.GetReasons(reasonType);
            var reasonName = _reasonManager.GetReasonType(reasonType);

            _performancelog.Debug($"End,ReasonController,GetReasons,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
            var response = new ReasonModel
            {
                ReasonTitle = reasonName,
                Reasons     = reasons.Select(r => new Reason
                {
                    Code        = r.Reason,
                    Description = r.Description
                }).ToList()
            };

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Esempio n. 2
0
        public void GetReasonTypeWhenTypeNotFoundTest()
        {
            _reasonService.Setup(t => t.GetReasonType(It.IsAny <char>()))
            .Returns((char type) => GetReasonTypeNameByType(type));
            _reasonManager = new ReasonManager(_reasonService.Object, _resourceManager);
            var actual = _reasonManager.GetReasonType(ReasonType.WriteOff);

            Assert.IsEmpty(actual);
        }
Esempio n. 3
0
        public void GetReasonTypeTest()
        {
            _reasonService.Setup(t => t.GetReasonType(It.IsAny <char>()))
            .Returns((char type) => GetReasonTypeNameByType(type));
            _reasonManager = new ReasonManager(_reasonService.Object, _resourceManager);
            var expected = "Price Changes";
            var actual   = _reasonManager.GetReasonType(ReasonType.PriceChanges);

            Assert.AreEqual(expected, actual);
        }