public async Task GetPublicOrganisationInfoHandler_HappyPath_ReturnsPublicOrganisationInfo() { var organisationId = Guid.NewGuid(); var context = A.Fake <WeeeContext>(); A.CallTo(() => context.Organisations).Returns(dbHelper.GetAsyncEnabledDbSet(new List <Organisation> { GetOrganisationWithId(organisationId) })); var expectedReturnValue = new PublicOrganisationData(); Organisation mappedOrganisation = null; var publicOrganisationMap = A.Fake <IMap <Organisation, PublicOrganisationData> >(); A.CallTo(() => publicOrganisationMap.Map(A <Organisation> ._)) .Invokes((Organisation o) => mappedOrganisation = o) .Returns(expectedReturnValue); var handler = new GetPublicOrganisationInfoHandler(context, publicOrganisationMap); var message = new GetPublicOrganisationInfo(organisationId); var result = await handler.HandleAsync(message); Assert.NotNull(mappedOrganisation); Assert.Equal(organisationId, mappedOrganisation.Id); Assert.Same(expectedReturnValue, result); }
public async Task GetPublicOrganisationInfoHandler_OrganisationNotAvailable_ThrowsArgumentException() { var organisationId = Guid.NewGuid(); var context = A.Fake <WeeeContext>(); A.CallTo(() => context.Organisations).Returns(dbHelper.GetAsyncEnabledDbSet(new List <Organisation>())); var handler = new GetPublicOrganisationInfoHandler(context, A.Dummy <PublicOrganisationMap>()); var message = new GetPublicOrganisationInfo(organisationId); await Assert.ThrowsAsync <ArgumentException>(async() => await handler.HandleAsync(message)); }