コード例 #1
0
        public static Chemistry PredictChemistry(string leaderBirthday, string playerBirthday)
        {
            Birthday leaderConverted = Birthday.Parse(leaderBirthday);
            Birthday playerConverted = Birthday.Parse(playerBirthday);

            return(PredictChemistry(leaderConverted, playerConverted));
        }
コード例 #2
0
        public static void ConfigureRepositories(this IContainer container)
        {
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMissingTypeMaps = false;
                cfg.CreateMap <DateTime, LocalDate>().ConvertUsing(x => new LocalDate(x.Year, x.Month, x.Day));
                cfg.CreateMap <LocalDate, DateTime>().ConvertUsing(x => new DateTime(x.Year, x.Month, x.Day, 0, 0, 0, DateTimeKind.Utc));
                cfg.CreateMap <Birthday, string>().ConvertUsing(x => x == null ? null : x.ToString());
                cfg.CreateMap <string, Birthday>().ConvertUsing(x => x == null ? null : Birthday.Parse(x));
                cfg.CreateMap <Gender, string>().ConvertUsing(x => x.ToString());
                cfg.CreateMap <string, Gender>().ConvertUsing(x => (Gender)Enum.Parse(typeof(Gender), x));
                cfg.CreateMap <CustomerStorageElement, Customer>().ReverseMap();
                cfg.CreateMap <CustomerStorageElement, CustomerIndexByPhoneStorageElement>().ForMember(x => x.CustomerId,
                                                                                                       expression => expression.MapFrom(x => x.Id));
                cfg.CreateMap <WorkerStorageElement, Worker>().ReverseMap();
                cfg.CreateMap <Birthday, Birthday>();
                cfg.CreateMap <Customer, Customer>();
                cfg.CreateMap <Worker, Worker>();
                cfg.CreateMap <ServiceCalendarRecord, ServiceCalendarRemovedRecord>().ReverseMap();
                cfg.CreateMap <PublicLinkToShopIdStorageElement, PublicLink>().ReverseMap();
                cfg.CreateMap <PublicLinkToShopIdStorageElement, ShopIdToPublicLinkStorageElement>();
            });

            config.AssertConfigurationIsValid();
            config.CompileMappings();

            container.Configurator.ForAbstraction <IMapper>().UseInstances(new Mapper(config));
            var cassandraSettings = container.Get <ICassandraSettings>();

            container.ConfigureContainerForWorkingWithCassandra();
            container.ConfigureCassandraStorages();
            container.Configurator.ForAbstraction <ILocker>().UseInstances(
                new Locker(container.Get <ICassandraSessionsManager>(),
                           new LockSettings(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(cassandraSettings.LockTtlSeconds), cassandraSettings.LockKeyspace),
                           new LockMetrics(cassandraSettings.LockKeyspace))
                );
        }
コード例 #3
0
 public void BirtdayFailParseTest(string birthdayString)
 {
     Assert.Throws <FormatException>(() => Birthday.Parse(birthdayString))
     .Message.Should().Be("Expected dd.mm.yyyy or dd.mm");
 }
コード例 #4
0
 public void BirtdaySuccessfulParseTest(string birthdayString, Birthday expectedBirthday)
 {
     Birthday.Parse(birthdayString).Should().Be(expectedBirthday);
 }