public async Task GetAatfAeReturnDataCSVHandler_Returns_MatchingFileContent()
        {
            var complianceYear   = 2019;
            var authorization    = new AuthorizationBuilder().AllowInternalAreaAccess().Build();
            var context          = A.Fake <WeeeContext>();
            var aatfDataAccess   = A.Fake <IGetAatfsDataAccess>();
            var csvWriterFactory = A.Fake <CsvWriterFactory>();

            var storedProcedures = A.Fake <IStoredProcedures>();

            A.CallTo(() => context.StoredProcedures)
            .Returns(storedProcedures);

            DataTable obligatedDataTable = CreateDummyDatatable();

            A.CallTo(() => storedProcedures
                     .GetAatfObligatedCsvData(A.Dummy <Guid>(), A <int> ._, A <int> ._, A.Dummy <Guid>()))
            .Returns(obligatedDataTable);

            var handler = new GetAatfObligatedDataHandler(authorization, context, csvWriterFactory, aatfDataAccess);
            var request = new GetAatfObligatedData(complianceYear, 1, A.Dummy <Guid>(), A.Dummy <Guid>());

            // Act
            var data = await handler.HandleAsync(request);

            data.FileContent.Contains("2019,Q1,TestAatf1,WEE/AC0005ZT/ATF,T User,24/04/2019,1. Large Household Appliances,B2C,33,15,");
            data.FileContent.Contains("2019,Q1,TestAatf2,WEE/AC0005ZT/ATF,T User,24/04/2019,1. Large Household Appliances,B2C,33,15,");
            data.FileContent.Contains("2019,Q1,TestAatf3,WEE/AC0005ZT/ATF,T User,24/04/2019,1. Large Household Appliances,B2C,33,15,");
            data.FileContent.Contains("2019,Q1,TestAatf4,WEE/AC0005ZT/ATF,T User,24/04/2019,1. Large Household Appliances,B2C,33,15,");
            data.FileContent.Contains("2019,Q1,TestAatf5,WEE/AC0005ZT/ATF,T User,24/04/2019,1. Large Household Appliances,B2C,33,15,");
        }
        public async Task GetAatfObligatedDataCsvHandlerr_PassVariousComplianceYears_ReturnsFileContent(int complianceYear)
        {
            var authorization    = new AuthorizationBuilder().AllowInternalAreaAccess().Build();
            var context          = A.Fake <WeeeContext>();
            var aatfDataAccess   = A.Fake <IGetAatfsDataAccess>();
            var csvWriterFactory = A.Fake <CsvWriterFactory>();

            var handler = new GetAatfObligatedDataHandler(authorization, context, csvWriterFactory, aatfDataAccess);
            var request = new GetAatfObligatedData(complianceYear, 1, A.Dummy <Guid>(), A.Dummy <Guid>());

            // Act
            CSVFileData data = await handler.HandleAsync(request);

            // Assert
            Assert.NotEmpty(data.FileContent);
        }
        public async Task GetAatfObligatedDataCsvHandler_NoComplianceYear_ThrowsArgumentException()
        {
            // Arrange
            var complianceYear = 0;

            var authorization    = new AuthorizationBuilder().AllowInternalAreaAccess().Build();
            var context          = A.Fake <WeeeContext>();
            var aatfDataAccess   = A.Fake <IGetAatfsDataAccess>();
            var csvWriterFactory = A.Fake <CsvWriterFactory>();

            var handler = new GetAatfObligatedDataHandler(authorization, context, csvWriterFactory, aatfDataAccess);
            var request = new GetAatfObligatedData(complianceYear, 1, A.Dummy <Guid>(), A.Dummy <Guid>());

            // Act
            Func <Task> action = async() => await handler.HandleAsync(request);

            // Assert
            await Assert.ThrowsAsync <ArgumentException>(action);
        }
        public async Task GetAatfObligatedDataCsvHandler_ReturnsFileName()
        {
            var authorization    = new AuthorizationBuilder().AllowInternalAreaAccess().Build();
            var context          = A.Fake <WeeeContext>();
            var aatfDataAccess   = A.Fake <IGetAatfsDataAccess>();
            var csvWriterFactory = A.Fake <CsvWriterFactory>();
            int complianceYear   = 2019;

            SystemTime.Freeze(new DateTime(2019, 2, 1, 11, 1, 2));
            Aatf aatf = new Aatf("Company Aatf", A.Dummy <UKCompetentAuthority>(), "1234", Domain.AatfReturn.AatfStatus.Approved, A.Fake <Organisation>(), A.Dummy <AatfAddress>(), Domain.AatfReturn.AatfSize.Large, DateTime.Now, A.Fake <AatfContact>(), Domain.AatfReturn.FacilityType.Aatf, 2019, A.Fake <LocalArea>(), A.Fake <PanArea>());

            var handler = new GetAatfObligatedDataHandler(authorization, context, csvWriterFactory, aatfDataAccess);
            var request = new GetAatfObligatedData(complianceYear, 1, A.Dummy <Guid>(), A.Dummy <Guid>());

            A.CallTo(() => aatfDataAccess.GetAatfById(request.AatfId)).Returns(aatf);

            // Act
            CSVFileData data = await handler.HandleAsync(request);

            // Assert
            data.FileName.Should().Be("2019_Q1_1234_Full data_01022019_1101.csv");
        }