예제 #1
0
        public ServiceProvider BuildServiceProvider()
        {
            var services = new ServiceCollection();

            this.ConfigureExternalServices(services);

            services.AddLogging(builder =>
                                builder.AddSerilog(
                                    new LoggerConfiguration()
                                    .Destructure.ByTransforming <LocalDate>(d =>
                                                                            LocalDatePattern.CreateWithCurrentCulture("yyyy-MM-dd").Format(d))
                                    .MinimumLevel.Debug()
                                    .Enrich.FromLogContext()
                                    .WriteTo.Console(new CompactJsonFormatter())
                                    .CreateLogger(),
                                    dispose: true));

            services.AddScoped <IEmailProvider, EmailProvider>();
            services.AddScoped <IDatabaseProvider, DatabaseProvider>();
            services.AddScoped <IIdentityProvider, IdentityProvider>();
            services.AddScoped <INotificationProvider, NotificationProvider>();
            services.AddScoped <IStorageProvider, StorageProvider>();

            services.AddScoped <IAllocationCreator, AllocationCreator>();
            services.AddScoped <AllocationNotifier>();
            services.AddScoped <IBankHolidayRepository, BankHolidayRepository>();
            services.AddScoped <IConfigurationRepository, ConfigurationRepository>();
            services.AddScoped <IDateCalculator, DateCalculator>();
            services.AddScoped <IEmailRepository, EmailRepository>();
            services.AddScoped <INotificationRepository, NotificationRepository>();
            services.AddScoped <Random>();
            services.AddScoped <IRequestRepository, RequestRepository>();
            services.AddScoped <IRequestSorter, RequestSorter>();
            services.AddScoped <RequestUpdater>();
            services.AddScoped <IReservationRepository, ReservationRepository>();
            services.AddScoped <IScheduleRepository, ScheduleRepository>();
            services.AddScoped <ScheduledTaskRunner>();
            services.AddScoped <TriggerManager>();
            services.AddScoped <ITriggerRepository, TriggerRepository>();
            services.AddScoped <IUserRepository, UserRepository>();

            services.AddScoped <IScheduledTask, DailyNotification>();
            services.AddScoped <IScheduledTask, RequestReminder>();
            services.AddScoped <IScheduledTask, ReservationReminder>();
            services.AddScoped <IScheduledTask, SoftInterruptionUpdater>();
            services.AddScoped <IScheduledTask, WeeklyNotification>();

            return(services.BuildServiceProvider());
        }
예제 #2
0
        public void CreateWithCurrentCulture()
        {
            var date = new LocalDate(2017, 8, 23);

            using (CultureSaver.SetCultures(Cultures.FrFr))
            {
                var pattern = LocalDatePattern.CreateWithCurrentCulture("d");
                Assert.AreEqual("23/08/2017", pattern.Format(date));
            }
            using (CultureSaver.SetCultures(Cultures.FrCa))
            {
                var pattern = LocalDatePattern.CreateWithCurrentCulture("d");
                Assert.AreEqual("2017-08-23", pattern.Format(date));
            }
        }
예제 #3
0
        public static void Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
                         .Destructure.ByTransforming <LocalDate>(d =>
                                                                 LocalDatePattern.CreateWithCurrentCulture("yyyy-MM-dd").Format(d))
                         .MinimumLevel.Debug()
                         .MinimumLevel.Override("Parking.Api.Authentication.DefaultAuthenticationHandler", LogEventLevel.Information)
                         .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
                         .MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning)
                         .Enrich.FromLogContext()
                         .WriteTo.Console(new CompactJsonFormatter())
                         .CreateLogger();

            CreateHostBuilder(args).Build().Run();
        }
예제 #4
0
        public void CanNotSellAnExpiredPie(
            string expiryDateString,
            string currentDateString,
            [Frozen(Matching.ImplementedInterfaces)] FakeClock fakeClock,
            [Frozen(Matching.ImplementedInterfaces)] ProductValidationService productValidationService,
            [Frozen(Matching.ImplementedInterfaces)] DiscountService discountService,
            Basket basket)
        {
            productValidationService.AddValidator(new ExpiredPieValidator(fakeClock));

            LocalDate expiryDate  = LocalDatePattern.CreateWithCurrentCulture("dd/MM/yyyy").Parse(expiryDateString).Value;
            Instant   currentDate = InstantPattern.CreateWithCurrentCulture("dd/MM/yyyy").Parse(currentDateString).Value;

            fakeClock.Reset(currentDate);

            Pie pie = new Pie(default(Price), expiryDate);

            AddResult result = basket.Add(pie);

            result.Success.Should().BeFalse();
        }
예제 #5
0
 public static string ForDisplay(this LocalDate localDate) =>
 LocalDatePattern.CreateWithCurrentCulture("dd MMM").Format(localDate);
예제 #6
0
 public ReportGenerator(WeekProvider weekProvider)
 {
     this.weekProvider = weekProvider;
     this.datePattern  = LocalDatePattern.CreateWithCurrentCulture("d");
 }