public void Constructing_WithNullResourceLoaderAndMapperFactoryProvided_ThrowsException()
        {
            IHalResponseLoader loader = null;
            var mapperFactory         = new Mock <IEntityMapperFactory>();

            Assert.Throws <ArgumentNullException>(() =>
            {
                new HalResource(loader, mapperFactory.Object);
            });
        }
        /// <summary>
        /// Instantiates a new instance of <see cref="HalResource"/> with a <see cref="IHalResponseLoader"/> provided
        /// to 'inject' the response data in a format that <see cref="HalResource"/> can understand.
        /// </summary>
        /// <param name="HalResourceLoader">
        /// The <see cref="IHalResponseLoader"/> responsible for 'injecting' data into the <see cref="HalResource"/>
        /// in a way that it understands it.
        /// </param>
        public HalResource(IHalResponseLoader HalResourceLoader)
        {
            Requires.NotNull(HalResourceLoader, nameof(HalResourceLoader));

            halResourceLoader = HalResourceLoader;

            Links         = new Dictionary <string, IEnumerable <Link> >();
            Properties    = new Dictionary <string, object>();
            EmbeddedItems = new Dictionary <string, IEnumerable <HalResource> >();
        }
        /// <summary>
        /// Instantiates a new instance of <see cref="HalResource"/> with an <see cref="IHalResponseLoader"/> provided
        /// to 'inject' the response data in a format that <see cref="HalResource"/> can understand and an
        /// <see cref="IEntityMapperFactory"/> that supplies data type mappers for casting the data contained within the
        /// <see cref="HalResource"/> to custom entity types.
        /// </summary>
        /// <param name="HalResourceLoader"></param>
        /// <param name="mapperFactory"></param>
        public HalResource(IHalResponseLoader HalResourceLoader, IEntityMapperFactory mapperFactory)
        {
            Requires.NotNull(HalResourceLoader, nameof(HalResourceLoader));
            Requires.NotNull(mapperFactory, nameof(mapperFactory));

            halResourceLoader  = HalResourceLoader;
            this.mapperFactory = mapperFactory;

            Links         = new Dictionary <string, IEnumerable <Link> >();
            Properties    = new Dictionary <string, object>();
            EmbeddedItems = new Dictionary <string, IEnumerable <HalResource> >();
        }
Example #4
0
 public RESTApi(IHalResponseLoader responseLoader, IEntityMapperFactory entityMapperFactory)
 {
     this.responseLoader      = responseLoader;
     this.entityMapperFactory = entityMapperFactory;
     this.entityMapperFactory.RegisterMappers();
 }