Exemple #1
0
        public static WorkDataLogProcessor InitialiseWorkDataLogProcessor(CloudTable workTable, CloudTable workRegistryTable,
                                                                          ICollector <string> ipfsImageProcesssinQueue)
        {
            var web3 = new Web3(ConfigurationSettings.GetEthereumRpcUrl());
            var workSearchService      = InitialiseWorkSearchService();
            var workRepository         = new WorkRepository(workTable);
            var workRegistryRepository = new WorkRegistryRepository(workRegistryTable);
            var ipfsQueue = new IpfsImageQueue(ipfsImageProcesssinQueue);

            Ujo.Repository.MappingBootstrapper.Initialise();
            var musicRecordingService = new MusicRecordingService(new UnitOfWork(new UjoContext(ConfigurationSettings.GetRepositoryConnectionString())));

            return(WorkDataLogProcessor.Create(web3, workRegistryRepository, ipfsQueue, workRepository, workSearchService, musicRecordingService));
        }
        public static WorkDataLogProcessor Create(Web3 web3,
                                                  IStandardDataRegistry dataRegistry,
                                                  IIpfsImageQueue imageQueue,
                                                  WorkRepository workRepository,
                                                  WorkSearchService workSearchService,
                                                  MusicRecordingService musicRecordingService
                                                  )
        {
            var services = new List <IStandardDataProcessingService <MusicRecordingDTO> >();

            services.Add(workRepository);
            services.Add(workSearchService);
            services.Add(new WorkIpfsImagesStandardDataProcessingService(imageQueue));
            services.Add(musicRecordingService);

            return(new WorkDataLogProcessor(web3, dataRegistry, services));
        }
Exemple #3
0
        public async Task ShouldBeAbleToUpsertMusicRecordingsIncludingOtherArtists()
        {
            MappingBootstrapper.Initialise();

            var address        = "XXXX";
            var musicRecording = new MusicRecordingDTO();

            musicRecording.Address = address;
            musicRecording.Name    = "my great track";
            //musicRecording.ObjectState = ObjectState.Added;
            musicRecording.OtherArtists.Add(new CreativeWorkArtistDTO()
            {
                ContributionType = "Featured", CreativeWorkAddress = address, NonRegisteredArtistName = "JB", Role = "Tambourine"
            });

            using (var context = new UjoContext())
            {
                var unitOfWork            = new UnitOfWork(context);
                var musicRecordingService = new MusicRecordingService(unitOfWork);
                await musicRecordingService.UpsertAsync(musicRecording).ConfigureAwait(false);
            }

            using (var context = new UjoContext())
                using (var unitOfWork = new UnitOfWork(context))
                {
                    var musicRecordingService = new MusicRecordingService(unitOfWork);
                    var recordingOutput       = await musicRecordingService.FindAsync(address).ConfigureAwait(false);

                    Assert.Equal(musicRecording.Name, recordingOutput.Name);
                    Assert.Equal(musicRecording.OtherArtists.ToList()[0].NonRegisteredArtistName, recordingOutput.OtherArtists.ToList()[0].NonRegisteredArtistName);
                }


            var musicRecording2 = new MusicRecordingDTO();

            musicRecording2.Address = address;
            musicRecording2.Name    = "my great track 2";
            // musicRecording2.ObjectState = ObjectState.Added;
            musicRecording2.OtherArtists.Add(new CreativeWorkArtistDTO()
            {
                ContributionType = "Featured", CreativeWorkAddress = address, NonRegisteredArtistName = "JB2", Role = "Tambourine"
            });

            using (var context = new UjoContext())
                using (var unitOfWork = new UnitOfWork(context))
                {
                    var musicRecordingService = new MusicRecordingService(unitOfWork);
                    await musicRecordingService.UpsertAsync(musicRecording2).ConfigureAwait(false);
                }

            using (var context = new UjoContext())
                using (var unitOfWork = new UnitOfWork(context))
                {
                    var musicRecordingService = new MusicRecordingService(unitOfWork);
                    var recordingOutput       = await musicRecordingService.FindAsync(address).ConfigureAwait(false);

                    Assert.Equal(musicRecording2.Name, recordingOutput.Name);
                    Assert.Equal(1, recordingOutput.OtherArtists.Count);
                    Assert.Equal(musicRecording2.OtherArtists.ToList()[0].NonRegisteredArtistName, recordingOutput.OtherArtists.ToList()[0].NonRegisteredArtistName);
                }
        }