Beispiel #1
0
 public AatfDataList(Guid id, string name, UKCompetentAuthorityData competentAuthority, string approvalNumber, AatfStatus aatfStatus, OrganisationData organisation, FacilityType facilityType, Int16 complianceYear, Guid aatfId, DateTime?approvalDate)
 {
     this.Id                 = id;
     this.Name               = name;
     this.ApprovalNumber     = approvalNumber;
     this.AatfStatus         = aatfStatus;
     this.AatfStatusString   = aatfStatus.DisplayName;
     this.CompetentAuthority = competentAuthority;
     this.Organisation       = organisation;
     this.FacilityType       = facilityType;
     this.ComplianceYear     = complianceYear;
     this.AatfId             = aatfId;
     this.ApprovalDate       = approvalDate;
 }
Beispiel #2
0
        private AatfData CreateAatfData(out UKCompetentAuthorityData competentAuthority)
        {
            competentAuthority = fixture.Create <UKCompetentAuthorityData>();
            var localArea   = fixture.Create <LocalAreaData>();
            var panAreaData = fixture.Create <PanAreaData>();

            var data = fixture.Build <AatfData>()
                       .With(e => e.CompetentAuthority, competentAuthority)
                       .With(e => e.AatfStatus, Core.AatfReturn.AatfStatus.Approved)
                       .With(e => e.Size, Core.AatfReturn.AatfSize.Large)
                       .With(e => e.LocalAreaData, localArea)
                       .With(e => e.PanAreaData, panAreaData)
                       .With(e => e.AatfSizeValue, Core.AatfReturn.AatfSize.Large.Value)
                       .With(e => e.AatfStatusValue, Core.AatfReturn.AatfStatus.Approved.Value)
                       .Create();

            return(data);
        }
Beispiel #3
0
 public AatfData(Guid id, string name, string approvalNumber, Int16 complianceYear, UKCompetentAuthorityData competentAuthority = null, AatfStatus status = null, AatfAddressData siteAddress = null, AatfSize size = null, DateTime approvalDate = default(DateTime), PanAreaData panAreaData = null, LocalAreaData localAreaData = null)
 {
     this.Id                 = id;
     this.Name               = name;
     this.ApprovalNumber     = approvalNumber;
     this.CompetentAuthority = competentAuthority;
     this.AatfStatus         = status;
     this.SiteAddress        = siteAddress;
     this.Size               = size;
     this.ApprovalDate       = approvalDate;
     this.ComplianceYear     = complianceYear;
     this.PanAreaData        = panAreaData;
     this.LocalAreaData      = localAreaData;
 }
        public async Task GetDownloadProducerDetailsCsv_WithNoSchemeIdAndWithAnAuthorityId_ReturnsFileNameWithComplianceYearAuthorityAbbreviationAndCurrentTime()
        {
            // Arrange
            IWeeeClient client = A.Fake<IWeeeClient>();

            CSVFileData file = new CSVFileData() { FileContent = "Content" };
            A.CallTo(() => client.SendAsync(A<string>._, A<GetMemberDetailsCsv>._))
                .Returns(file);

            UKCompetentAuthorityData authorityData = new UKCompetentAuthorityData() { Abbreviation = "AA" };
            A.CallTo(() => client.SendAsync(A<string>._, A<GetUKCompetentAuthorityById>._))
                .WhenArgumentsMatch(a => a.Get<GetUKCompetentAuthorityById>("request").Id == new Guid("703839B3-A081-4491-92B7-FCF969067EA3"))
                .Returns(authorityData);

            ReportsController controller = new ReportsController(
                () => client,
                A.Dummy<BreadcrumbService>());

            // Act
            SystemTime.Freeze(new DateTime(2016, 12, 31, 23, 59, 58));
            ActionResult result = await controller.DownloadProducerDetailsCsv(
                2015,
                null,
                new Guid("703839B3-A081-4491-92B7-FCF969067EA3"),
                false,
                false);
            SystemTime.Unfreeze();

            // Assert
            FileResult fileResult = result as FileResult;
            Assert.NotNull(fileResult);

            Assert.Equal("2015_AA_producerdetails_31122016_2359.csv", fileResult.FileDownloadName);
        }
        public async Task PostProducerDetails_WithInvalidViewModel_ReturnsSchemeWeeeDataProducerDataViewModel()
        {
            // Arrange
            IWeeeClient weeeClient = A.Fake<IWeeeClient>();

            List<int> years = new List<int>() { 2001, 2002 };
            A.CallTo(() => weeeClient.SendAsync(A<string>._, A<GetMemberRegistrationsActiveComplianceYears>._)).Returns(years);

            UKCompetentAuthorityData authority1 = new UKCompetentAuthorityData()
            {
                Id = new Guid("EB44DAD0-6B47-47C1-9124-4BE91042E563"),
                Abbreviation = "AA1"
            };
            List<UKCompetentAuthorityData> authorities = new List<UKCompetentAuthorityData>() { authority1 };
            A.CallTo(() => weeeClient.SendAsync(A<string>._, A<GetUKCompetentAuthorities>._)).Returns(authorities);

            SchemeData scheme1 = new SchemeData()
            {
                Id = new Guid("0F638399-226F-4942-AEF1-E6BC7EB447D6"),
                SchemeName = "Test Scheme"
            };
            List<SchemeData> schemes = new List<SchemeData>() { scheme1 };
            A.CallTo(() => weeeClient.SendAsync(A<string>._, A<Weee.Requests.Admin.GetSchemes>._)).Returns(schemes);

            ReportsController controller = new ReportsController(
                () => weeeClient,
                A.Dummy<BreadcrumbService>());

            // Act
            controller.ModelState.AddModelError("Key", "Error");
            ActionResult result = await controller.ProducerDetails(A.Dummy<ReportsFilterViewModel>());

            // Assert
            ViewResult viewResult = result as ViewResult;
            Assert.NotNull(viewResult);
            Assert.True(string.IsNullOrEmpty(viewResult.ViewName) || viewResult.ViewName.ToLowerInvariant() == "producerdetails");

            ReportsFilterViewModel model = viewResult.Model as ReportsFilterViewModel;
            Assert.NotNull(model);

            Assert.Collection(model.ComplianceYears,
                y1 => Assert.Equal("2001", y1.Text),
                y2 => Assert.Equal("2002", y2.Text));

            Assert.Collection(model.AppropriateAuthorities,
                a1 => { Assert.Equal("EB44DAD0-6B47-47C1-9124-4BE91042E563", a1.Value, true); Assert.Equal("AA1", a1.Text); });

            Assert.Collection(model.SchemeNames,
                s1 => { Assert.Equal("0F638399-226F-4942-AEF1-E6BC7EB447D6", s1.Value, true); Assert.Equal("Test Scheme", s1.Text); });
        }