コード例 #1
0
        private (Project, Action) CreateAction(PreservationContext context, string projectName, bool closeProject)
        {
            var plantId = _plantProvider.Plant;
            var mode    = new Mode(plantId, "M1", false);

            context.Modes.Add(mode);

            var responsible = new Responsible(plantId, "Resp1", "Resp1-Desc");

            context.Responsibles.Add(responsible);
            context.SaveChangesAsync().Wait();

            var journey = new Journey(plantId, "J1");
            var step    = new Step(plantId, "S1", mode, responsible);

            journey.AddStep(step);
            context.Journeys.Add(journey);
            context.SaveChangesAsync().Wait();

            var requirementType = new RequirementType(plantId, "RT", "RT title", RequirementTypeIcon.Other, 1);

            context.RequirementTypes.Add(requirementType);

            var requirementDefinition = new RequirementDefinition(plantId, "RD", 2, RequirementUsage.ForAll, 1);

            requirementType.AddRequirementDefinition(requirementDefinition);
            context.SaveChangesAsync().Wait();

            var project = new Project(plantId, projectName, $"{projectName} Desc")
            {
                IsClosed = closeProject
            };

            context.Projects.Add(project);

            var tag = new Tag(
                plantId,
                TagType.Standard,
                "Tag A",
                "Tag desc",
                step,
                new List <TagRequirement> {
                new TagRequirement(plantId, 2, requirementDefinition)
            });

            project.AddTag(tag);
            context.SaveChangesAsync().Wait();

            var action = new Action(plantId, "A", "D", null);

            tag.AddAction(action);

            var attachment = new ActionAttachment(plantId, Guid.Empty, "fil.txt");

            action.AddAttachment(attachment);

            context.SaveChangesAsync().Wait();
            return(project, action);
        }
        private static Action SeedAction(PreservationContext dbContext, Tag tag)
        {
            var suffix = Guid.NewGuid().ToString().Substring(3, 8);
            var title  = $"{KnownTestData.Action}-{suffix}";
            var action = new Action(tag.Plant, title, $"{title}-Desc", new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc));

            tag.AddAction(action);
            dbContext.SaveChangesAsync().Wait();
            return(action);
        }