Пример #1
0
        public async Task HandleAsync_WithNonInternalUser_ThrowsSecurityException()
        {
            IWeeeAuthorization authorization = new AuthorizationBuilder().DenyInternalAreaAccess().Build();
            var context          = A.Dummy <WeeeContext>();
            var dataAccess       = A.Dummy <ICommonDataAccess>();
            var csvWriterFactory = A.Dummy <CsvWriterFactory>();

            var handler = new FetchInvoiceRunCsvHandler(authorization, context, dataAccess, csvWriterFactory);

            await Assert.ThrowsAsync <SecurityException>(() => handler.HandleAsync(A.Dummy <FetchInvoiceRunCsv>()));
        }
        public async Task HandleAsync_WithNonInternalUser_ThrowsSecurityException()
        {
            IWeeeAuthorization authorization = new AuthorizationBuilder().DenyInternalAreaAccess().Build();
            var context = A.Dummy<WeeeContext>();
            var dataAccess = A.Dummy<ICommonDataAccess>();
            var csvWriterFactory = A.Dummy<CsvWriterFactory>();

            var handler = new FetchInvoiceRunCsvHandler(authorization, context, dataAccess, csvWriterFactory);

            await Assert.ThrowsAsync<SecurityException>(() => handler.HandleAsync(A.Dummy<FetchInvoiceRunCsv>()));
        }
Пример #3
0
        public async Task HandleAsync_ReturnsFileContent()
        {
            var authorization    = new AuthorizationBuilder().AllowInternalAreaAccess().Build();
            var context          = A.Dummy <WeeeContext>();
            var dataAccess       = A.Dummy <ICommonDataAccess>();
            var csvWriterFactory = A.Dummy <CsvWriterFactory>();

            var handler = new FetchInvoiceRunCsvHandler(authorization, context, dataAccess, csvWriterFactory);

            var data = await handler.HandleAsync(A.Dummy <FetchInvoiceRunCsv>());

            Assert.NotEmpty(data.FileContent);
        }
        public async Task HandleAsync_ReturnsFileContent()
        {
            var authorization = new AuthorizationBuilder().AllowInternalAreaAccess().Build();
            var context = A.Dummy<WeeeContext>();
            var dataAccess = A.Dummy<ICommonDataAccess>();
            var csvWriterFactory = A.Dummy<CsvWriterFactory>();

            var handler = new FetchInvoiceRunCsvHandler(authorization, context, dataAccess, csvWriterFactory);

            var data = await handler.HandleAsync(A.Dummy<FetchInvoiceRunCsv>());

            Assert.NotEmpty(data.FileContent);
        }
        public async Task HandleAsync_ReturnsFileNameWithInvoiceIssuedDateAndAA()
        {
            var authorization = new AuthorizationBuilder().AllowInternalAreaAccess().Build();
            var context = A.Dummy<WeeeContext>();
            var dataAccess = A.Fake<ICommonDataAccess>();
            var csvWriterFactory = A.Dummy<CsvWriterFactory>();

            var handler = new FetchInvoiceRunCsvHandler(authorization, context, dataAccess, csvWriterFactory);

            var invoiceRun = A.Fake<InvoiceRun>();
            A.CallTo(() => invoiceRun.CompetentAuthority)
                .Returns(new UKCompetentAuthority(Guid.NewGuid(), "Wales", "NRW", A.Dummy<Country>(), "*****@*****.**"));
            A.CallTo(() => invoiceRun.IssuedDate)
                .Returns(new DateTime(2016, 02, 25));

            A.CallTo(() => dataAccess.FetchInvoiceRunAsync(A<Guid>._))
                .Returns(invoiceRun);

            var data = await handler.HandleAsync(A.Dummy<FetchInvoiceRunCsv>());

            Assert.Equal("invoicerun_NRW_25022016.csv", data.FileName);
        }
Пример #6
0
        public async Task HandleAsync_ReturnsFileNameWithInvoiceIssuedDateAndAA()
        {
            var authorization    = new AuthorizationBuilder().AllowInternalAreaAccess().Build();
            var context          = A.Dummy <WeeeContext>();
            var dataAccess       = A.Fake <ICommonDataAccess>();
            var csvWriterFactory = A.Dummy <CsvWriterFactory>();

            var handler = new FetchInvoiceRunCsvHandler(authorization, context, dataAccess, csvWriterFactory);

            var invoiceRun = A.Fake <InvoiceRun>();

            A.CallTo(() => invoiceRun.CompetentAuthority)
            .Returns(new UKCompetentAuthority(Guid.NewGuid(), "Wales", "NRW", A.Dummy <Country>(), "*****@*****.**", 0));
            A.CallTo(() => invoiceRun.IssuedDate)
            .Returns(new DateTime(2016, 02, 25));

            A.CallTo(() => dataAccess.FetchInvoiceRunAsync(A <Guid> ._))
            .Returns(invoiceRun);

            var data = await handler.HandleAsync(A.Dummy <FetchInvoiceRunCsv>());

            Assert.Equal("invoicerun_NRW_25022016.csv", data.FileName);
        }