Esempio n. 1
0
        public async void CorrectlyMapsTransferAlertToDisplayAlert(
            bool hasCaseManager,
            bool hasTbService,
            string expectedCaseManagerName,
            string expectedTbServiceName,
            string expectedTbServiceCode)
        {
            // Arrange
            var notification = await GivenNotificationWithCaseManagerAndTbService
                                   (hasCaseManager?_caseManager : null, hasTbService?_tbService : null);

            await _context.Alert.AddAsync(new TransferAlert()
            {
                CaseManagerId  = notification.HospitalDetails.CaseManagerId,
                TbServiceCode  = notification.HospitalDetails.TBServiceCode,
                CreationDate   = new DateTime(2004, 2, 2),
                NotificationId = notification.NotificationId,
                AlertType      = AlertType.TransferRequest
            });

            _context.SaveChanges();

            // Act
            var result = (await _alertRepo.GetOpenAlertsForNotificationAsync(notification.NotificationId)).Single();

            // Assert
            Assert.Equal(expectedCaseManagerName, result.CaseManagerName);
            Assert.Equal(expectedTbServiceCode, result.TbServiceCode);
            Assert.Equal(expectedTbServiceName, result.TbServiceName);
            Assert.Equal(new DateTime(2004, 2, 2), result.CreationDate);
            Assert.Equal(notification.NotificationId, result.NotificationId);
            Assert.Equal(AlertType.TransferRequest, result.AlertType);
        }
Esempio n. 2
0
        public static void SetPostcodeForNotification(NtbsContext context, int notificationId, string code)
        {
            var notification = context.Notification.Find(notificationId);

            notification.PatientDetails.PostcodeToLookup = code;
            context.SaveChanges();
        }
Esempio n. 3
0
        public static void SeedDatabase(NtbsContext context)
        {
            // General purpose entities shared between tests
            context.Notification.AddRange(GetSeedingNotifications());
            context.PostcodeLookup.AddRange(GetTestPostcodeLookups());
            context.NotificationGroup.AddRange(GetTestNotificationGroups());
            context.User.AddRange(GetCaseManagers());
            context.CaseManagerTbService.AddRange(GetCaseManagerTbServicesJoinEntries());
            context.Alert.AddRange(GetSeedingAlerts());

            // Entities required for specific test suites
            context.Notification.AddRange(OverviewPageTests.GetSeedingNotifications());
            context.Notification.AddRange(DenotifyPageTests.GetSeedingNotifications());
            context.Notification.AddRange(DeletePageTests.GetSeedingNotifications());
            context.Notification.AddRange(PatientPageTests.GetSeedingNotifications());
            context.Notification.AddRange(HospitalDetailsPageTests.GetSeedingNotifications());
            context.Notification.AddRange(ManualTestResultEditPagesTests.GetSeedingNotifications());
            context.Notification.AddRange(SocialContextVenueEditPageTests.GetSeedingNotifications());
            context.Notification.AddRange(SocialContextAddressEditPageTests.GetSeedingNotifications());
            context.Notification.AddRange(TreatmentEventEditPageTests.GetSeedingNotifications());
            context.Notification.AddRange(ClinicalDetailsPageTests.GetSeedingNotifications());
            context.Notification.AddRange(ActionTransferPageTests.GetSeedingNotifications());
            context.Notification.AddRange(LabResultsPageTests.GetSeedingNotifications());
            context.Notification.AddRange(MBovisExposureToKnownCasesPageTests.GetSeedingNotifications());
            context.Notification.AddRange(MBovisUnpasteurisedMilkConsumptionPageTests.GetSeedingNotifications());
            context.Notification.AddRange(MBovisOccupationExposurePageTests.GetSeedingNotifications());
            context.Notification.AddRange(MBovisAnimalExposurePageTests.GetSeedingNotifications());
            context.Notification.AddRange(DraftEditPageTests.GetSeedingNotifications());

            context.TreatmentOutcome.AddRange(TreatmentEventEditPageTests.GetSeedingOutcomes());

            context.Alert.AddRange(DraftEditPageTests.GetSeedingAlerts());

            context.SaveChanges();
        }
