protected override void ScenarioSetup() { ExplicitMappings.Setup(instance => instance.GetEnumerator()) .Returns(Enumerable.Range(0, 2).Select(_ => EntityMapping.Object).GetEnumerator()); MappingRepository.As <IEnumerable <IEntityMapping> >().Setup(instance => instance.GetEnumerator()) .Returns(Enumerable.Range(0, 3).Select(_ => EntityMapping.Object).GetEnumerator()); }
public void Sample_WithInitializers_UsesInitializer() { var source = this.CreateSource(); var repo = new MappingRepository(); repo.InitializeMappings(); SampleInitializer.Repos.ShouldContain(repo); }
public void ResolveMapper2_ExistingMapper_ResolvesCorrectly() { var target = new MappingRepository(); var mapper = target.ResolveMapper(typeof(TTarget), typeof(TSource)); Assert.IsNotNull(mapper); Assert.IsInstanceOf <CompositeMapper <TTarget, TSource> >(mapper); Assert.IsTrue(((CompositeMapper <TTarget, TSource>)mapper).InnerMappers.Any()); }
public void AddMapperTest() { IExtensibleMapper <TSource, TTarget> expected = new ManualMapper <TSource, TTarget>(); var target = new MappingRepository(); target.AddMapper(expected); var actual = target.ResolveMapper <TSource, TTarget>(); Assert.AreEqual(expected, actual); }
public void ClearTest() { IExtensibleMapper <TSource, TTarget> mapper = new ManualMapper <TSource, TTarget>(); var target = new MappingRepository(); target.AddMapper(mapper); target.Clear(); var mappersField = target.GetType().GetField("mappers", BindingFlags.NonPublic | BindingFlags.Instance); var mappers = (IEnumerable)mappersField.GetValue(target); Assert.IsFalse(mappers.Cast <object>().Any()); }
public ActionResult V3Request() { var mapping = new MappingRepository().Search("v3"); if (mapping != null) { List <RecordValueViewModel> result = Crawler.Crawl(Factory.Convert(mapping)); var matchList = ClassMapper.Map <News>(result); return(View(matchList)); } return(null); }
public ActionResult MatchCrawlRequest() { var mapping = new MappingRepository().Search(StaticString.MatchCrawlingKey); if (mapping != null) { List <RecordValueViewModel> result = Crawler.Crawl(Factory.Convert(mapping)); var matchList = ClassMapper.Map <Match>(result).OrderBy(m => m.League); return(View(matchList)); } return(null); }
public ActionResult TransferCrawlRequest() { var mapping = new MappingRepository().Search(StaticString.TransferCrawlingKey); if (mapping != null) { List <RecordValueViewModel> result = Crawler.Crawl(Factory.Convert(mapping)); var transferList = ClassMapper.Map <Transfer>(result).OrderBy(t => t.Team).ThenBy(t => t.TransferType); return(View(transferList)); } return(null); }
public void AddMappingGeneric_DefaultCase_RedirectsToMapper() { var target = new MappingRepository(); var mapperMock = A.Fake <IExtensibleMapper <TSource, TTarget> >(); target.AddMapper <TSource, TTarget>(mapperMock); var sourceMemberName = "source"; var targetMemberName = "target"; var mappingAction = new MappingAction <TSource, TTarget>((s, t) => { }); target.AddMappingAction(sourceMemberName, targetMemberName, mappingAction); A.CallTo(() => mapperMock.AddMappingAction(sourceMemberName, targetMemberName, mappingAction)) .MustHaveHappened(); }
public void Sample_FluentMappingViaMapper_MapsCorrectly() { var mappingRepo = new MappingRepository(); var source = this.CreateSource(); var mapper = mappingRepo.ResolveMapper <Person, PersonEditModel>(); mapper.AddMapping() .From(p => p.FirstName + p.LastName) .To(pi => pi.Name); var result = mapper.Map(source); MappingRepository.Default.Clear(); result.ShouldNotBe(null); this.CheckMapping(source, result); result.Name.ShouldBe(source.FirstName + source.LastName); }
public JsonResult AddTheme(Theme theme, int organisationID, int subOrganisationID, int applicationID) { ThemeRepository themeRepository = new ThemeRepository(); int id = themeRepository.Insert(theme); Mapping mapping = new Mapping() { OrganisationID = organisationID == 0 ? null : (int?)Convert.ToInt32(organisationID), SubOrganisationID = subOrganisationID == 0 ? null : (int?)Convert.ToInt32(subOrganisationID), ApplicationID = applicationID == 0 ? null : (int?)Convert.ToInt32(applicationID), ThemeID = id }; MappingRepository mappingRepository = new MappingRepository(); mappingRepository.Insert(mapping); return(Json(new { id = id }, JsonRequestBehavior.AllowGet)); }
protected virtual IMapper <TSource, TTarget> CreateMapper(Type[] innerMappers) { IMappingRepository repo = null; if (innerMappers != null) { var options = new MappingOptions(innerMappers); repo = new MappingRepository(options); } else { repo = new MappingRepository(); } var mapper = repo.ResolveMapper <TSource, TTarget>(); this.AddMappingActions(mapper); return(mapper); }
public void Sample_SingleMapperSequenceOverride_CreatesCorrectly() { var source = this.CreateSource(); var repo = new MappingRepository(o => o.MapperOrder .UseJust <ManualMapper <object, object> >() ); repo.AddMapping <Person, PersonEditModel>() .From(s => 111) .To(t => t.Id); var mapper = repo.ResolveMapper <Person, PersonEditModel>(); var result = mapper.Map(source); result.ShouldNotBe(null); result.Id.ShouldBe(111); }
public ActionResult CreateTransferUrls() { string url = "http://uk.soccerway.com/players/transfers/?ICID=TN_04"; HtmlWeb web = new HtmlWeb(); HtmlDocument document = web.Load(url); //first get league List <string> leagueValues = new List <string>(); List <string> leagueUrls = new List <string>(); int counter = 1; while (true) { string dropXpath = string.Format("//*[@id='competition-select']/option[{0}]", counter++); var drop = document.DocumentNode.SelectSingleNode(dropXpath); if (drop == null) { break; } leagueValues.Add(drop.GetAttributeValue("value", "")); leagueUrls.Add( string.Format( "http://uk.soccerway.com/a/block_players_transfers?block_id=page_players_1_block_players_transfers_4&callback_params=%7B%22year%22%3A%222017%22%2C%22season_id%22%3A%22{0}%22%7D&action=showTransfers¶ms=%7B%22season_id%22%3A%22{1}%22%7D", (leagueValues.Count >= 1) ? leagueValues[leagueValues.Count - 1] : "11360", drop.GetAttributeValue("value", ""))); } List <Url> lstUrls = new List <Url>(); var mapping = new MappingRepository().Search(StaticString.TransferCrawlingKey); foreach (string leagueUrl in leagueUrls) { lstUrls.Add(new Url() { Link = leagueUrl, MappingCode = mapping.Id, }); } _db.Urls.AddRange(lstUrls); _db.SaveChanges(); return(RedirectToAction("Index")); }
public void PASS_GetClusterMapping() { string clusterSettingsJson = EmbeddedResource.GetContentOfEmbeddedResourceFile(typeof(UnitTests_MappingRepository).Assembly, "Bolay.Elastic.Api.Mapping.Tests.MappingExamples.MultiIndexSettings.json"); string clusterMappingJson = EmbeddedResource.GetContentOfEmbeddedResourceFile(typeof(UnitTests_MappingRepository).Assembly, "Bolay.Elastic.Api.Mapping.Tests.MappingExamples.ElasticMappingByCluster.txt"); IEnumerable<Settings.Models.Settings> clusterSettings = JsonConvert.DeserializeObject<Settings.Models.SettingsCollection>(clusterSettingsJson); _MockedSettingsRepository.Setup(x => x.Get()) .Returns(clusterSettings); _MockedhttpLayer.Setup(x => x.Get(It.IsAny<HttpRequest>())) .Returns(new HttpResponse(HttpStatusCode.OK, clusterMappingJson)); MappingRepository mappingRepo = new MappingRepository( new ElasticUriProvider("http://es:9200/"), _MockedSettingsRepository.Object, _MockedhttpLayer.Object); IEnumerable<IndexMapping> clusterMappings = mappingRepo.GetClusterMapping(); Assert.IsNotNull(clusterMappings); Assert.IsTrue(clusterMappings.Any()); }
public void Sample_FluentMappingViaMapper_MapsCorrectly() { var mappingRepo = new MappingRepository(); var source = this.CreateSource(); var mapper = mappingRepo.ResolveMapper<Person, PersonEditModel>(); mapper.AddMapping() .From(p => p.FirstName + p.LastName) .To(pi => pi.Name); var result = mapper.Map(source); MappingRepository.Default.Clear(); result.ShouldNotBe(null); this.CheckMapping(source, result); result.Name.ShouldBe(source.FirstName + source.LastName); }
public void MyTestInitialize() { _mappingRepository = new MappingRepository(); }
public int AddOrUpdate(MappingSyncModel mapping) { var rep = new MappingRepository(new DatabaseFactory()); return(rep.AddOrUpdate(mapping)); }
public int Remove(MappingSyncModel mappingSyncModel) { var repo = new MappingRepository(new DatabaseFactory()); return(repo.Remove(mappingSyncModel, true)); }
public void foo() { var repo = new MappingRepository(); //repo.MapperOrder }
public DataTable ProcessPipelineData(DataTable toProcess, IDataLoadEventListener listener, GracefulCancellationToken cancellationToken) { //Things we ignore, Lookups, SupportingSql etc if (_extractCommand == null) { listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Information, "Ignoring non dataset command ")); return(toProcess); } //if it isn't a dicom dataset don't process it if (!toProcess.Columns.Contains(RelativeArchiveColumnName)) { listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Warning, "Dataset " + _extractCommand.DatasetBundle.DataSet + " did not contain field '" + RelativeArchiveColumnName + "' so we will not attempt to extract images")); return(toProcess); } if (_putter == null) { _putter = (IPutDicomFilesInExtractionDirectories) new ObjectConstructor().Construct(PutterType); } var projectNumber = _extractCommand.Configuration.Project.ProjectNumber.Value; var mappingServer = new MappingRepository(UIDMappingServer); var destinationDirectory = new DirectoryInfo(Path.Combine(_extractCommand.GetExtractionDirectory().FullName, "Images")); var releaseCol = _extractCommand.QueryBuilder.SelectColumns.Select(c => c.IColumn).Single(c => c.IsExtractionIdentifier); // See: ftp://medical.nema.org/medical/dicom/2011/11_15pu.pdf var flags = DicomAnonymizer.SecurityProfileOptions.BasicProfile | DicomAnonymizer.SecurityProfileOptions.CleanStructdCont | DicomAnonymizer.SecurityProfileOptions.CleanDesc | DicomAnonymizer.SecurityProfileOptions.RetainUIDs; if (RetainDates) { flags |= DicomAnonymizer.SecurityProfileOptions.RetainLongFullDates; } var profile = DicomAnonymizer.SecurityProfile.LoadProfile(null, flags); var anonymiser = new DicomAnonymizer(profile); using (var pool = new ZipPool()) { _sw.Start(); foreach (DataRow row in toProcess.Rows) { if (_errors > 0 && _errors > ErrorThreshold) { throw new Exception($"Number of errors reported ({_errors}) reached the threshold ({ErrorThreshold})"); } cancellationToken.ThrowIfAbortRequested(); var path = new AmbiguousFilePath(ArchiveRootIfAny, (string)row[RelativeArchiveColumnName]); DicomFile dicomFile; try { dicomFile = path.GetDataset(pool); } catch (Exception e) { listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Error, $"Failed to get image at path '{path.FullPath}'", e)); _errors++; continue; } //get the new patient ID var releaseId = row[releaseCol.GetRuntimeName()].ToString(); DicomDataset ds; try { ds = anonymiser.Anonymize(dicomFile.Dataset); } catch (Exception e) { listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Error, $"Failed to anonymize image at path '{path.FullPath}'", e)); _errors++; continue; } //now we want to explicitly use our own release Id regardless of what FoDicom said ds.AddOrUpdate(DicomTag.PatientID, releaseId); //rewrite the UIDs foreach (var kvp in UIDMapping.SupportedTags) { if (!ds.Contains(kvp.Key)) { continue; } var value = ds.GetValue <string>(kvp.Key, 0); //if it has a value for this UID if (value == null) { continue; } var releaseValue = mappingServer.GetOrAllocateMapping(value, projectNumber, kvp.Value); //change value in dataset ds.AddOrUpdate(kvp.Key, releaseValue); //and change value in DataTable if (toProcess.Columns.Contains(kvp.Key.DictionaryEntry.Keyword)) { row[kvp.Key.DictionaryEntry.Keyword] = releaseValue; } } var newPath = _putter.WriteOutDataset(destinationDirectory, releaseId, ds); row[RelativeArchiveColumnName] = newPath; _anonymisedImagesCount++; listener.OnProgress(this, new ProgressEventArgs("Writing ANO images", new ProgressMeasurement(_anonymisedImagesCount, ProgressType.Records), _sw.Elapsed)); } _sw.Stop(); } return(toProcess); }
public void foo() { var repo = new MappingRepository(); //repo.MapperOrder }
public void Sample_WithInitializers_UsesInitializer() { var source = this.CreateSource(); var repo = new MappingRepository(); repo.InitializeMappings(); SampleInitializer.Repos.ShouldContain(repo); }
public void Sample_SingleMapperSequenceOverride_CreatesCorrectly() { var source = this.CreateSource(); var repo = new MappingRepository(o => o.MapperOrder .UseJust<ManualMapper<object, object>>() ); repo.AddMapping<Person, PersonEditModel>() .From(s => 111) .To(t => t.Id); var mapper = repo.ResolveMapper<Person, PersonEditModel>(); var result = mapper.Map(source); result.ShouldNotBe(null); result.Id.ShouldBe(111); }