Esempio n. 1
0
        public async Task GetFilteredAatfsDataAccess_ByCA_ReturnsFilteredAatfsList()
        {
            using (var database = new DatabaseWrapper())
            {
                var helper                       = new ModelHelper(database.Model);
                var dataAccess                   = new GetAatfsDataAccess(database.WeeeContext);
                var genericDataAccess            = new GenericDataAccess(database.WeeeContext);
                var competentAuthorityDataAccess = new CommonDataAccess(database.WeeeContext);
                var competentAuthority           = await competentAuthorityDataAccess.FetchCompetentAuthority(CompetentAuthority.England);

                var competentAuthorityNIEA = await competentAuthorityDataAccess.FetchCompetentAuthority(CompetentAuthority.NorthernIreland);

                var country = await database.WeeeContext.Countries.SingleAsync(c => c.Name == "UK - England");

                var aatfContact  = new AatfContact("first", "last", "position", "address1", "address2", "town", "county", "postcode", country, "telephone", "email");
                var organisation = Organisation.CreatePartnership("Koalas");
                var aatfAddress  = AddressHelper.GetAatfAddress(database);
                var aatfSize     = AatfSize.Large;

                var aatf  = new Aatf("KoalaBears", competentAuthority, "WEE/AB1289YZ/ATF", AatfStatus.Approved, organisation, aatfAddress, aatfSize, DateTime.Now, aatfContact, FacilityType.Aatf, 2019, database.WeeeContext.LocalAreas.First(), database.WeeeContext.PanAreas.First());
                var aatf1 = new Aatf("KoalaBears1", competentAuthority, "WEE/AB1289YY/ATF", AatfStatus.Cancelled, organisation, aatfAddress, aatfSize, DateTime.Now, aatfContact, FacilityType.Aatf, 2019, database.WeeeContext.LocalAreas.First(), database.WeeeContext.PanAreas.First());
                var aatf2 = new Aatf("KoalaBears2", competentAuthorityNIEA, "WEE/AB1289YP/ATF", AatfStatus.Cancelled, organisation, aatfAddress, aatfSize, DateTime.Now, aatfContact, FacilityType.Aatf, 2019, database.WeeeContext.LocalAreas.First(), database.WeeeContext.PanAreas.First());

                await genericDataAccess.AddMany <Aatf>(new List <Aatf>() { aatf, aatf1, aatf2 });

                var filteredListWithEA = await dataAccess.GetFilteredAatfs(new Core.AatfReturn.AatfFilter {
                    SelectedAuthority = new List <Guid> {
                        competentAuthority.Id
                    }
                });

                var filteredListWithNIEA = await dataAccess.GetFilteredAatfs(new Core.AatfReturn.AatfFilter {
                    SelectedAuthority = new List <Guid> {
                        competentAuthorityNIEA.Id
                    }
                });

                var filteredListWithBothCA = await dataAccess.GetFilteredAatfs(new Core.AatfReturn.AatfFilter {
                    SelectedAuthority = new List <Guid> {
                        competentAuthorityNIEA.Id, competentAuthority.Id
                    }
                });

                filteredListWithEA.Should().Contain(aatf);
                filteredListWithEA.Should().Contain(aatf1);
                filteredListWithEA.Should().NotContain(aatf2);

                filteredListWithNIEA.Should().Contain(aatf2);
                filteredListWithNIEA.Should().NotContain(aatf);
                filteredListWithNIEA.Should().NotContain(aatf1);

                filteredListWithBothCA.Should().Contain(aatf);
                filteredListWithBothCA.Should().Contain(aatf1);
                filteredListWithBothCA.Should().Contain(aatf2);
            }
        }
