Пример #1
0
        public async Task GetAll_All_EvacueePropertiesAreMapped()
        {
            var fromCommunity = await GetRandomSeededCommunity();

            var toCommunity = await GetRandomSeededCommunity();

            var incidentTaskId = await SeedIncident(fromCommunity.Id);

            var registrationId = await di.CreateEvacueeRegistrationAsync(RegistrationGenerator.GenerateCompleted(incidentTaskId, toCommunity.Id));

            var registration = await di.GetEvacueeRegistrationAsync(registrationId);

            var result = await di.GetEvacueesPaginatedAsync(new EvacueeSearchQueryParameters());

            Assert.Equal(registration.HeadOfHousehold.FamilyMembers.Count(), result.Items.Count(e => !e.IsHeadOfHousehold));
            Assert.Equal(1, result.Items.Count(e => e.IsHeadOfHousehold));
            Assert.All(result.Items, e =>
            {
                Assert.Equal(registration.IncidentTask.TaskNumber, e.IncidentTaskNumber);
                Assert.Equal(registration.Id, e.RegistrationId);
                Assert.Equal(registration.RestrictedAccess, e.RestrictedAccess);
                Assert.Equal(registration.RegistrationCompletionDate, e.RegistrationCompletionDate);
                Assert.Equal(registration.IncidentTask.Community.Name, e.EvacuatedFrom);
                Assert.Equal(registration.HostCommunity.Name, e.EvacuatedTo);
                Assert.True(e.IsFinalized);
                Assert.False(e.HasReferrals);
            });
        }
        public async Task CanGetReferralHtmlPages(Gov.Jag.Embc.Public.ViewModels.Referral referral)
        {
            var ctx        = EmbcDb;
            var di         = new DataInterface(ctx, Mapper);
            var pdfService = new PdfConverter();
            var service    = new ReferralsService(di, pdfService);

            var incidentTask = await di.CreateIncidentTaskAsync(IncidentTaskGenerator.Generate());

            var regVM = RegistrationGenerator.GenerateSelf();

            regVM.IncidentTask = incidentTask;

            var registrationId = await di.CreateEvacueeRegistrationAsync(regVM);

            referral.EssNumber = registrationId;

            var referralIds = new List <string>();
            var id          = await di.CreateReferralAsync(referral);

            referralIds.Add(id);

            var printReferrals = new ReferralsToPrint {
                ReferralIds = referralIds, AddSummary = true
            };

            var content = await service.GetReferralHtmlPagesAsync(printReferrals);

            Assert.False(string.IsNullOrEmpty(content));
        }
Пример #3
0
        public async Task CanQueryReferralsByStatus()
        {
            var ctx = EmbcDb;

            var di = new DataInterface(ctx, Mapper);

            var registrationId = await di.CreateEvacueeRegistrationAsync(RegistrationGenerator.GenerateSelf());

            var referral1   = ReferralGenerator.Generate(ReferralType.Clothing, registrationId);
            var referral2   = ReferralGenerator.Generate(ReferralType.Clothing, registrationId);
            var referralId1 = await di.CreateReferralAsync(referral1);

            var referralId2 = await di.CreateReferralAsync(referral1);

            await di.DeactivateReferralAsync(referralId2);

            var activeReferrals = await di.GetReferralsAsync(registrationId, new SearchQueryParameters { Active = true });

            var inactiveReferrals = await di.GetReferralsAsync(registrationId, new SearchQueryParameters { Active = false });

            Assert.Single(activeReferrals.Items);
            Assert.True(activeReferrals.Items.First().Active);
            Assert.Single(activeReferrals.Items);
            Assert.False(inactiveReferrals.Items.First().Active);
        }
Пример #4
0
        public async Task CanGetReferralHtmlPages(Gov.Jag.Embc.Public.ViewModels.Referral referral)
        {
            var pdfService = new PdfConverter();
            var service    = new ReferralsService(di, pdfService, cus, null);

            var fromCommunity = await GetRandomSeededCommunity();

            var taskId = await SeedIncident(fromCommunity.Id);

            var regVM = RegistrationGenerator.GenerateSelf();

            regVM.IncidentTask = new Gov.Jag.Embc.Public.ViewModels.IncidentTask {
                Id = taskId
            };

            var registrationId = await di.CreateEvacueeRegistrationAsync(regVM);

            referral.EssNumber = registrationId;

            var referralIds = new List <string>();
            var id          = await di.CreateReferralAsync(referral);

            referralIds.Add(id);

            var printReferrals = new ReferralsToPrint {
                ReferralIds = referralIds, AddSummary = true
            };

            var content = await service.GetReferralHtmlPagesAsync(printReferrals);

            Assert.False(string.IsNullOrEmpty(content));
        }