Esempio n. 4
0
        public static void SetServiceCodeForNotification(NtbsContext context, int notificationId, string code)
        {
            var notification = context.Notification.Find(notificationId);

            notification.HospitalDetails.TBServiceCode = code;
            context.SaveChanges();
        }
Esempio n. 5
0
        public static void SeedDatabase(NtbsContext context)
        {
            // General purpose entities shared between tests
            context.Notification.AddRange(GetSeedingNotifications());

            context.SaveChanges();
        }
Esempio n. 6
0
        public UserRepositoryTests(RepositoryFixture <UserRepository> userRepositoryFixture)
        {
            ContextHelper.DisableAudits();
            _context        = userRepositoryFixture.Context;
            _contextOptions = userRepositoryFixture.ContextOptions;

            var optionsMonitor = new Mock <IOptionsMonitor <AdOptions> >();

            optionsMonitor.Setup(om => om.CurrentValue).Returns(new AdOptions {
                ReadOnlyUserGroup = "ReadOnly"
            });
            _userRepo = new UserRepository(_context, optionsMonitor.Object);

            var phec = new PHEC {
                Code = "E45000001", Name = "London"
            };

            _tbService1 = new TBService {
                Code = "TBS0001", IsLegacy = false, PHECCode = "E45000001"
            };
            _tbService2 = new TBService {
                Code = "TBS0002", IsLegacy = false, PHECCode = "E45000001"
            };
            _context.PHEC.Add(phec);
            _context.TbService.AddRange(_tbService1, _tbService2);
            _context.SaveChanges();
        }
Esempio n. 7
0
 public void Dispose()
 {
     _context.TbService.RemoveRange(_context.TbService);
     _context.PHEC.RemoveRange(_context.PHEC);
     _context.User.RemoveRange(_context.User);
     _context.SaveChanges();
 }
 private NtbsContext SetupTestDatabase(NtbsContext context)
 {
     context.Notification.AddRange(new List <Notification>
     {
         new Notification
         {
             NotificationId   = 1,
             ETSID            = "12",
             LTBRID           = "222",
             LTBRPatientId    = "22",
             NotificationDate = new DateTime(2000, 1, 1),
             PatientDetails   =
                 new PatientDetails
             {
                 FamilyName       = "Merry",
                 GivenName        = "Christmas",
                 NhsNumber        = "1234567890",
                 SexId            = 1,
                 CountryId        = 1,
                 Dob              = new DateTime(1990, 1, 1),
                 PostcodeToLookup = "SW12RT"
             },
             HospitalDetails = new HospitalDetails {
                 TBServiceCode = "Ashford hospital"
             },
             DrugResistanceProfile = new DrugResistanceProfile {
                 Species = string.Empty, DrugResistanceProfileString = string.Empty
             }
         },
         new Notification
         {
             NotificationId   = 2,
             ETSID            = "13",
             LTBRID           = "223",
             LTBRPatientId    = "23",
             NotificationDate = new DateTime(2001, 1, 1),
             PatientDetails   =
                 new PatientDetails
             {
                 FamilyName       = "Merry",
                 GivenName        = "Goround",
                 NhsNumber        = "1234567891",
                 SexId            = 2,
                 CountryId        = 2,
                 Dob              = new DateTime(1991, 1, 1),
                 PostcodeToLookup = "SW294FB"
             },
             HospitalDetails = new HospitalDetails {
                 TBServiceCode = "Not Ashford"
             },
             DrugResistanceProfile = new DrugResistanceProfile {
                 Species = string.Empty, DrugResistanceProfileString = string.Empty
             }
         }
     });
     context.SaveChanges();
     return(context);
 }
 private void GivenHospitalIdHasTbServiceCode(Guid hospitalId, string tbServiceCode)
 {
     _context.Hospital.Add(new Hospital {
         TBServiceCode = tbServiceCode, HospitalId = hospitalId
     });
     _context.TbService.Add(new TBService {
         Code = tbServiceCode
     });
     _context.SaveChanges();
 }
        private void SaveNotificationInDatabase(Notification notification)
        {
            var options = new DbContextOptionsBuilder <NtbsContext>();

            options.UseSqlServer(Settings.EnvironmentConfig.ConnectionString);
            using (var context = new NtbsContext(options.Options))
            {
                context.Add(notification);
                context.SaveChanges();
            }
            TestContext.AddedNotificationIds.Add(notification.NotificationId);
        }