Esempio n. 2
0
        public async Task GetFilteredAatfsDataAccess_ByApprovalNumber_ReturnsFilteredAatfsList()
        {
            using (var database = new DatabaseWrapper())
            {
                var helper                       = new ModelHelper(database.Model);
                var dataAccess                   = new GetAatfsDataAccess(database.WeeeContext);
                var genericDataAccess            = new GenericDataAccess(database.WeeeContext);
                var competentAuthorityDataAccess = new CommonDataAccess(database.WeeeContext);
                var competentAuthority           = await competentAuthorityDataAccess.FetchCompetentAuthority(CompetentAuthority.England);

                var country = await database.WeeeContext.Countries.SingleAsync(c => c.Name == "UK - England");

                var aatfContact  = new AatfContact("first", "last", "position", "address1", "address2", "town", "county", "postcode", country, "telephone", "email");
                var organisation = Organisation.CreatePartnership("Koalas");
                var aatfAddress  = AddressHelper.GetAatfAddress(database);
                var aatfSize     = AatfSize.Large;

                var aatf = new Aatf("KoalaBears", competentAuthority, "WEE/AB1289YZ/ATF", AatfStatus.Approved, organisation, aatfAddress, aatfSize, DateTime.Now, aatfContact, FacilityType.Aatf, 2019, database.WeeeContext.LocalAreas.First(), database.WeeeContext.PanAreas.First());

                await genericDataAccess.Add <Aatf>(aatf);

                var filteredListWithAatf = await dataAccess.GetFilteredAatfs(new Core.AatfReturn.AatfFilter {
                    ApprovalNumber = "a"
                });

                var filteredListWithoutAatf = await dataAccess.GetFilteredAatfs(new Core.AatfReturn.AatfFilter {
                    ApprovalNumber = "q"
                });

                filteredListWithAatf.Should().Contain(aatf);
                filteredListWithoutAatf.Should().NotContain(aatf);
            }
        }
Esempio n. 3
0
        public async Task GetAatfsDataAccess_ReturnsAatfsList()
        {
            using (var database = new DatabaseWrapper())
            {
                var helper                       = new ModelHelper(database.Model);
                var dataAccess                   = new GetAatfsDataAccess(database.WeeeContext);
                var genericDataAccess            = new GenericDataAccess(database.WeeeContext);
                var competentAuthorityDataAccess = new CommonDataAccess(database.WeeeContext);
                var competentAuthority           = await competentAuthorityDataAccess.FetchCompetentAuthority(CompetentAuthority.England);

                var country = await database.WeeeContext.Countries.SingleAsync(c => c.Name == "UK - England");

                var aatfContact  = new AatfContact("first", "last", "position", "address1", "address2", "town", "county", "postcode", country, "telephone", "email");
                var organisation = Organisation.CreatePartnership("Koalas");
                var aatfAddress  = AddressHelper.GetAatfAddress(database);
                var aatfSize     = AatfSize.Large;

                var aatf = ObligatedWeeeIntegrationCommon.CreateAatf(database, organisation);

                await genericDataAccess.Add <Aatf>(aatf);

                var aatfList = await dataAccess.GetAatfs();

                aatfList.Should().Contain(aatf);
            }
        }
Esempio n. 4
0
        public async Task GetAatfsDataAccess_ReturnsLatestAesList()
        {
            using (var database = new DatabaseWrapper())
            {
                var helper                       = new ModelHelper(database.Model);
                var dataAccess                   = new GetAatfsDataAccess(database.WeeeContext);
                var genericDataAccess            = new GenericDataAccess(database.WeeeContext);
                var competentAuthorityDataAccess = new CommonDataAccess(database.WeeeContext);
                var competentAuthority           = await competentAuthorityDataAccess.FetchCompetentAuthority(CompetentAuthority.England);

                var country = await database.WeeeContext.Countries.SingleAsync(c => c.Name == "UK - England");

                var aatfContact  = new AatfContact("first", "last", "position", "address1", "address2", "town", "county", "postcode", country, "telephone", "email");
                var organisation = Organisation.CreatePartnership("Koalas");
                var aatfAddress  = AddressHelper.GetAatfAddress(database);
                var aatfSize     = AatfSize.Large;

                var aatfId = Guid.NewGuid();

                var aatf  = new Aatf("KoalaBears", competentAuthority, "WEE/AB1289YZ/ATF", AatfStatus.Approved, organisation, aatfAddress, aatfSize, DateTime.Now, aatfContact, FacilityType.Ae, 2019, database.WeeeContext.LocalAreas.First(), database.WeeeContext.PanAreas.First(), aatfId);
                var aatf1 = new Aatf("KoalaBears", competentAuthority, "WEE/AB1289YZ/ATF", AatfStatus.Approved, organisation, aatfAddress, aatfSize, Convert.ToDateTime("20/01/2020"), aatfContact, FacilityType.Ae, 2020, database.WeeeContext.LocalAreas.First(), database.WeeeContext.PanAreas.First(), aatfId);

                await genericDataAccess.AddMany <Aatf>(new List <Aatf>() { aatf1, aatf });

                var aatfList = await dataAccess.GetLatestAatfs();

                aatfList.Should().Contain(aatf1);
                aatfList.Should().NotContain(aatf);
            }
        }
