private TestFactory()
        {
            KnownTestData = new KnownTestData();

            var projectDir = Directory.GetCurrentDirectory();

            _connectionString = GetTestDbConnectionString(projectDir);
            _configPath       = Path.Combine(projectDir, "appsettings.json");

            SetupTestUsers();
        }
Esempio n. 2
0
        public static void Seed(this IPOContext dbContext, IServiceProvider serviceProvider, KnownTestData knownTestData)
        {
            var userProvider  = serviceProvider.GetRequiredService <CurrentUserProvider>();
            var plantProvider = serviceProvider.GetRequiredService <PlantProvider>();

            userProvider.SetCurrentUserOid(new Guid(_seederOid));
            plantProvider.SetPlant(KnownTestData.Plant);

            /*
             * Add the initial seeder user. Don't do this through the UnitOfWork as this expects/requires the current user to exist in the database.
             * This is the first user that is added to the database and will not get "Created" and "CreatedBy" data.
             */
            SeedCurrentUserAsPerson(dbContext, userProvider);

            var plant = plantProvider.Plant;

            var mdpInvitation = SeedMdpInvitation(dbContext, plant);

            knownTestData.MdpInvitationIds.Add(mdpInvitation.Id);

            var comment = SeedComment(dbContext, mdpInvitation);

            knownTestData.CommentIds.Add(comment.Id);

            SeedContractor(dbContext, mdpInvitation);
            SeedConstructionCompany(dbContext, mdpInvitation);

            var dpInvitation = SeedDpInvitation(dbContext, plant);

            knownTestData.DpInvitationIds.Add(dpInvitation.Id);

            SeedContractor(dbContext, dpInvitation);
            SeedConstructionCompany(dbContext, dpInvitation);
        }