Esempio n. 11
0
        public static void SeedDatabase(NtbsContext context)
        {
            // Reference data
            context.PHEC.AddRange(ReferenceDataSeedingHelper.GetPHECList());
            context.TbService.AddRange(ReferenceDataSeedingHelper.GetTBServices());
            context.Hospital.AddRange(ReferenceDataSeedingHelper.GetHospitalsList());
            context.LocalAuthority.AddRange(ReferenceDataSeedingHelper.GetLocalAuthorities());
            context.LocalAuthorityToPhec.AddRange(ReferenceDataSeedingHelper.GetLAtoPHECs());
            context.PostcodeLookup.AddRange(ReferenceDataSeedingHelper.GetPostcodeLookups());

            // General purpose entities shared between tests
            context.User.AddRange(GetCaseManagers());
            context.Notification.AddRange(GetSeedingNotifications());
            context.NotificationGroup.AddRange(GetTestNotificationGroups());
            context.CaseManagerTbService.AddRange(GetCaseManagerTbServicesJoinEntries());
            context.Alert.AddRange(GetSeedingAlerts());
            context.ReleaseVersion.Add(new ReleaseVersion {
                Version = "test-version", Date = DateTime.UtcNow
            });

            // Entities required for specific test suites
            context.Notification.AddRange(OverviewPageTests.GetSeedingNotifications());
            context.Notification.AddRange(DenotifyPageTests.GetSeedingNotifications());
            context.Notification.AddRange(DeletePageTests.GetSeedingNotifications());
            context.Notification.AddRange(PatientPageTests.GetSeedingNotifications());
            context.Notification.AddRange(HospitalDetailsPageTests.GetSeedingNotifications());
            context.Notification.AddRange(TransferPageTests.GetSeedingNotifications());
            context.Notification.AddRange(ManualTestResultEditPagesTests.GetSeedingNotifications());
            context.Notification.AddRange(SocialContextVenueEditPageTests.GetSeedingNotifications());
            context.Notification.AddRange(SocialContextAddressEditPageTests.GetSeedingNotifications());
            context.Notification.AddRange(TreatmentEventEditPageTests.GetSeedingNotifications());
            context.Notification.AddRange(ClinicalDetailsPageTests.GetSeedingNotifications());
            context.Notification.AddRange(ActionTransferPageTests.GetSeedingNotifications());
            context.Notification.AddRange(LabResultsPageTests.GetSeedingNotifications());
            context.Notification.AddRange(MBovisExposureToKnownCasesPageTests.GetSeedingNotifications());
            context.Notification.AddRange(MBovisUnpasteurisedMilkConsumptionPageTests.GetSeedingNotifications());
            context.Notification.AddRange(MBovisOccupationExposurePageTests.GetSeedingNotifications());
            context.Notification.AddRange(MBovisAnimalExposurePageTests.GetSeedingNotifications());
            context.Notification.AddRange(DraftEditPageTests.GetSeedingNotifications());

            context.TreatmentOutcome.AddRange(TreatmentEventEditPageTests.GetSeedingOutcomes());

            context.Alert.AddRange(DraftEditPageTests.GetSeedingAlerts());

            context.SaveChanges();
        }
Esempio n. 12
0
 private void GivenUserExistsInNtbs(User user)
 {
     _context.User.Add(user);
     _context.SaveChanges();
 }