Пример #5
0
        public async Task CanGetAllReferralsForRegistration()
        {
            var ctx = EmbcDb;

            var di = new DataInterface(ctx, Mapper);

            var registrationId = await di.CreateEvacueeRegistrationAsync(RegistrationGenerator.GenerateSelf());

            var referrals = new[] {
                ReferralGenerator.Generate(ReferralType.Incidentals, registrationId),
                ReferralGenerator.Generate(ReferralType.Clothing, registrationId),
                ReferralGenerator.Generate(ReferralType.Lodging_Group, registrationId),
                ReferralGenerator.Generate(ReferralType.Transportation_Taxi, registrationId),
                ReferralGenerator.Generate(ReferralType.Food_Restaurant, registrationId)
            };

            foreach (var referral in referrals)
            {
                await di.CreateReferralAsync(referral);
            }

            var result = (await di.GetReferralsAsync(registrationId, new SearchQueryParameters())).Items;

            Assert.NotEmpty(result);
            Assert.Equal(referrals.Length, result.Count());
            Assert.All(referrals, r => Assert.Equal(registrationId, r.EssNumber));
        }
Пример #6
0
        public async Task CanMapToPrintReferrals(Gov.Jag.Embc.Public.ViewModels.Referral referral)
        {
            var pdfService = new PdfConverter();
            var service    = new ReferralsService(di, pdfService, cus, null);

            var fromCommunity = await GetRandomSeededCommunity();

            var taskId = await SeedIncident(fromCommunity.Id);

            var regVM = RegistrationGenerator.GenerateSelf();

            regVM.IncidentTask = new Gov.Jag.Embc.Public.ViewModels.IncidentTask {
                Id = taskId
            };

            var registrationId = await di.CreateEvacueeRegistrationAsync(regVM);

            referral.EssNumber = registrationId;

            var referralId = await di.CreateReferralAsync(referral);

            var id = await di.CreateReferralAsync(referral);

            var result = await di.GetReferralsAsync(new string[] { id });

            Assert.NotNull(result);
            Assert.Equal("D0000001", result.First().IncidentTaskNumber);
            Assert.NotNull(result);
            Assert.Equal(referral.EssNumber, result.First().EssNumber);
            Assert.NotEmpty(result.First().Id);
            Assert.Equal(referral.Type + (referral.SubType != null ? $"_{referral.SubType}" : ""), result.First().Type);
            Assert.Null(result.First().SubType);
            Assert.Equal(referral.Purchaser, result.First().Purchaser);
            Assert.Equal(referral.TotalAmount, result.First().TotalAmount);
            Assert.Equal(referral.Supplier.Fax, result.First().Supplier.Fax);
            Assert.Equal(referral.ValidDates.From, result.First().ValidDates.From);
            Assert.Equal(referral.ValidDates.To, result.First().ValidDates.To);
            Assert.Equal(referral.ConfirmChecked, result.First().ConfirmChecked);
            Assert.All(result.First().Evacuees, e => referral.Evacuees.Any(re => re.Id == e.Id));
            Assert.Equal(referral.Evacuees.Count(), result.First().Evacuees.Count());
            Assert.NotNull(result.First().Supplier);
            Assert.Equal(referral.Supplier.Name, result.First().Supplier.Name);
            Assert.Equal(referral.Supplier.Address, result.First().Supplier.Address);
            Assert.Equal(referral.Supplier.City, result.First().Supplier.City);
            Assert.Equal(referral.Supplier.Province, result.First().Supplier.Province);
            Assert.Equal(referral.Supplier.Fax, result.First().Supplier.Fax);
            Assert.Equal(referral.Supplier.Telephone, result.First().Supplier.Telephone);
            Assert.Equal(referral.Supplier.Active, result.First().Supplier.Active);
            Assert.Equal(referral.ToAddress, result.First().ToAddress);
            Assert.Equal(referral.FromAddress, result.First().FromAddress);
            Assert.Equal(referral.OtherTransportModeDetails, result.First().OtherTransportModeDetails);
            Assert.Equal(referral.NumLunches, result.First().NumLunches);
            Assert.Equal(referral.NumBreakfasts, result.First().NumBreakfasts);
            Assert.Equal(referral.NumDaysMeals, result.First().NumDaysMeals);
            Assert.Equal(referral.NumDinners, result.First().NumDinners);
            Assert.Equal(referral.NumNights, result.First().NumNights);
            Assert.Equal(referral.ApprovedItems, result.First().ApprovedItems);
            Assert.Equal(referral.ExtremeWinterConditions, result.First().ExtremeWinterConditions);
        }
