Exemple #1
0
 public FaceScanner(
     MediaStoreContext storeContext,
     IMediaProcessorFlowFactory flowFactory)
 {
     _storeContext = storeContext;
     _flowFactory  = flowFactory;
 }
        public async Task GetOrCreatePerson_New_PersonCreated()
        {
            // Arrange
            IMongoDatabase db = _mongo.CreateDatabase();

            var dbContext = new MediaStoreContext(new MongoOptions
            {
                ConnectionString = _mongo.ConnectionString,
                DatabaseName     = db.DatabaseNamespace.DatabaseName
            });

            var personStore = new PersonStore(dbContext);
            var newPerson   = new Person
            {
                Id          = Guid.NewGuid(),
                Name        = "Bart",
                DateOfBirth = new DateTime(1980, 4, 2),
                Groups      = new List <Guid>()
                {
                    Guid.NewGuid()
                }
            };

            // Act
            Person person = await personStore
                            .AddAsync(newPerson, default);

            // Assert
            Person cratedPerson = await dbContext.Persons.AsQueryable()
                                  .Where(x => x.Id == newPerson.Id)
                                  .FirstOrDefaultAsync();

            cratedPerson.Name.Should().Be(person.Name);
        }
Exemple #3
0
 public VideoConverter(
     MediaStoreContext storeContext,
     IMediaBlobStore mediaBlobStore,
     IVideoProcessingService videoProcessing)
 {
     _storeContext    = storeContext;
     _mediaBlobStore  = mediaBlobStore;
     _videoProcessing = videoProcessing;
 }
Exemple #4
0
        public Task Invoke(HttpContext context)
        {
            // context.Request;
            Account acct = MediaStoreContext.GetContext().FindAccount("jpompeii");

            context.Items["Account"] = acct;

            // Call the next delegate/middleware in the pipeline
            Task nextTask = this._next(context);

            MediaStoreContext.FreeContext();
            return(nextTask);
        }
Exemple #5
0
        public async Task InitializeAsync()
        {
            MongoResource = new MongoResource();
            await MongoResource.InitializeAsync();

            Database = MongoResource.CreateDatabase();

            DbContext = new MediaStoreContext(
                new MongoOptions
            {
                ConnectionString = MongoResource.ConnectionString,
                DatabaseName     = Database.DatabaseNamespace.DatabaseName
            });

            IWebHostBuilder hostBuilder = new WebHostBuilder()
                                          .ConfigureAppConfiguration(builder =>
            {
                builder.SetBasePath(Directory.GetCurrentDirectory());
                builder.AddJsonFile("appsettings.test.json", optional: true);
                builder.AddInMemoryCollection(new Dictionary <string, string>
                {
                    ["MagicMedia:Database:ConnectionString"] =
                        MongoResource.ConnectionString,
                    ["MagicMedia:Database:DatabaseName"] =
                        Database.DatabaseNamespace.DatabaseName
                });
            })
                                          .ConfigureTestServices(services =>
            {
                services.AddSingleton(_httpClientFactory);
                services.AddMagicMediaTest();
                services.RemoveAll <IOperationExecutorFactory>();
                services.AddSingleton <IOperationExecutorFactory>(sp =>
                                                                  new HttpOperationExecutorFactory(
                                                                      "MagicMediaTest",
                                                                      sp.GetRequiredService <InMemoryHttpClientFactory>().CreateClient,
                                                                      PipelineFactory(sp),
                                                                      sp));
            })
                                          .UseStartup <Startup>();

            var server = new TestServer(hostBuilder);

            Services      = server.Services;
            HttpClient    = server.CreateClient();
            GraphQLClient = Services.GetService <IMagicMediaTest>();
            _httpClientFactory.HttpClient             = server.CreateClient();
            _httpClientFactory.HttpClient.BaseAddress = new Uri("http://localhost/graphql");

            await SeedIntialDataAsync();
        }
