public async Task When_GenerateSource_Return_Bool_ThrowExceptionAsync() { try { SourceDomainService sourceDomainService = new Service.SourceDomainService(_sourceRepositoryMock.Object); List <SourceEntity> expectedSource = new List <SourceEntity>(); SourceDto sourceDto = new SourceDto { SourceID = 4, SourceName = "Press Trust of India", SourceURL = "https://www.presstrustofindia.com", RegistrationDate = DateTime.Now, SourceType = SourceType.External, IsActive = true }; SourceEntity source = new SourceEntity(sourceDto); expectedSource.Add(source); _sourceRepositoryMock.Setup(c => c.GetSourceAsync(source)).ReturnsAsync(expectedSource); //Act bool actualSourceList = await sourceDomainService.RegistrationAsync(sourceDto); //Assert. Assert.Equals(true, actualSourceList); } catch (Exception) { Assert.Fail(); throw; } }
public async Task <IActionResult> Get() { SourceDto sourceDto = new SourceDto(); var list = await _sourceDomainService.GetSoruceAsync(sourceDto); return(Ok(list)); }
public async Task <IActionResult> Post([FromBody] SourceDto sourceDto = null) { sourceDto.UserId = _fakeUser; var source = await _sourceDomainService.RegistrationAsync(sourceDto); return(Ok(source)); }
public InternalSourceEntity(SourceDto sourceDto) { SourceID = sourceDto.SourceID; SourceName = sourceDto.SourceName; SourceType = sourceDto.SourceType; RegistrationDate = sourceDto.RegistrationDate; }
public ActionResult <SourceDto> Update([FromBody] SourceDto sourceDto) { if (sourceDto == null) { return(new BadRequestResult()); } var source = _sourceService.Get(sourceDto.Id); if (source == null) { return(NotFound()); } var sourceType = _sourceTypeService.Get(sourceDto.SourceTypeId); if (sourceType == null) { return(NotFound()); } _mapper.Map(sourceDto, source); source.SourceType = sourceType; _sourceService.Update(source); return(NoContent()); }
public void InitForNew(ObservableCollection <SourceDto> mainCollection) { SourceDto = new SourceDto(); _mainCollection = mainCollection; DataContext = this; BorderFileTypes.IsEnabled = false; }
public void InitForNew(ObservableCollection <FileTypeDto> mainCollection, SourceDto parentSource) { _fileTypeDto = new FileTypeDto(); _fileTypeDto.SourceId = parentSource.Id; _mainCollection = mainCollection; DataContext = _fileTypeDto; }
//Non-Startup private void SourceAdded(SourceDto source) { Device.BeginInvokeOnMainThread(() => { this._profile.Sources.Add(SourceMapper.GetMcSourceFromDtoSource(source)); }); }
public void When_Get_Generated_Source_Return_List_OF_Source() { try { SourceDomainService sourceDomainService = new Service.SourceDomainService(_sourceRepositoryMock.Object); List <SourceEntity> expectedSource = new List <SourceEntity>(); SourceDto sourceDto = new SourceDto(); SourceEntity source = new SourceEntity(sourceDto); expectedSource.Add(source); _sourceRepositoryMock.Setup(c => c.GetSourceAsync(source)).ReturnsAsync(expectedSource); //Act Task <List <SourceEntity> > actualSourceList = sourceDomainService.GetSoruceAsync(sourceDto); if (actualSourceList != null) { //Assert. Assert.AreEqual(expectedSource.Count, actualSourceList.Result.Count); } } catch (Exception) { Assert.Fail(); throw; } }
public void Map_WithType_Success() { SourceDto source = CreateSource(); var target = TinyMapper.Map <Target>(source); Assert.Equal(target.Key, source.Id); }
public SourceDto UpdateSource(SourceDto sourceDto) { var source = _unitOfWork.Context.GetDbSet <Source>().FirstOrDefault(x => x.Id == sourceDto.Id); source = _mapper.Map <SourceDto, Source>(sourceDto); _unitOfWork.Context.SaveChanges(); return(_mapper.Map <SourceDto>(source)); }
internal void InitForEdit(SourceDto selectedSource, ObservableCollection <SourceDto> mainCollection) { SourceDto = selectedSource; _mainCollection = mainCollection; _originalRecordIndex = _mainCollection.IndexOf(SourceDto); DataContext = this; GetFileTypes(); }
//Non-Startup private void SourceAdded(SourceDto source) { var context = SynchronizationContext.Current; App.Current.Dispatcher.Invoke((Action) delegate { this._profile.Sources.Add(SourceMapper.GetDcSourceFromDtoSource(source)); }); }
public void Map_WithType_Success() { _tinyMapper.Bind <SourceDto, Target>(); SourceDto source = CreateSource(); var target = _tinyMapper.Map <Target>(source); XAssert.Equal(target.Key, source.Id); }
public async Task <bool> RegistrationAsync(SourceDto sourceDto) { //if (sourceDto.SourceType == SourceType.External) // SourceEntity _sourceRepository = new SourceEntity(sourceDto); //else // SourceEntity registerSourceEntity = new SourceEntity(sourceDto); SourceEntity sourceEntity = new SourceEntity(sourceDto); return(await _sourceRepository.RegistrationAsync(sourceEntity)); }
public SourceDto AddSource(SourceDto sourceDto) { var source = new Source(); source = _mapper.Map <SourceDto, Source>(sourceDto); source.ExternalId = sourceDto.SourceId; _unitOfWork.Context.GetDbSet <Source>().Add(source); _unitOfWork.Context.SaveChanges(); return(_mapper.Map <SourceDto>(source)); }
protected override void Because_of() { var source = new Source { Inner = new Inner { Member = SomeValue } }; //_dest = Mapper.Map<Source, SourceDto>(source); _dest = new[] { source }.AsQueryable().ProjectTo <SourceDto>(Configuration).First(); }
public ExernalSourceEntity(SourceDto sourceDto) { SourceID = sourceDto.SourceID; SourceName = sourceDto.SourceName; SourceType = sourceDto.SourceType; SourceURL = sourceDto.SourceURL; Country = sourceDto.Country; State = sourceDto.State; City = sourceDto.City; SourceType = sourceDto.SourceType; RegistrationDate = sourceDto.RegistrationDate; }
protected override void Because_of() { var source = new SourceDto() { Items = new GenericWrappedDictionary <string, string> { { "A", "AAA" }, { "B", "BBB" }, { "C", "CCC" } } }; _dest = Mapper.Map <System.Collections.Generic.IDictionary <string, string>, System.Collections.Generic.IDictionary <string, string> >(source.Items); }
public MergedEntity Post(SourceDto sourceDto) { using (var mutex = new Mutex(false, "matrix42")) { mutex.WaitOne(); try { var source = Mapper.Map <Source>(sourceDto); return(SourcesRepository.Add(source).Result); } finally { mutex.ReleaseMutex(); } } }
public ActionResult <SourceDto> Create([FromBody] SourceDto sourceDto) { if (sourceDto == null) { return(new BadRequestResult()); } var sourceType = _sourceTypeService.Get(sourceDto.SourceTypeId); if (sourceType == null) { return(NotFound()); } var source = _mapper.Map <Source>(sourceDto); source.SourceType = sourceType; var newSource = _sourceService.Create(source); return(Ok(_mapper.Map <SourceDto>(newSource))); }
public async Task <List <SourceEntity> > GetSoruceAsync(SourceDto sourceDto) { SourceEntity sourceEntity = new SourceEntity(sourceDto); return(await _sourceRepository.GetSourceAsync(sourceEntity)); }
public async Task <GrpcResponseWithData <GrpcList <AssetBalanceDto> > > GetBalancesAsync(SourceDto request) { var data = _externalBalanceCacheManager.GetBalances(request.Source); var result = data.Select(e => new AssetBalanceDto(e.Symbol, (double)e.Balance, (double)e.Free)).ToList(); return(GrpcResponseWithData <GrpcList <AssetBalanceDto> > .Create(GrpcList <AssetBalanceDto> .Create(result))); }
public async Task <GrpcResponseWithData <GrpcList <ExchangeMarketInfo> > > GetInstrumentsAsync(SourceDto request) { var data = _externalBalanceCacheManager.GetMarketInfo(request.Source); return(GrpcResponseWithData <GrpcList <ExchangeMarketInfo> > .Create(GrpcList <ExchangeMarketInfo> .Create(data))); }
public static UcSource GetUcSourceFromDtoSource(SourceDto dtoSource) { return(new UcSource(dtoSource.Name, dtoSource.DefaultWidth, dtoSource.DefaultHeight, dtoSource.HexColor, dtoSource.Id)); }
private SourceDto PopulateSourceInfo() { if (_connection == null) { throw new Exception($"Failed to popluate source info for {Id} as no connection exist"); } try { var source = new SourceDto(); using (var metaCmd = _connection.CreateCommand()) { metaCmd.CommandText = "select name, value from metadata"; using (var rdr = metaCmd.ExecuteReader()) { while (rdr.Read()) { switch (rdr.GetString(0)) { case "bounds": source.Bounds = rdr.GetString(1).Split(',').Select(Convert.ToDouble).ToArray(); break; case "center": var cen = rdr.GetString(1).Split(','); source.Center = new double[3]; source.Center[0] = Convert.ToDouble(cen[0]); source.Center[1] = Convert.ToDouble(cen[1]); source.Center[2] = Convert.ToInt16(cen[2]); break; case "maxzoom": source.MaxZoom = Convert.ToInt16(rdr.GetString(1)); break; case "minzoom": source.MinZoom = Convert.ToInt16(rdr.GetString(1)); break; case "name": source.Name = rdr.GetString(1); break; case "description": source.Description = rdr.GetString(1); break; case "version": source.Version = rdr.GetString(1); break; case "attribution": source.Attribution = rdr.GetString(1); break; case "format": source.Format = rdr.GetString(1); break; case "tilejson": source.TileJsonVersion = rdr.GetString(1); break; case "template": source.Template = rdr.GetString(1); break; case "scheme": source.Scheme = rdr.GetString(1); break; } } } source.TileJsonVersion = "2.0.0"; source.Scheme = source.Scheme ?? "xyz"; source.Type = source.Format == "pbf" ? "vector" : "raster"; source.Attribution = string.IsNullOrWhiteSpace(source.Attribution) ? "Served on GruntiMaps" : source.Attribution; // tiles url to be generated when user calls } return(source); } catch (Exception e) { throw new Exception($"Failed to populate source info for {Id}", e); } }
protected override void Because_of() { var source = new Source { Inner = new Inner { Member = SomeValue } }; //_dest = Mapper.Map<Source, SourceDto>(source); _dest = new[] { source }.AsQueryable().ProjectTo<SourceDto>(Configuration).First(); }
//Non-Startup private void SourceAdded(SourceDto source) { this._unityMainThreadDispatcher.Enqueue(() => { this._profile.Sources.Add(SourceMapper.GetUcSourceFromDtoSource(source)); }); }