Пример #7
0
        protected async Task <string[]> SeedRegistrations(string taskId, string hostCommunity, int numberOfRegistrations)
        {
            var di = Services.ServiceProvider.GetService <IDataInterface>();

            var registrations = new List <string>();

            for (int i = 0; i < numberOfRegistrations; i++)
            {
                var registration = RegistrationGenerator.GenerateCompleted(taskId, hostCommunity);
                registrations.Add(await di.CreateEvacueeRegistrationAsync(registration));
            }

            return(registrations.ToArray());
        }
Пример #8
0
        public async Task CanDeactivateReferral()
        {
            var registrationId = await di.CreateEvacueeRegistrationAsync(RegistrationGenerator.GenerateSelf());

            var referralId = await di.CreateReferralAsync(ReferralGenerator.Generate(ReferralType.Clothing, registrationId));

            var result = await di.DeactivateReferralAsync(referralId);

            Assert.True(result);

            var referral = await di.GetReferralAsync(referralId);

            Assert.False(referral.Active);
        }
Пример #9
0
        public async Task CanIgnoreExcessiveProperties()
        {
            var registrationId = await di.CreateEvacueeRegistrationAsync(RegistrationGenerator.GenerateSelf());

            var referral = ReferralGenerator.GenerateWithExcessiveProperties(registrationId);

            Assert.NotNull(referral.FromAddress);
            Assert.NotNull(referral.ToAddress);

            var referralId = await di.CreateReferralAsync(referral);

            var result = await di.GetReferralAsync(referralId);

            Assert.Null(result.FromAddress);
            Assert.Null(result.ToAddress);
        }
Пример #10
0
        public async Task CanInsertReferralViewModel(Gov.Jag.Embc.Public.ViewModels.Referral referral)
        {
            var ctx = EmbcDb;

            var di = new DataInterface(ctx, Mapper);

            var registrationId = await di.CreateEvacueeRegistrationAsync(RegistrationGenerator.GenerateSelf());

            referral.EssNumber = registrationId;

            var referralId = await di.CreateReferralAsync(referral);

            var result = await di.GetReferralAsync(referralId);

            Assert.NotNull(result);
            Assert.Equal(referral.EssNumber, result.EssNumber);
            Assert.NotEmpty(result.Id);
            Assert.Equal(referral.Type.ToUpperInvariant(), result.Type);
            Assert.Equal(referral.SubType?.ToUpperInvariant(), result.SubType);
            Assert.Equal(referral.Purchaser, result.Purchaser);
            Assert.Equal(referral.TotalAmount, result.TotalAmount);
            Assert.Equal(referral.Supplier.Fax, result.Supplier.Fax);
            Assert.Equal(referral.ValidDates.From, result.ValidDates.From);
            Assert.Equal(referral.ValidDates.To, result.ValidDates.To);
            Assert.Equal(referral.ConfirmChecked, result.ConfirmChecked);
            Assert.All(result.Evacuees, e => referral.Evacuees.Any(re => re.Id == e.Id));
            Assert.Equal(referral.Evacuees.Count(), result.Evacuees.Count());
            Assert.NotNull(result.Supplier);
            Assert.Equal(referral.Supplier.Name, result.Supplier.Name);
            Assert.Equal(referral.Supplier.Address, result.Supplier.Address);
            Assert.Equal(referral.Supplier.City, result.Supplier.City);
            Assert.Equal(referral.Supplier.Province, result.Supplier.Province);
            Assert.Equal(referral.Supplier.Fax, result.Supplier.Fax);
            Assert.Equal(referral.Supplier.Telephone, result.Supplier.Telephone);
            Assert.Equal(referral.Supplier.Active, result.Supplier.Active);
            Assert.Equal(referral.ToAddress, result.ToAddress);
            Assert.Equal(referral.FromAddress, result.FromAddress);
            Assert.Equal(referral.OtherTransportModeDetails, result.OtherTransportModeDetails);
            Assert.Equal(referral.NumLunches, result.NumLunches);
            Assert.Equal(referral.NumBreakfasts, result.NumBreakfasts);
            Assert.Equal(referral.NumDaysMeals, result.NumDaysMeals);
            Assert.Equal(referral.NumDinners, result.NumDinners);
            Assert.Equal(referral.NumNights, result.NumNights);
            Assert.Equal(referral.ApprovedItems, result.ApprovedItems);
            Assert.Equal(referral.ExtremeWinterConditions, result.ExtremeWinterConditions);
        }