Esempio n. 5
0
        private async Task <Aatf> CreateAatf(DatabaseWrapper database, FacilityType facilityType, DateTime date, short year, string approvalNumber = null, string name = null)
        {
            var country = database.WeeeContext.Countries.First();
            var competentAuthorityDataAccess = new CommonDataAccess(database.WeeeContext);
            var competentAuthority           = await competentAuthorityDataAccess.FetchCompetentAuthority(CompetentAuthority.England);

            var organisation = Organisation.CreatePartnership("Dummy");
            var contact      = new AatfContact("First Name", "Last Name", "Manager", "1 Address Lane", "Address Ward", "Town", "County", "Postcode", country, "01234 567890", "*****@*****.**");

            if (approvalNumber == null)
            {
                approvalNumber = "12345678";
            }

            if (name == null)
            {
                name = "name";
            }

            return(new Aatf(name,
                            competentAuthority,
                            approvalNumber,
                            AatfStatus.Approved,
                            organisation,
                            AddressHelper.GetAatfAddress(database),
                            A.Fake <AatfSize>(),
                            date,
                            contact,
                            facilityType,
                            year,
                            database.WeeeContext.LocalAreas.First(),
                            database.WeeeContext.PanAreas.First()));
        }
Esempio n. 6
0
        public async Task GetEACompetentAuthorityById_AuthorityShouldBeReturned(string id, string abbreviation)
        {
            using (var database = new DatabaseWrapper())
            {
                var helper = new ModelHelper(database.Model);

                var dataAccess = new CommonDataAccess(database.WeeeContext);

                var result = await dataAccess.FetchCompetentAuthority(abbreviation);

                result.Abbreviation.Should().Be(abbreviation);
            }
        }
        private async Task <Aatf> CreateAatf(DatabaseWrapper database, Organisation organisation, DateTime?approvalDate)
        {
            var competentAuthorityDataAccess = new CommonDataAccess(database.WeeeContext);
            var country = await database.WeeeContext.Countries.SingleAsync(c => c.Name == "France");

            var competentAuthority = await competentAuthorityDataAccess.FetchCompetentAuthority(CompetentAuthority.England);

            var aatf = ObligatedWeeeIntegrationCommon.CreateAatf(database, organisation);

            if (!approvalDate.HasValue)
            {
                aatf.UpdateDetails("name", competentAuthority, "12345678", AatfStatus.Approved, organisation, AatfSize.Large, null, aatf.LocalArea, aatf.PanArea);
            }

            database.WeeeContext.Aatfs.Add(aatf);

            await database.WeeeContext.SaveChangesAsync();

            return(aatf);
        }
Esempio n. 8
0
        private async Task <List <Aatf> > CreateMultipleAatf(DatabaseWrapper database, FacilityType facilityType, DateTime date, short year)
        {
            var country = database.WeeeContext.Countries.First();
            var competentAuthorityDataAccess = new CommonDataAccess(database.WeeeContext);
            var competentAuthority           = await competentAuthorityDataAccess.FetchCompetentAuthority(CompetentAuthority.England);

            var organisation = Organisation.CreatePartnership("Dummy");
            var contact      = new AatfContact("First Name", "Last Name", "Manager", "1 Address Lane", "Address Ward", "Town", "County", "Postcode", country, "01234 567890", "*****@*****.**");
            var aatfList     = new List <Aatf>();

            aatfList.Add(new Aatf("B",
                                  competentAuthority,
                                  "12345678",
                                  AatfStatus.Approved,
                                  organisation,
                                  AddressHelper.GetAatfAddress(database),
                                  A.Fake <AatfSize>(),
                                  date,
                                  contact,
                                  facilityType,
                                  year,
                                  database.WeeeContext.LocalAreas.First(),
                                  database.WeeeContext.PanAreas.First()));

            aatfList.Add(new Aatf("A",
                                  competentAuthority,
                                  "12345679",
                                  AatfStatus.Approved,
                                  organisation,
                                  AddressHelper.GetAatfAddress(database),
                                  A.Fake <AatfSize>(),
                                  date,
                                  contact,
                                  facilityType,
                                  year,
                                  database.WeeeContext.LocalAreas.First(),
                                  database.WeeeContext.PanAreas.First()));

            return(aatfList);
        }