Exemplo n.º 1
0
        public void ConvertDataContainerToGpx_ShouldConvertToGpx()
        {
            var dataContainer = new DataContainer();

            var results = _converterService.ToAnyFormat(dataContainer, FlowFormats.GPX).Result.ToGpx();

            Assert.IsFalse(results.Waypoints.Any());
            Assert.IsFalse(results.Routes.Any());
            Assert.IsFalse(results.Tracks.Any());
        }
Exemplo n.º 2
0
        public void ConvertDataContainerToGpx_ShouldConvertToGpx()
        {
            var dataContainer = new DataContainer();

            var results = _converterService.ToAnyFormat(dataContainer, FlowFormats.GPX).Result.ToGpx();

            Assert.IsNull(results.wpt);
            Assert.IsNull(results.rte);
            Assert.IsNull(results.trk);
        }
Exemplo n.º 3
0
        private async Task <IActionResult> GetUrlAsFile(string id, string format, ShareUrl shareUrl)
        {
            var bytes = await _dataContainerConverterService.ToAnyFormat(shareUrl.DataContainer, format);

            var restuls = new FileContentResult(bytes, new MediaTypeHeaderValue($"application/{format}"))
            {
                FileDownloadName = id + "." + format
            };

            return(restuls);
        }
Exemplo n.º 4
0
        public void GetSiteUrl_ItemInDatabase_ShouldReturnItAccordingToFromat()
        {
            var id    = "someId";
            var bytes = new byte[] { 1 };

            _israelHikingRepository.GetUrlById(id).Returns(new SiteUrl {
                Id = id, JsonData = JsonConvert.SerializeObject(new DataContainer())
            });
            _containerConverterService.ToAnyFormat(Arg.Any <DataContainer>(), "gpx").Returns(bytes);

            var results = _controller.GetSiteUrl(id, "gpx").Result as FileContentResult;

            Assert.IsNotNull(results);
            var content = results.FileContents;

            Assert.IsNotNull(content);
            Assert.AreEqual(bytes.Length, content.Length);
        }
Exemplo n.º 5
0
 // POST api/files?format=gpx
 public Task <byte[]> PostSaveFile(string format, [FromBody] DataContainer dataContainer)
 {
     return(_dataContainerConverterService.ToAnyFormat(dataContainer, format));
 }