Пример #11
0
        public async Task CanGetReferralsInOrder()
        {
            var ctx = EmbcDb;

            var di = new DataInterface(ctx, Mapper);

            var registrationId = await di.CreateEvacueeRegistrationAsync(RegistrationGenerator.GenerateSelf());

            var referrals = new[] {
                ReferralGenerator.Generate(ReferralType.Incidentals, registrationId),
                ReferralGenerator.Generate(ReferralType.Incidentals, registrationId),
                ReferralGenerator.Generate(ReferralType.Clothing, registrationId),
                ReferralGenerator.Generate(ReferralType.Clothing, registrationId),
                ReferralGenerator.Generate(ReferralType.Lodging_Group, registrationId),
                ReferralGenerator.Generate(ReferralType.Lodging_Hotel, registrationId),
                ReferralGenerator.Generate(ReferralType.Transportation_Taxi, registrationId),
                ReferralGenerator.Generate(ReferralType.Food_Restaurant, registrationId),
                ReferralGenerator.Generate(ReferralType.Food_Groceries, registrationId)
            };

            int days = 0;

            foreach (var referral in referrals)
            {
                referral.ValidDates.From = referral.ValidDates.From.AddDays(days);
                referral.ValidDates.To   = referral.ValidDates.To.AddDays(days);
                days++;
            }
            var referralTypeOrder = new List <string> {
                "FOOD", "LODGING", "CLOTHING", "TRANSPORTATION", "INCIDENTALS"
            };
            var expectedReferralsOrder = referrals
                                         .OrderBy(r => referralTypeOrder.IndexOf(r.Type.ToUpperInvariant()))
                                         .ThenByDescending(r => r.ValidDates.From)
                                         .Select(r => (r.Type.ToUpperInvariant(), r.ValidDates.From))
                                         .ToArray();

            foreach (var referral in referrals)
            {
                await di.CreateReferralAsync(referral);
            }

            var result = (await di.GetReferralsAsync(registrationId, new SearchQueryParameters())).Items;

            Assert.Equal(expectedReferralsOrder, result.Select(r => (r.Type, r.ValidFrom)).ToArray());
        }
Пример #12
0
        public async Task GetAll_AdvancedSearch_MatchedElementReturned(EvacueeSearchQueryParameters search, int expectedNumberOfEvacuees)
        {
            var fromCommunity = await GetRandomSeededCommunity();

            var toCommunity = await GetRandomSeededCommunity();

            var incidentTaskId = await SeedIncident(fromCommunity.Id);

            var registrationId = await di.CreateEvacueeRegistrationAsync(RegistrationGenerator.GenerateCompleted(incidentTaskId, toCommunity.Id));

            var registration = await di.GetEvacueeRegistrationAsync(registrationId);

            var lastName = registration.HeadOfHousehold.FamilyMembers.First().LastName;

            var result = await di.GetEvacueesPaginatedAsync(search);

            Assert.Equal(expectedNumberOfEvacuees, result.Items.Count());
        }
Пример #13
0
        public async Task CanMapToReferralListItem()
        {
            var registrationId = await di.CreateEvacueeRegistrationAsync(RegistrationGenerator.GenerateSelf());

            var referralId = await di.CreateReferralAsync(ReferralGenerator.Generate(ReferralType.Clothing, registrationId));

            var referral = await di.GetReferralAsync(referralId);

            var item = referral.ToListItem();

            Assert.Equal(referral.Id, item.ReferralId);
            Assert.StartsWith("D", item.ReferralId);
            Assert.Equal(referral.SubType, item.SubType);
            Assert.Equal(referral.Type, item.Type);
            Assert.Equal(referral.ValidDates.From, item.ValidFrom);
            Assert.Equal(referral.ValidDates.To, item.ValidTo);
            Assert.Equal(referral.Supplier.Name, item.Supplier.Name);
        }
Пример #14
0
        public async Task GetAll_BasicSearchByIncidentTaskNumber_MatchedElementReturned()
        {
            var fromCommunity = await GetRandomSeededCommunity();

            var toCommunity = await GetRandomSeededCommunity();

            var incidentTaskId = await SeedIncident(fromCommunity.Id);

            var registrationId = await di.CreateEvacueeRegistrationAsync(RegistrationGenerator.GenerateCompleted(incidentTaskId, toCommunity.Id));

            var registration = await di.GetEvacueeRegistrationAsync(registrationId);

            var result = await di.GetEvacueesPaginatedAsync(new EvacueeSearchQueryParameters()
            {
                Query = incidentTaskId
            });

            Assert.All(result.Items, e => Assert.Equal(incidentTaskId, e.IncidentTaskNumber));
        }
