Exemplo n.º 1
0
        public void ModelToEntity_FileContent_IsNotInstantiatedNew()
        {
            // ARRANGE
            var source = new EntryModel
            {
                Type        = EntryType.File,
                FileContent = new EntryFileContentModel
                {
                    FileType = FileEntryType.Image,
                },
            };

            var entryFileContent = new EntryFileContent
            {
                FileType = FileEntryType.Generic,
            };
            var dest = new Entry
            {
                FileContent = entryFileContent,
            };

            // ACT
            var mapperConfig = new MapperConfiguration(
                cfg => {
                MainObjectMapper.Configure(cfg);
            });
            IMapper mapper = mapperConfig.CreateMapper();

            mapper.Map(source, dest);

            // ASSERT
            dest.FileContent.Should().BeSameAs(entryFileContent);
            dest.FileContent.FileType.ShouldBeEquivalentTo(source.FileContent.FileType);
        }
Exemplo n.º 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public virtual void ConfigureServices(IServiceCollection services)
        {
            var mapperConfig = new MapperConfiguration(
                cfg =>
            {
                MainObjectMapper.Configure(cfg);
                ApiObjectMapper.Configure(cfg);
            });
            IMapper mapper = mapperConfig.CreateMapper();

            services
            .AddSingleton(mapper)

            .AddMvc();

            DiaryCore.Init(services);
        }
Exemplo n.º 3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            DiaryCore.Init(services);

            var mapperConfig = new MapperConfiguration(
                cfg =>
            {
                MainObjectMapper.Configure(cfg);
                ApiObjectMapper.Configure(cfg);
            });
            IMapper mapper = mapperConfig.CreateMapper();

            services
            .AddSingleton(mapper)
            .AddMvc()
            .AddViewLocalization()
            .AddApplicationPart(typeof(Api.Startup).GetTypeInfo().Assembly)
            .AddControllersAsServices();
        }