public async Task HandleAsync_NoAccessToScheme_ThrowsSecurityException()
        {
            var authorization = new AuthorizationBuilder().DenySchemeAccess().Build();

            var handler = new FetchDataReturnForSubmissionHandler(authorization, A.Dummy<IFetchDataReturnForSubmissionDataAccess>());

            await Assert.ThrowsAsync<SecurityException>(() => handler.HandleAsync(A.Dummy<Requests.DataReturns.FetchDataReturnForSubmission>()));
        }
Пример #2
0
        public async Task HandleAsync_NoAccessToScheme_ThrowsSecurityException()
        {
            var authorization = new AuthorizationBuilder().DenySchemeAccess().Build();

            var handler = new FetchDataReturnForSubmissionHandler(authorization, A.Dummy <IFetchDataReturnForSubmissionDataAccess>());

            await Assert.ThrowsAsync <SecurityException>(() => handler.HandleAsync(A.Dummy <Requests.DataReturns.FetchDataReturnForSubmission>()));
        }
Пример #3
0
        public async Task HandleAsync_ForDataReturnWithMultipleErrors_ReturnsErrorsByLineNumberOrder()
        {
            // Arrange
            DataReturnUpload dataReturnsUpload = new DataReturnUpload(
                A.Dummy <Scheme>(),
                A.Dummy <string>(),
                new List <DataReturnUploadError>()
            {
                new DataReturnUploadError(ErrorLevel.Error, UploadErrorType.Schema, "Error on 55 line no", 55),
                new DataReturnUploadError(ErrorLevel.Error, UploadErrorType.Schema, "Error on 5 line no", 5),
                new DataReturnUploadError(ErrorLevel.Error, UploadErrorType.Schema, "Error on 75 line no", 75),
                new DataReturnUploadError(ErrorLevel.Error, UploadErrorType.Schema, "Error without line no")
            },
                A.Dummy <string>(),
                A.Dummy <int>(),
                A.Dummy <int>());

            IFetchDataReturnForSubmissionDataAccess dataAccess = A.Fake <IFetchDataReturnForSubmissionDataAccess>();

            A.CallTo(() => dataAccess.FetchDataReturnUploadAsync(A <Guid> ._)).Returns(dataReturnsUpload);

            FetchDataReturnForSubmissionHandler handler = new FetchDataReturnForSubmissionHandler(
                A.Dummy <IWeeeAuthorization>(),
                dataAccess);

            Requests.DataReturns.FetchDataReturnForSubmission request = new Requests.DataReturns.FetchDataReturnForSubmission(
                A.Dummy <Guid>());

            // Act
            DataReturnForSubmission result = await handler.HandleAsync(request);

            // Assert
            Assert.Equal(4, result.Errors.Count);
            Assert.True(result.Errors.ElementAt(0).Description == "Error without line no" &&
                        result.Errors.ElementAt(1).Description == "Error on 5 line no" &&
                        result.Errors.ElementAt(2).Description == "Error on 55 line no" &&
                        result.Errors.ElementAt(3).Description == "Error on 75 line no");
        }
        public async Task HandleAsync_ForDataReturnWithOneErrorWithErrorLevelWarning_ReturnsDtoWithOneWarning()
        {
            // Arrange
            DataReturnUploadError dataReturnsUploadWarning = new DataReturnUploadError(
                ErrorLevel.Warning,
                UploadErrorType.Business,
                A.Dummy<string>());

            IFetchDataReturnForSubmissionDataAccess dataAccess = FetchDummyDataReturnWithWarning(dataReturnsUploadWarning);

            FetchDataReturnForSubmissionHandler handler = new FetchDataReturnForSubmissionHandler(
                A.Dummy<IWeeeAuthorization>(),
                dataAccess);

            Requests.DataReturns.FetchDataReturnForSubmission request = new Requests.DataReturns.FetchDataReturnForSubmission(
                A.Dummy<Guid>());

            // Act
            DataReturnForSubmission result = await handler.HandleAsync(request);

            // Assert
            Assert.Equal(1, result.Warnings.Count);
        }
Пример #5
0
        public async Task HandleAsync_ForDataReturnWithOneErrorWithErrorLevelWarning_ReturnsDtoWithOneWarning()
        {
            // Arrange
            DataReturnUploadError dataReturnsUploadWarning = new DataReturnUploadError(
                ErrorLevel.Warning,
                UploadErrorType.Business,
                A.Dummy <string>());

            IFetchDataReturnForSubmissionDataAccess dataAccess = FetchDummyDataReturnWithWarning(dataReturnsUploadWarning);

            FetchDataReturnForSubmissionHandler handler = new FetchDataReturnForSubmissionHandler(
                A.Dummy <IWeeeAuthorization>(),
                dataAccess);

            Requests.DataReturns.FetchDataReturnForSubmission request = new Requests.DataReturns.FetchDataReturnForSubmission(
                A.Dummy <Guid>());

            // Act
            DataReturnForSubmission result = await handler.HandleAsync(request);

            // Assert
            Assert.Equal(1, result.Warnings.Count);
        }
        public async Task HandleAsync_ForDataReturnWithMultipleErrors_ReturnsErrorsByLineNumberOrder()
        {
            // Arrange
            DataReturnUpload dataReturnsUpload = new DataReturnUpload(
                A.Dummy<Scheme>(),
                A.Dummy<string>(),
                new List<DataReturnUploadError>()
                {
                  new DataReturnUploadError(ErrorLevel.Error, UploadErrorType.Schema, "Error on 55 line no", 55),
                  new DataReturnUploadError(ErrorLevel.Error, UploadErrorType.Schema, "Error on 5 line no", 5),
                  new DataReturnUploadError(ErrorLevel.Error, UploadErrorType.Schema, "Error on 75 line no", 75),
                  new DataReturnUploadError(ErrorLevel.Error, UploadErrorType.Schema, "Error without line no")
                },
                A.Dummy<string>(),
                A.Dummy<int>(),
                A.Dummy<int>());

            IFetchDataReturnForSubmissionDataAccess dataAccess = A.Fake<IFetchDataReturnForSubmissionDataAccess>();
            A.CallTo(() => dataAccess.FetchDataReturnUploadAsync(A<Guid>._)).Returns(dataReturnsUpload);

            FetchDataReturnForSubmissionHandler handler = new FetchDataReturnForSubmissionHandler(
                A.Dummy<IWeeeAuthorization>(),
                dataAccess);

            Requests.DataReturns.FetchDataReturnForSubmission request = new Requests.DataReturns.FetchDataReturnForSubmission(
                A.Dummy<Guid>());

            // Act
            DataReturnForSubmission result = await handler.HandleAsync(request);

            // Assert
            Assert.Equal(4, result.Errors.Count);
            Assert.True(result.Errors.ElementAt(0).Description == "Error without line no"
                && result.Errors.ElementAt(1).Description == "Error on 5 line no"
                && result.Errors.ElementAt(2).Description == "Error on 55 line no"
                && result.Errors.ElementAt(3).Description == "Error on 75 line no");
        }