Ejemplo n.º 1
0
        public async Task HandleAsync_GivenAddReturnRequest_DataAccessSubmitsIsCalled(QuarterType quarterType, FacilityType facility)
        {
            var request = new AddReturn {
                OrganisationId = Guid.NewGuid(), Quarter = quarterType, Year = year, FacilityType = Core.AatfReturn.FacilityType.Aatf
            };

            var @return      = A.Dummy <Return>();
            var organisation = new Organisation();
            var userId       = Guid.NewGuid();

            A.CallTo(() => userContext.UserId).Returns(userId);
            A.CallTo(() => genericDataAccess.GetById <Organisation>(request.OrganisationId)).Returns(organisation);
            A.CallTo(() => returnFactory.GetReturnQuarter(A <Guid> ._, A <FacilityType> ._)).Returns(new Quarter(year, quarterType));

            await handler.HandleAsync(request);

            A.CallTo(() => returnDataAccess.Submit(A <Return> .That.Matches(c => c.Quarter.Year == request.Year && (int)c.Quarter.Q == (int)quarterType && c.Organisation.Equals(organisation) && c.CreatedById.Equals(userId.ToString())))).MustHaveHappened(Repeated.Exactly.Once);
        }
Ejemplo n.º 2
0
        public async Task <Guid> HandleAsync(AddReturn message)
        {
            authorization.EnsureCanAccessExternalArea();
            authorization.EnsureOrganisationAccess(message.OrganisationId);

            await ValidateReturnMessage(message);

            var quarter = new Quarter(message.Year, (QuarterType)message.Quarter);

            var aatfOrganisation = await genericDataAccess.GetById <Organisation>(message.OrganisationId);

            var type = Enumeration.FromValue <EA.Weee.Domain.AatfReturn.FacilityType>((int)message.FacilityType);

            var aatfReturn = new Return(aatfOrganisation, quarter, userContext.UserId.ToString(), type);

            await returnDataAccess.Submit(aatfReturn);

            return(aatfReturn.Id);
        }