Esempio n. 1
0
        public void GetApplicableLinks_WithNotConfiguredType_ReturnEmptyList(Testee instance)
        {
            // arrange
            var notConfiguredType = instance.GetType();

            // act
            var hateoasLinks = _sut.GetApplicableLinks(notConfiguredType, instance);

            // assert
            Assert.IsType <List <IHateoasLink> >(hateoasLinks);
            Assert.Empty(hateoasLinks);
        }
Esempio n. 2
0
        /// <summary>
        ///   Builds the <see cref="Resource.Links" /> collection for created <see cref="Resource" />.
        /// </summary>
        /// <param name="resource">Original value wrapped in a <see cref="Resource" /> instance.</param>
        /// <param name="value">Original value of the configured type.</param>
        /// <param name="type">
        ///   type parameter of <see cref="IHateoasLink{T}" /> configuration to builds the <see cref="Resource.Links" />.
        /// </param>
        internal void BuildResourceLinks(Resource resource, object value, Type type)
        {
            foreach (var hateoasLink in _hateoasConfiguration.GetApplicableLinks(type, value))
            {
                var createdLink =
                    _resourceLinkFactory.Create(hateoasLink.RouteName, hateoasLink.GetRouteDictionary(value));

                resource.Links.Add(createdLink);
            }
        }