Exemplo n.º 1
0
        public void ReturnUriWhenResourceDtoIsFound()
        {
            var list = new List <ResourceDto>
            {
                new ResourceDto {
                    Key = "foo", Value = "http://foo"
                },
                new ResourceDto {
                    Key = "bar", Value = "http://bar"
                }
            };

            var restClientMock = new Mock <IRestClient>();

            restClientMock.Setup(x => x.GetResources(It.IsAny <string>())).Returns(list);

            var configurationMock = new Mock <IConfiguration>();

            configurationMock.Setup(x => x.Get(It.IsAny <string>())).Returns("bar");

            var urlServices = new UrlServices(restClientMock.Object, configurationMock.Object);

            var uri = urlServices.GetServiceUri("foo");

            Assert.That(uri.ToString(), Is.EqualTo("http://foo/"));
        }
Exemplo n.º 2
0
        public void ReturnNullWhenPartitionConfigurationIsNull()
        {
            var configurationMock = new Mock <IConfiguration>();

            var urlServices = new UrlServices(null, configurationMock.Object);

            Assert.That(urlServices.GetServiceUri("foo"), Is.Null);
        }
Exemplo n.º 3
0
        public void ReturnNullWhenNoResourceDtoIsFound()
        {
            var restClientMock = new Mock <IRestClient>();

            restClientMock.Setup(x => x.GetResources(It.IsAny <string>())).Returns(() => null);

            var configurationMock = new Mock <IConfiguration>();

            configurationMock.Setup(x => x.Get(It.IsAny <string>())).Returns("bar");

            var urlServices = new UrlServices(restClientMock.Object, configurationMock.Object);

            Assert.That(urlServices.GetServiceUri("foo"), Is.Null);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Sets AssetReference.Object, and updates loadedAssetByUrl collection.
        /// </summary>
        internal void SetAssetObject(AssetReference assetReference, object obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }

            if (assetReference.Object != null)
            {
                if (assetReference.Object != obj)
                {
                    throw new InvalidOperationException("SetAssetObject has already been called with a different object");
                }

                return;
            }

            var objectId = assetReference.ObjectId;

            assetReference.Object = obj;

            lock (loadedAssetsByUrl)
            {
                AssetReference previousAssetReference;

                if (loadedAssetsByUrl.TryGetValue(objectId, out previousAssetReference))
                {
                    assetReference.Next = previousAssetReference.Next;
                    assetReference.Prev = previousAssetReference;

                    if (previousAssetReference.Next != null)
                    {
                        previousAssetReference.Next.Prev = assetReference;
                    }
                    previousAssetReference.Next = assetReference;
                }
                else
                {
                    loadedAssetsByUrl[objectId] = assetReference;
                }

                loadedAssetsUrl[obj] = assetReference;

                // TODO: Currently here so that ContentReference.ObjectValue later keeps its Url.
                // Need some reorganization?
                UrlServices.SetUrl(obj, assetReference.Url);
            }
        }
Exemplo n.º 5
0
        public void GetLegalPartySearchUri()
        {
            var configuration = new Dev1Configuration();

            var securityTokenServiceProxy = new Mock <ISecurityTokenServiceProxy>();

            securityTokenServiceProxy.Setup(x => x.GetAccessToken()).Returns("HELLO");

            var httpClientProxy = new HttpClientProxy(securityTokenServiceProxy.Object);

            var urlService = new UrlServices(new RestClient(configuration, httpClientProxy), configuration);

            var uri = urlService.GetServiceUri("service.legalpartysearch");

            Assert.That(uri.ToString(), Is.EqualTo("http://c592xfglumwb1.ecomqc.tlrg.com/service.legalpartysearch"));
        }
 public async Task <IActionResult> Create(CategoryViewModel cvm)
 {
     if (ModelState.IsValid)
     {
         Category newCategory = new Category
         {
             CategoryId   = cvm.CategoryId,
             CategoryName = cvm.CategoryName,
             Slug         = UrlServices.URLFriendly(cvm.Slug)
         };
         _categoryRepository.CreateCategory(newCategory);
         if (await _categoryRepository.SaveChangesAsync())
         {
             return(RedirectToAction(nameof(Index)));
         }
     }
     return(View());
 }
Exemplo n.º 7
0
 public async Task <IActionResult> Create(CreatePostModel cpm)
 {
     if (ModelState.IsValid)
     {
         Post newPost = new Post
         {
             CategoryId = cpm.CategoryId,
             Title      = cpm.Title,
             Content    = cpm.Content,
             PhotoPath  = await _file.SaveImages(cpm.PhotoPath),
             Slug       = UrlServices.URLFriendly(cpm.Slug),
             AddTime    = DateTime.Now,
             EditTime   = DateTime.Now
         };
         _postRepository.CreatePost(newPost);
         if (await _postRepository.SaveChangesAsync())
         {
             return(RedirectToAction("Index"));
         }
     }
     //Dropddown'da category name cagırmak için category ıd cagırılacak
     ViewBag.CategoryId = new SelectList(_categoryRepository.AllCategories.OrderBy(x => x.CategoryName), "CategoryId", "CategoryName");
     return(View());
 }
Exemplo n.º 8
0
 public string ConvertToSlug(string title)
 {
     return(UrlServices.URLFriendly(title));
 }
Exemplo n.º 9
0
 public EmployeeRepository(IOptions <UrlServices> option)
 {
     urlServices = option.Value;
 }
Exemplo n.º 10
0
 private void SetupEndpoints(UrlServices endpoints)
 {
     ApiUrls.UserImagesEndpoint  = endpoints.UserImagesBaseUrl;
     ApiUrls.StoreImagesEndpoint = endpoints.StoreImagesBaseUrl;
 }