private void CreateTestData(NYCLandmarkContext dbContext)
        {
            var i            = 0;
            var boroughs     = EnumHelper.EnumToList <Borough>().Select(e => e.GetDescription());
            var boroughCodes = EnumHelper.EnumToList <Borough>().Select(e => e.GetAttribute <BoroughId>().Value);
            var objectTypes  = EnumHelper.EnumToList <ObjectType>().Select(e => e.GetDescription());

            GenFu.GenFu.Configure <LPCReport>()
            .Fill(l => l.Id, () => ++ i)
            .Fill(l => l.LPNumber, () => string.Format("LP-{0,5:D5}", i))
            .Fill(l => l.LPCId, () => string.Format("{0,5:D5}", i))
            .Fill(l => l.Borough, () => BaseValueGenerator.GetRandomValue(boroughs))
            .Fill(l => l.ObjectType, () => BaseValueGenerator.GetRandomValue(objectTypes));

            var lpcReports = GenFu.GenFu.ListOf <LPCReport>(20);

            dbContext.LPCReports.AddRange(lpcReports);

            var j = 0;

            GenFu.GenFu.Configure <Landmark>()
            .Fill(m => m.Id, () => ++ j)
            .Fill(l => l.LM_TYPE, () => BaseValueGenerator.GetRandomValue(objectTypes))
            .Fill(l => l.BoroughID, () => BaseValueGenerator.GetRandomValue(boroughCodes))
            .Fill(m => m.LP_NUMBER, () => string.Format("LP-{0,5:D5}", j));

            var landmarks = GenFu.GenFu.ListOf <Landmark>(20);

            dbContext.Landmarks.AddRange(landmarks);
            dbContext.SaveChanges();
        }
        public LPCReportServiceTest()
        {
            var services = new ServiceCollection();

            var builder = new ConfigurationBuilder();

            builder.SetBasePath(Directory.GetCurrentDirectory());
            builder.AddJsonFile("appsettings.json").Build();

            var connectionStringConfig = builder.Build();
            var dbonnection            = connectionStringConfig.GetConnectionString("SqlServer");

            services.AddDbContext <NYCLandmarkContext>(options =>
                                                       options.UseSqlServer(dbonnection));

            services.AddScoped <ILPCReportRepository, LPCReportRepository>();
            services.AddScoped <ILPCReportService, LPCReportService>();
            serviceProvider = services.BuildServiceProvider();

            dbContext           = serviceProvider.GetRequiredService <NYCLandmarkContext>();
            lpcReportRepository = serviceProvider.GetRequiredService <ILPCReportRepository>();
            lbcReportService    = serviceProvider.GetRequiredService <ILPCReportService>();

            AutoMapperConfiguration.Configure();
        }
Ejemplo n.º 3
0
        public LPCReportRepositoryTest()
        {
            var services = new ServiceCollection();

            services.AddDbContext <NYCLandmarkContext>(options =>
                                                       options.UseNpgsql(@"User ID=nyclandmarks;Password=nyclandmarks;Server=192.168.99.100;Port=5432;Database=nyclandmarks;Integrated Security=true;Pooling=true;"));

            services.AddScoped <ILPCReportRepository, LPCReportRepository>();
            serviceProvider = services.BuildServiceProvider();

            dbContext           = serviceProvider.GetRequiredService <NYCLandmarkContext>();
            lpcReportRepository = serviceProvider.GetRequiredService <ILPCReportRepository>();
        }
Ejemplo n.º 4
0
        public LandmarkRepositoryTest()
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json")
                          .Build();

            var dbonnection = builder.GetConnectionString("SqlServer");

            var serviceProvider = new ServiceCollection()
                                  .AddDbContext <NYCLandmarkContext>(options => options.UseSqlServer(dbonnection))
                                  .AddScoped <ILandmarkRepository, LandmarkRepository>()
                                  .BuildServiceProvider();

            serviceProvider.GetRequiredService <SqlServer.NYCLandmarkContext>();

            _dbContext          = serviceProvider.GetRequiredService <NYCLandmarkContext>();
            _landmarkRepository = serviceProvider.GetRequiredService <ILandmarkRepository>();
        }
Ejemplo n.º 5
0
 public LandmarkRepository(NYCLandmarkContext context)
     : base(context)
 {
 }