public double GetAmountByYear(double amount, int year)
 {
     _myLogger.Log("");
     _myLogger.Log("");
     _myLogger.Log("");
     return(amount + amount * _inflationRate.Rate(year));
 }
Ejemplo n.º 2
0
        public void Start()
        {
            _logger.Log("Starting DmvWaitTime Service");

            foreach (var service in SchedulerFactory.GetSchedulers(_container))
            {
                service.ScheduleJob();
            }
        }
Ejemplo n.º 3
0
        public IActionResult GetAll()
        {
            _logger.Log($"Products list called at {DateTime.Now}");
            var result = _productDal.GetAll();

            if (result != null)
            {
                return(Ok(result));
            }

            return(BadRequest("Products cannot list"));
        }
        public void Get_WhenThereIsUnhandledException_ShouldReturn500StatusCodeAndLogAnException()
        {
            //Arrange
            A.CallTo(() => _productService.GetProducts()).Throws <Exception>();
            A.CallTo(() => _logger.Log(A <string> ._, A <Exception> ._)).DoesNothing();

            //Act
            var result = _sut.Get() as StatusCodeResult;

            //Assert
            A.CallTo(() => _productService.GetProducts()).MustHaveHappenedOnceExactly();
            A.CallTo(() => _logger.Log(A <string> ._, A <Exception> ._)).MustHaveHappenedOnceExactly();
            Assert.NotNull(result);
            Assert.Equal(StatusCodes.Status500InternalServerError, result.StatusCode);
        }
Ejemplo n.º 5
0
        public List <HugModel> Get() // <HugModel> sumapina
        {
            _logger.Log("Get started");

            var hugs       = _dbManager.GetHugs();
            var mappedHugs = hugs.Select(h => new HugModel
            {
                Id      = h.Id,
                From    = h.From,
                To      = h.To,
                Reason  = h.Reason,
                Created = h.Created
            })
                             .ToList();

            return(mappedHugs);
        }
Ejemplo n.º 6
0
        public string FormatMessage()
        {
            _somethingMaker.MakeSomething();
            _parametrizedSomethingMaker.MakeSomething();

            _logger.Log("formatting ...");

            return(string.Format(_formatProvider.GetFormat(), _argumentsProvider.GetArguments()));
        }
Ejemplo n.º 7
0
        public ActionResult <IEnumerable <string> > Get()
        {
            var strings = new string[] { "common value 1", "cool value 2" };

            foreach (var item in strings)
            {
                logger.Log(item);
            }
            return(strings);
        }
Ejemplo n.º 8
0
        public void OnActionExecuting(ActionExecutingContext context)
        {
            var builder = new StringBuilder();

            builder.AppendLine($"Path      : {context.HttpContext.Request.Path}");
            builder.AppendLine($"Method    : {context.HttpContext.Request.Method}");
            builder.AppendLine($"Remote ip : {context.HttpContext.Connection.RemoteIpAddress.ToString()}");
            builder.AppendLine($"Local  ip : {context.HttpContext.Connection.LocalIpAddress.ToString()}");

            logger.Log(builder.ToString());
        }
Ejemplo n.º 9
0
        public void Execute()
        {
            try
            {
                var currentOffices = _dmvOfficeProvider.GetDmvOffices();

                _dmvOfficeDataService.SaveDmvOffices(currentOffices);
            }
            catch (Exception ex)
            {
                _logger.Log(ex.Message);
            }
        }
Ejemplo n.º 10
0
        public void Execute()
        {
            try
            {
                IEnumerable <CurrentDmvWaitTimes> dmvWaitTimes = _dmvWaitTimeDataService.LoadDmvWaitTime();

                var dmvBestVistTimes = _dmvBestVisitTimeService.GetDmvBestVisitTimes(dmvWaitTimes);

                _dmvBestVisitTimeDataService.SaveDmvBestVisitTime(dmvBestVistTimes);
            }
            catch (Exception err)
            {
                _logger.Log(err.Message);
            }
        }
 public ActionResult Get()
 {
     try
     {
         var products = _productService.GetProducts();
         if (products?.Count > 0)
         {
             return(Ok(products));
         }
         return(NotFound());
     }
     catch (Exception ex)
     {
         _logger.Log($"The method {nameof(ProductService.GetProducts)} caused an exception", ex);
     }
     return(StatusCode(StatusCodes.Status500InternalServerError));
 }
Ejemplo n.º 12
0
        public void Execute()
        {
            try
            {
                var currentDateTime = DateTime.Now;

                var currentDmvWaitTimes = _dmvWaitTimeProvider.GetCurrentDmvWaitTimes();

                _dmvWaitTimeDataService.SaveDmvWaitTime(
                    new CurrentDmvWaitTimes
                {
                    CurrentDateTime = currentDateTime,
                    DmvWaitTimes    = currentDmvWaitTimes
                });
            }
            catch (Exception ex)
            {
                _logger.Log(ex.Message);
            }
        }
Ejemplo n.º 13
0
        public void Setup()
        {
            logger = Substitute.For <IMyLogger>();
            logger.Log(Arg.Any <string>());

            repository = Substitute.For <IIpLockRepository>();
            repository.IsLocked(Arg.Any <IPAddress>()).Returns(false);

            foreach (var address in lockedIps)
            {
                repository.IsLocked(Arg.Is(address.MakeIpAddress())).Returns(true);
            }
            foreach (var address in unlockedIps)
            {
                repository.IsLocked(Arg.Is(address.MakeIpAddress())).Returns(false);
            }

            container = new WindsorContainer();

            container.Register(Component.For <IMyLogger>().Instance(logger));
            container.Register(Component.For <IIpLockRepository>().Instance(repository));
            container.Register(Component.For <IMyActionFilter>().ImplementedBy <IpLockFilter>().LifestyleTransient());

            filter = container.Resolve <IMyActionFilter>();

            var actionContext = new ActionContext(
                Substitute.For <HttpContext>(),
                Substitute.For <RouteData>(),
                Substitute.For <ActionDescriptor>(),
                Substitute.For <ModelStateDictionary>()
                );

            context = new ActionExecutingContext(
                actionContext,
                Substitute.For <IList <IFilterMetadata> >(),
                Substitute.For <IDictionary <string, object> >(),
                Substitute.For <ControllerBase>()
                );
        }
Ejemplo n.º 14
0
 public int CalculateC()
 {
     _logger.Log("service C");
     return(2);
 }
Ejemplo n.º 15
0
 public void GetTenant()
 {
     _myLogger.Log(HttpContext.Current.Request.Url.ToString());
 }
Ejemplo n.º 16
0
 public int CalculateA()
 {
     _myLogger.Log("ServiceA");
     return(10 * _serviceB.CalculateB());
 }
Ejemplo n.º 17
0
 public override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     _myLogger.Log("OnActionExecuting", filterContext.RouteData);
     _tenantService.GetTenant();
 }
Ejemplo n.º 18
0
 public int CalculateB()
 {
     _logger.Log("Service B");
     return(5 * _serviceC.CalculateC());
 }
Ejemplo n.º 19
0
 public void OnActionExecuted(ActionExecutedContext context)
 {
     logger.Log("Everything fine");
 }