Ejemplo n.º 1
0
        private SVP.CIL.Domain.Workspace WorkspaceCreate(AppDbContext dbc, SVP.CIL.Domain.Workspace target)
        {
            var workspace = Mapper.Map <Workspace>(target);
            var repo      = new WorkspaceRepository(dbc);

            repo.Add(workspace);
            dbc.SaveChanges();
            var domainWorkspace = Mapper.Map <SVP.CIL.Domain.Workspace>(workspace);

            return(domainWorkspace);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// InMemoryデータベース用のユニットテストデータを作成する
        /// </summary>
        void ImportInitializeData(int threadId, SimpleInjector.Container container)
        {
            var @dbc = (AppDbContext)container.GetInstance <IAppDbContext>();

            // Category
            var repo_Category = new CategoryRepository(@dbc);

            repo_Category.Add(new Category
            {
                Id   = 2,
                Name = "テストカテゴリA"
            });
            repo_Category.Add(new Category
            {
                Id   = 3,
                Name = "テストカテゴリA2"
            });
            repo_Category.Add(new Category
            {
                Id   = 4,
                Name = "テストカテゴリA3"
            });

            // Label
            var repo_Label = new LabelRepository(@dbc);

            repo_Label.Add(new Label
            {
                Id   = 1,
                Name = "テストラベル"
            });
            repo_Label.Add(new Label
            {
                Id       = 2,
                Name     = "テストラベル_2",
                Category = (Category)repo_Category.Load(1)
            });

            // Content
            var repo_Content = new ContentRepository(@dbc);

            repo_Content.Add(new Content
            {
                Id          = 1,
                Name        = "Content1",
                IdentifyKey = "IDEN_Content1"
            });
            repo_Content.Add(new Content
            {
                Id          = 2,
                Name        = "Content2",
                IdentifyKey = "IDEN_Content2",
            });
            repo_Content.Add(new Content
            {
                Id          = 3,
                Name        = "Content3",
                IdentifyKey = "IDEN_Content3"
            });

            // Workspace
            var repo_Workspace = new WorkspaceRepository(@dbc);
            var workspace1     = new Workspace
            {
                Id           = 1,
                Name         = "UT_Workspace",
                PhysicalPath = Path.Combine(TESTDATADIRECTORY, "PixstockSrvUT_" + threadId)
            };

            repo_Workspace.Add(workspace1);

            // FileMappingInfo
            var repo_FileMappingInfo = new FileMappingInfoRepository(@dbc);

            repo_FileMappingInfo.Add(new FileMappingInfo
            {
                Id        = 1,
                AclHash   = "ABC1",
                Workspace = workspace1
            });

            @dbc.SaveChanges();

            var label2 = repo_Label.Load(2L);

            label2.Contents.Add(new Label2Content
            {
                ContentId = 1L,
                Content   = (Content)repo_Content.Load(1L),
                LabelId   = 2L,
                Label     = label2
            });

            @dbc.SaveChanges();
        }