Esempio n. 1
0
        public async Task <DataReturnUploadInfo> HandleAsync(GetUploadInfoByDataReturnUploadId message)
        {
            DataReturnUpload dataReturnUpload = await dataAccess.FetchDataReturnUploadByIdAsync(message.DataReturnUploadId);

            authorization.EnsureSchemeAccess(dataReturnUpload.Scheme.Id);

            var quarter = new DataReturnUploadInfo
            {
                Quarter = (QuarterType?)dataReturnUpload.Quarter,
                Year    = dataReturnUpload.ComplianceYear
            };

            return(quarter);
        }
        public async Task HandleAsync_Happypath_ReturnsQuarterInfo()
        {
            DataReturnUpload dataReturnsUpload = new DataReturnUpload(
                A.Dummy <Scheme>(),
                A.Dummy <string>(),
                new List <DataReturnUploadError>(),
                A.Dummy <string>(),
                2016,
                1);

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

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

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

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

            var result = await handler.HandleAsync(request);

            Assert.Equal(2016, result.Year);
            Assert.Equal(1, (int)result.Quarter.Value);
        }