Ejemplo n.º 1
0
 public virtual void BaseOneTimeSetUp()
 {
     Config     = TestConfigBuilder.BuildTestConfig();
     Context    = ContextLoader.GetDbContext(Config, EnableRetryOnFailure);
     TestConfig = new TestConfigReader(Config);
     Context.Database.EnsureDeleted();
     Context.Database.EnsureCreated();
     MockClock = new Mock <IClock>();
     MockClock.SetupGet(c => c.UtcNow).Returns(() => MockTime);
     OneTimeSetup();
 }
Ejemplo n.º 2
0
        public void TestGetInstitutionEnrichmentWithDifferentUserFromSavedUser()
        {
            Context = ContextLoader.GetDbContext(Config);//refresh the context

            var enrichmentService = new EnrichmentService(Context);
            //test get the enrichment using user2
            var result = enrichmentService.GetProviderEnrichment(ProviderInstCode, Email2);

            result.Should().NotBeNull();
            result.EnrichmentModel.Should().NotBeNull();
            result.EnrichmentModel.TrainWithDisability.Should().BeEquivalentTo(TrainWithDisabilityText);
            result.EnrichmentModel.TrainWithUs.Should().BeEquivalentTo(TrainWithUsText);
            result.LastPublishedTimestampUtc.Should().BeNull();
            result.Status.Should().BeEquivalentTo(EnumStatus.Draft);
        }
        private void SetupSmokeTestData()
        {
            // don't use the retrying context because the migrator hasn't been updated to use the retry strategy
            var migratorContext = ContextLoader.GetDbContext(Config, false);

            // Not using CurrentRecruitmentCycle from base class because it doesn't share this context
            var currentRecruitmentCycle = migratorContext
                                          .RecruitmentCycles
                                          .Single(rc => rc.Year == RecruitmentCycle.CurrentYear);

            migratorContext.AddTestReferenceData(TestConfig.SignInUsername, currentRecruitmentCycle);
            migratorContext.Save();

            var ucasDataMigrator = new UcasDataMigrator(migratorContext,
                                                        new Mock <Serilog.ILogger>().Object,
                                                        TestPayloadBuilder.MakeSimpleUcasPayload(),
                                                        null,
                                                        currentRecruitmentCycle);

            ucasDataMigrator.UpdateUcasData();
        }
Ejemplo n.º 4
0
        public void BaseSetup()
        {
            // get a fresh context every time to avoid stale in-memory data contaminating subsequent tests
            Context = ContextLoader.GetDbContext(Config, EnableRetryOnFailure);
            // Truncate (delete all data from) all tables, following FK constraints by virtue of CASCADE
            // https://stackoverflow.com/questions/2829158/truncating-all-tables-in-a-postgres-database/12082038#12082038
            Context.Database.ExecuteSqlCommandAsync(@"
                DO
                $func$
                BEGIN
                   EXECUTE
                   (SELECT 'TRUNCATE TABLE ' || string_agg(oid::regclass::text, ', ') || ' CASCADE'
                    FROM   pg_class
                    WHERE  relkind = 'r'  -- only tables
                    AND    relnamespace = 'public'::regnamespace
                   );
                END
                $func$;").Wait();

            // reset clock
            MockTime = new DateTime(1977, 1, 2, 3, 4, 5, 7);

            Context.RecruitmentCycles.AddRange(
                new List <RecruitmentCycle>
            {
                new RecruitmentCycle {
                    Year = RecruitmentCycle.CurrentYear
                },
                new RecruitmentCycle {
                    Year = "2020"
                },
            });
            Context.SaveChanges();

            // allow derived tests to do their own setup
            Setup();
        }