Exemple #6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            IFileCache cache     = new FileCache(Configuration);
            IFileStore fileStore = new FileStore(cache);

            services.AddSingleton(typeof(IFileStore), fileStore);
            services.AddSingleton <IStorageService, StorageService>();
            services.AddSingleton <IDefaultStorageProvider, LocalFS>();
            var mvc         = services.AddMvc();
            var storageAssy = Assembly.Load(new AssemblyName("StorageService"));

            mvc.AddApplicationPart(storageAssy);
            mvc.AddJsonOptions(opt =>
            {
                var resolver = opt.SerializerSettings.ContractResolver;
                if (resolver != null)
                {
                    var res            = resolver as DefaultContractResolver;
                    res.NamingStrategy = null;  // this removes the camelcasing
                }
            });

            MediaStoreContext.ConfigureModel();
        }
Exemple #7
0
 public BulkMediaUpdater(IMediaService mediaService, IFaceService faceService, MediaStoreContext context)
 {
     _mediaService = mediaService;
     _faceService  = faceService;
     _context      = context;
 }
Exemple #8
0
 public ImageHasher(MediaStoreContext dbContext, IMediaService mediaService)
 {
     _dbContext    = dbContext;
     _mediaService = mediaService;
 }
Exemple #9
0
        public async Task InitializeAsync()
        {
            Containers = new ComposeResource <MagicApiAppOptions>();
            await Containers.InitializeAsync();

            MongoResource = Containers.GetResource <MongoResource>("mongo");
            IdentityHost  = Containers
                            .GetResource <GenericContainerResource <IdentityHostOptions> >("identity");

            Database = MongoResource.CreateDatabase();

            DbContext = new MediaStoreContext(
                new MongoOptions
            {
                ConnectionString = MongoResource.ConnectionString,
                DatabaseName     = Database.DatabaseNamespace.DatabaseName
            });

            string identityUrl = IdentityHost.GetContainerUri().ToString();

            IWebHostBuilder hostBuilder = new WebHostBuilder()
                                          .ConfigureAppConfiguration(builder =>
            {
                builder.SetBasePath(Directory.GetCurrentDirectory());
                builder.AddJsonFile("appsettings.test.json", optional: true);
                builder.AddInMemoryCollection(new Dictionary <string, string>
                {
                    ["MagicMedia:Database:ConnectionString"] =
                        MongoResource.ConnectionString,
                    ["MagicMedia:Database:DatabaseName"] =
                        Database.DatabaseNamespace.DatabaseName,
                    ["MagicMedia:Security:Authority"] = identityUrl
                });
            })
                                          .ConfigureTestServices(services =>
            {
                services.AddSingleton(_httpClientFactory);
                services.AddMagicMediaTest();
                services.RemoveAll <IOperationExecutorFactory>();
                services.AddSingleton <IOperationExecutorFactory>(sp =>
                                                                  new HttpOperationExecutorFactory(
                                                                      "MagicMediaTest",
                                                                      sp.GetRequiredService <InMemoryHttpClientFactory>().CreateClient,
                                                                      PipelineFactory(sp),
                                                                      sp));
            })
                                          .UseStartup <Startup>();

            var server = new TestServer(hostBuilder);

            Services   = server.Services;
            HttpClient = server.CreateClient();

            GraphQLClient = Services.GetService <IMagicMediaTest>();
            _httpClientFactory.HttpClient             = server.CreateClient();
            _httpClientFactory.HttpClient.BaseAddress = new Uri("http://localhost/graphql");
            _httpClientFactory.TokenResolver          = GetTokenAsync;

            await SeedIntialDataAsync();

            //TODO. Improve readycheck for IdentityServer container
            await Task.Delay(TimeSpan.FromSeconds(1));
        }
Exemple #10
0
 public DataSeeder(MediaStoreContext mediaStoreContext)
 {
     _mediaStoreContext = mediaStoreContext;
 }
Exemple #11
0
 public MediaStoreController(IFileStore fileStore)
 {
     this.fileStore = fileStore;
     Context        = MediaStoreContext.GetContext();
 }