public async Task HandleAsync_GivenReturn_ReturnStatusShouldBeMapped() { var message = new GetReturnStatus(Guid.NewGuid()); var @return = GetReturn(); A.CallTo(() => returnDataAccess.GetById(message.ReturnId)).Returns(@return); await handler.HandleAsync(message); A.CallTo(() => mapper.Map <EA.Weee.Core.AatfReturn.ReturnStatus>(@return.ReturnStatus)).MustHaveHappened(Repeated.Exactly.Once); }
public async Task HandleAsync_GivenReturnId_ReturnShouldBeRetrieved() { var message = new GetReturnStatus(Guid.NewGuid()); var @return = GetReturn(); A.CallTo(() => returnDataAccess.GetById(message.ReturnId)).Returns(@return); await handler.HandleAsync(message); A.CallTo(() => returnDataAccess.GetById(message.ReturnId)).MustHaveHappened(Repeated.Exactly.Once); }
public async Task HandleAsync_GivenNoOtherCreatedReturnsInYearAndQuarter_OtherInProgressReturnShouldBeFalse() { var message = new GetReturnStatus(Guid.NewGuid()); var @return = A.Fake <Return>(); A.CallTo(() => returnDataAccess.GetById(A <Guid> ._)).Returns(@return); A.CallTo(() => returnDataAccess.GetByComplianceYearAndQuarter(@return)).Returns(new List <Return>()); var result = await handler.HandleAsync(message); result.OtherInProgressReturn.Should().BeFalse(); }
public async Task HandleAsync_GivenReturnOrganisation_OrganisationIdShouldBeReturned() { var organisationId = Guid.NewGuid(); var message = new GetReturnStatus(Guid.NewGuid()); var @return = A.Fake <Return>(); var organisation = A.Fake <Organisation>(); A.CallTo(() => @return.Organisation).Returns(organisation); A.CallTo(() => organisation.Id).Returns(organisationId); A.CallTo(() => returnDataAccess.GetById(message.ReturnId)).Returns(@return); var result = await handler.HandleAsync(message); result.OrganisationId.Should().Be(organisationId); }
public async Task HandleAsync_GivenReturnStatus_MappedReturnStatusShouldBeReturned() { var message = new GetReturnStatus(Guid.NewGuid()); var @return = GetReturn(); foreach (var enumVar in Enum.GetValues(typeof(EA.Weee.Core.AatfReturn.ReturnStatus))) { A.CallTo(() => returnDataAccess.GetById(message.ReturnId)).Returns(@return); A.CallTo(() => mapper.Map <EA.Weee.Core.AatfReturn.ReturnStatus>(A <ReturnStatus> ._)).Returns((EA.Weee.Core.AatfReturn.ReturnStatus)enumVar); var result = await handler.HandleAsync(message); result.ReturnStatus.Should().Be((EA.Weee.Core.AatfReturn.ReturnStatus)enumVar); } }