Пример #15
0
        public async Task GetAll_BasicSearchByDifferentName_NoMatchedElementReturned()
        {
            var fromCommunity = await GetRandomSeededCommunity();

            var toCommunity = await GetRandomSeededCommunity();

            var incidentTaskId = await SeedIncident(fromCommunity.Id);

            var registrationId = await di.CreateEvacueeRegistrationAsync(RegistrationGenerator.GenerateCompleted(incidentTaskId, toCommunity.Id));

            var registration = await di.GetEvacueeRegistrationAsync(registrationId);

            var lastName = registration.HeadOfHousehold.LastName;

            var result = await di.GetEvacueesPaginatedAsync(new EvacueeSearchQueryParameters()
            {
                Query = "1234"
            });

            Assert.Empty(result.Items);
        }
Пример #16
0
        public async Task GetAll_BasicSearchByHOHLastNamePartial_MatchedElementReturned()
        {
            var fromCommunity = await GetRandomSeededCommunity();

            var toCommunity = await GetRandomSeededCommunity();

            var incidentTaskId = await SeedIncident(fromCommunity.Id);

            var registrationId = await di.CreateEvacueeRegistrationAsync(RegistrationGenerator.GenerateCompleted(incidentTaskId, toCommunity.Id));

            var registration = await di.GetEvacueeRegistrationAsync(registrationId);

            var lastName = registration.HeadOfHousehold.LastName.Substring(1, 3);

            var result = await di.GetEvacueesPaginatedAsync(new EvacueeSearchQueryParameters()
            {
                Query = lastName
            });

            Assert.All(result.Items, e => Assert.Contains(lastName, e.LastName));
        }
Пример #17
0
        public async Task GetAll_BasicSearchByHostCommunity_MatchedElementReturned()
        {
            var fromCommunity = await GetRandomSeededCommunity();

            var toCommunity = await GetRandomSeededCommunity();

            var incidentTaskId = await SeedIncident(fromCommunity.Id);

            var registrationId = await di.CreateEvacueeRegistrationAsync(RegistrationGenerator.GenerateCompleted(incidentTaskId, toCommunity.Id));

            var registration = await di.GetEvacueeRegistrationAsync(registrationId);

            var hostCommunityName = toCommunity.Name;

            var result = await di.GetEvacueesPaginatedAsync(new EvacueeSearchQueryParameters()
            {
                Query = hostCommunityName
            });

            Assert.All(result.Items, e => Assert.Contains(hostCommunityName, e.EvacuatedTo));
        }
Пример #18
0
        public async Task CanMapToListItem()
        {
            var ctx = EmbcDb;
            var di  = new DataInterface(ctx, Mapper);

            var fromCommunity = (await di.GetCommunitiesAsync()).First();
            var toCommunity   = (await di.GetCommunitiesAsync()).Last();

            var incidentTask = await di.CreateIncidentTaskAsync(new Gov.Jag.Embc.Public.ViewModels.IncidentTask()
            {
                Active    = true,
                Community = new Gov.Jag.Embc.Public.ViewModels.Community {
                    Id = fromCommunity.Id
                }
            });

            var registrationId = await di.CreateEvacueeRegistrationAsync(RegistrationGenerator.GenerateCompleted(incidentTask.Id, toCommunity.Id));

            var registration = await di.GetEvacueeRegistrationAsync(registrationId);

            var result = await di.GetEvacueesAsync(new SearchQueryParameters());

            Assert.Equal(registration.HeadOfHousehold.FamilyMembers.Count(), result.Items.Count(e => !e.IsHeadOfHousehold));
            Assert.Equal(1, result.Items.Count(e => e.IsHeadOfHousehold));
            Assert.All(result.Items, e =>
            {
                Assert.Equal(registration.IncidentTask.TaskNumber, e.IncidentTaskNumber);
                Assert.Equal(registration.Id, e.RegistrationId);
                Assert.Equal(registration.RestrictedAccess, e.RestrictedAccess);
                Assert.Equal(registration.RegistrationCompletionDate, e.RegistrationCompletionDate);
                Assert.Equal(registration.IncidentTask.Community.Name, e.EvacuatedFrom);
                Assert.Equal(registration.HostCommunity.Name, e.EvacuatedTo);
                Assert.True(e.IsFinalized);
                Assert.False(e.HasReferrals);
            });
        }