public async Task HandleAsync_ReturnsFileContent()
        {
            // Arrange
            IWeeeAuthorization authorization = new AuthorizationBuilder().AllowInternalAreaAccess().Build();
            var context = A.Fake<WeeeContext>();
            var csvWriterFactory = A.Fake<CsvWriterFactory>();
            GetProducerEeeDataHistoryCsvHandler handler = new GetProducerEeeDataHistoryCsvHandler(
                authorization,
                context,
                csvWriterFactory);

            GetProducerEeeDataHistoryCsv request = new GetProducerEeeDataHistoryCsv("PRN");
            // Act
            CSVFileData data = await handler.HandleAsync(request);

            // Assert
            Assert.NotEmpty(data.FileContent);
        }
        public async Task HandleAsync_ReturnsFileContent()
        {
            // Arrange
            IWeeeAuthorization authorization = new AuthorizationBuilder().AllowInternalAreaAccess().Build();
            var context          = A.Fake <WeeeContext>();
            var csvWriterFactory = A.Fake <CsvWriterFactory>();
            GetProducerEeeDataHistoryCsvHandler handler = new GetProducerEeeDataHistoryCsvHandler(
                authorization,
                context,
                csvWriterFactory);

            GetProducerEeeDataHistoryCsv request = new GetProducerEeeDataHistoryCsv("PRN");
            // Act
            CSVFileData data = await handler.HandleAsync(request);

            // Assert
            Assert.NotEmpty(data.FileContent);
        }
        public async Task HandleAsync_WithNoRegistrationNumber_ThrowsArgumentException()
        {
            // Arrange            
            IWeeeAuthorization authorization = new AuthorizationBuilder().AllowInternalAreaAccess().Build();
            var context = A.Fake<WeeeContext>();
            var csvWriterFactory = A.Fake<CsvWriterFactory>();
            GetProducerEeeDataHistoryCsvHandler handler = new GetProducerEeeDataHistoryCsvHandler(
                authorization,
                context,
                csvWriterFactory);

            GetProducerEeeDataHistoryCsv request = new GetProducerEeeDataHistoryCsv(string.Empty);

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

            // Assert
            await Assert.ThrowsAsync<ArgumentException>(action);
        }
        public async Task HandleAsync_WithNonInternalUser_ThrowsSecurityException()
        {
            // Arrange            
            var authorization = new AuthorizationBuilder().DenyInternalAreaAccess().Build();
            var context = A.Fake<WeeeContext>();
            var csvWriterFactory = A.Fake<CsvWriterFactory>();
            GetProducerEeeDataHistoryCsvHandler handler = new GetProducerEeeDataHistoryCsvHandler(
                authorization,
                context,
                csvWriterFactory);

            GetProducerEeeDataHistoryCsv request = new GetProducerEeeDataHistoryCsv(A.Dummy<string>());

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

            // Assert
            await Assert.ThrowsAsync<SecurityException>(action);
        }
        public async Task HandleAsync_WithNoRegistrationNumber_ThrowsArgumentException()
        {
            // Arrange
            IWeeeAuthorization authorization = new AuthorizationBuilder().AllowInternalAreaAccess().Build();
            var context          = A.Fake <WeeeContext>();
            var csvWriterFactory = A.Fake <CsvWriterFactory>();
            GetProducerEeeDataHistoryCsvHandler handler = new GetProducerEeeDataHistoryCsvHandler(
                authorization,
                context,
                csvWriterFactory);

            GetProducerEeeDataHistoryCsv request = new GetProducerEeeDataHistoryCsv(string.Empty);

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

            // Assert
            await Assert.ThrowsAsync <ArgumentException>(action);
        }
        public async Task HandleAsync_WithNonInternalUser_ThrowsSecurityException()
        {
            // Arrange
            var authorization    = new AuthorizationBuilder().DenyInternalAreaAccess().Build();
            var context          = A.Fake <WeeeContext>();
            var csvWriterFactory = A.Fake <CsvWriterFactory>();
            GetProducerEeeDataHistoryCsvHandler handler = new GetProducerEeeDataHistoryCsvHandler(
                authorization,
                context,
                csvWriterFactory);

            GetProducerEeeDataHistoryCsv request = new GetProducerEeeDataHistoryCsv(A.Dummy <string>());

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

            // Assert
            await Assert.ThrowsAsync <SecurityException>(action);
        }