Ejemplo 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));
        }
Ejemplo n.º 2
0
        public void GetReasonsTest()
        {
            _reasonService.Setup(t => t.GetReasons(It.IsAny <char>()))
            .Returns((char type) => GetReasonsByType(type));
            _reasonManager = new ReasonManager(_reasonService.Object, _resourceManager);
            var expected = 2;
            var actual   = _reasonManager.GetReasons(ReasonType.Discounts);

            Assert.AreEqual(expected, actual.Count);
        }
Ejemplo n.º 3
0
        public void GetReasonsWhenNoReasonsTest()
        {
            _reasonService.Setup(t => t.GetReasons(It.IsAny <char>()))
            .Returns((char type) => GetReasonsByType(type));
            _reasonManager = new ReasonManager(_reasonService.Object, _resourceManager);
            var expected = 1;
            var actual   = _reasonManager.GetReasons(ReasonType.WriteOff);

            Assert.AreEqual(expected, actual.Count);
            var firstOrDefault = actual.FirstOrDefault();

            if (firstOrDefault != null)
            {
                Assert.AreEqual("0", firstOrDefault.Reason);
            }
        }