예제 #1
0
        public async Task <ActionResult> DownloadUkWeeeDataCsv(int complianceYear)
        {
            FileInfo file;

            var request = new GetUkWeeeCsv(complianceYear);

            using (var client = apiClient())
            {
                file = await client.SendAsync(User.GetAccessToken(), request);
            }

            return(File(file.Data, "text/csv", file.FileName));
        }
        public async Task HandleAsync_WithNonInternalUser_ThrowsSecurityException()
        {
            // Arrange
            IWeeeAuthorization authorization = new AuthorizationBuilder().DenyInternalAreaAccess().Build();

            GetUkWeeeCsvHandler handler = new GetUkWeeeCsvHandler(
                authorization,
                A.Dummy<IGetUkWeeeCsvDataAccess>(),
                A.Dummy<CsvWriterFactory>());

            GetUkWeeeCsv request = new GetUkWeeeCsv(A.Dummy<int>());

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

            // Assert
            await Assert.ThrowsAsync<SecurityException>(testCode);
        }
예제 #3
0
        public async Task HandleAsync_WithNonInternalUser_ThrowsSecurityException()
        {
            // Arrange
            IWeeeAuthorization authorization = new AuthorizationBuilder().DenyInternalAreaAccess().Build();

            GetUkWeeeCsvHandler handler = new GetUkWeeeCsvHandler(
                authorization,
                A.Dummy <IGetUkWeeeCsvDataAccess>(),
                A.Dummy <CsvWriterFactory>());

            GetUkWeeeCsv request = new GetUkWeeeCsv(A.Dummy <int>());

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

            // Assert
            await Assert.ThrowsAsync <SecurityException>(testCode);
        }
        public async Task HandleAsync_Always_GeneratesCorrectFileName()
        {
            // Arrange
            IWeeeAuthorization authorization = AuthorizationBuilder.CreateUserWithAllRights();

            GetUkWeeeCsvHandler handler = new GetUkWeeeCsvHandler(
                authorization,
                A.Dummy<IGetUkWeeeCsvDataAccess>(),
                A.Dummy<CsvWriterFactory>());

            GetUkWeeeCsv request = new GetUkWeeeCsv(2016);

            // Act
            SystemTime.Freeze(new DateTime(2016, 12, 31, 23, 59, 0));
            FileInfo result = await handler.HandleAsync(request);
            SystemTime.Unfreeze();

            // Assert
            Assert.Equal("2016_UK_WEEE_31122016_2359.csv", result.FileName);
        }
예제 #5
0
        public async Task HandleAsync_Always_GeneratesCorrectFileName()
        {
            // Arrange
            IWeeeAuthorization authorization = AuthorizationBuilder.CreateUserWithAllRights();

            GetUkWeeeCsvHandler handler = new GetUkWeeeCsvHandler(
                authorization,
                A.Dummy <IGetUkWeeeCsvDataAccess>(),
                A.Dummy <CsvWriterFactory>());

            GetUkWeeeCsv request = new GetUkWeeeCsv(2016);

            // Act
            SystemTime.Freeze(new DateTime(2016, 12, 31, 23, 59, 0));
            FileInfo result = await handler.HandleAsync(request);

            SystemTime.Unfreeze();

            // Assert
            Assert.Equal("2016_UK_WEEE_collected_by_PCSs_31122016_2359.csv", result.FileName);
        }
        public async Task<ActionResult> DownloadUkWeeeDataCsv(int complianceYear)
        {
            FileInfo file;

            GetUkWeeeCsv request = new GetUkWeeeCsv(complianceYear);
            using (var client = apiClient())
            {
                file = await client.SendAsync(User.GetAccessToken(), request);
            }

            return File(file.Data, "text/csv", file.FileName);
        }