Exemplo n.º 1
0
        public void SetUp()
        {
            LiteDBFunctions.DoLiteDBGlobalSetUp();

            rawContentRepository          = new LiteDBRawContentRepository(new LiteDatabase(":memory:"));
            unprocessedDocumentRepository = new LiteDBUnprocessedDocumentRepository(new LiteDatabase(":memory:"));

            system = new AggregatorSystem
                     (
                RawContentRepository: rawContentRepository,
                UnprocessedDocumentRepository: unprocessedDocumentRepository
                     );
        }
Exemplo n.º 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors(options =>
            {
                options.AddPolicy(name: MyAllowSpecificOrigins,
                                  builder =>
                {
                    builder.AllowAnyOrigin()
                    .AllowAnyMethod()
                    .AllowAnyHeader()
                    .WithOrigins("http://localhost:4201");
                });
            });

            LiteDBFunctions.DoLiteDBGlobalSetUp();

            var databaseDirectory = Path.GetDirectoryName(DatabaseFilePath);

            Directory.CreateDirectory(databaseDirectory);   // TODO: error handling and logging

            var database                      = new LiteDB.LiteDatabase($"Filename={DatabaseFilePath}");
            var rawContentRepository          = new LiteDBRawContentRepository(database);
            var unprocessedDocumentRepository = new LiteDBUnprocessedDocumentRepository(database);
            var system = new AggregatorSystem(rawContentRepository, unprocessedDocumentRepository);

            services.AddSingleton(typeof(AggregatorSystem), system);

            services
            .AddControllers()
            .AddJsonOptions(o =>
            {
                o.JsonSerializerOptions.Converters.Add(new InstantJsonConverter());
                o.JsonSerializerOptions.Converters.Add(new UnprocessedDocumentContentJsonConverter());

                // for serializing enums as strings (https://stackoverflow.com/questions/59096102/asp-net-mvc-core-api-serialize-enums-to-string)
                o.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
            });

            services.AddMvc().AddJsonOptions(options =>
            {
                options.JsonSerializerOptions.MaxDepth = 64;
            });

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "Aggregator", Version = "v1"
                });
            });
        }
 public void SetUp()
 {
     LiteDBFunctions.DoLiteDBGlobalSetUp();
     repository = new LiteDBRawContentRepository(new LiteDatabase(":memory:"));
 }
Exemplo n.º 4
0
 public void SetUp()
 {
     LiteDBFunctions.DoLiteDBGlobalSetUp();
     repository = new LiteDBUnprocessedDocumentRepository(new LiteDatabase(":memory:"));
 }
Exemplo n.º 5
0
 public void SetUp()
 {
     LiteDBFunctions.DoLiteDBGlobalSetUp();
     database = new LiteDatabase(":memory:");
 }