public async void GetSchemeByIdHandler_WithUnknownId_ThrowsArgumentException() { // Arrage Guid badSchemeId = new Guid("88C60FAC-1172-43F2-9AA5-7E79A8877F92"); ISchemeDataAccess dataAccess = A.Fake <ISchemeDataAccess>(); A.CallTo(() => dataAccess.GetSchemeOrDefault(badSchemeId)).Returns((Scheme)null); IWeeeAuthorization authorization = new AuthorizationBuilder() .AllowInternalAreaAccess() .Build(); var mapper = A.Fake <IMapper>(); GetSchemeByIdHandler handler = new GetSchemeByIdHandler(dataAccess, mapper, authorization); GetSchemeById request = new GetSchemeById(badSchemeId); // Act Func <Task <SchemeData> > action = () => handler.HandleAsync(request); // Assert await Assert.ThrowsAsync <ArgumentException>(action); }
public GetMemberRegistrationSchemesByComplianceYearHandler(IWeeeAuthorization authorization, IMap <Scheme, SchemeData> schemeMap, WeeeContext context, ISchemeDataAccess schemeDataAccess) { this.authorization = authorization; this.schemeMap = schemeMap; this.context = context; this.schemeDataAccess = schemeDataAccess; }
public AddReturnSchemeHandler(IWeeeAuthorization authorization, IReturnSchemeDataAccess returnSchemeDataAccess, IReturnDataAccess returnDataAccess, ISchemeDataAccess schemeDataAccess) { this.authorization = authorization; this.returnSchemeDataAccess = returnSchemeDataAccess; this.returnDataAccess = returnDataAccess; this.schemeDataAccess = schemeDataAccess; }
public async void GetSchemeByIdHandler_WithNonInternalUser_ThrowsSecurityException(AuthorizationBuilder.UserType userType) { // Arrage Guid schemeId = new Guid("AC9116BC-5732-4F80-9AED-A6E2A0C4C1F1"); ISchemeDataAccess dataAccess = A.Fake <ISchemeDataAccess>(); Scheme scheme = A.Fake <Scheme>(); A.CallTo(() => dataAccess.GetSchemeOrDefault(schemeId)).Returns(scheme); IWeeeAuthorization authorization = AuthorizationBuilder.CreateFromUserType(userType); var mapper = A.Fake <IMapper>(); SchemeData schemeData = A.Fake <SchemeData>(); A.CallTo(() => mapper.Map <Scheme, SchemeData>(scheme)) .Returns(schemeData); GetSchemeByIdHandler handler = new GetSchemeByIdHandler(dataAccess, mapper, authorization); GetSchemeById request = new GetSchemeById(schemeId); // Act Func <Task <SchemeData> > action = () => handler.HandleAsync(request); // Assert await Assert.ThrowsAsync <SecurityException>(action); }
public async void GetSchemeByIdHandler_HappyPath_ReturnsSchemeData() { // Arrage Guid schemeId = new Guid("AC9116BC-5732-4F80-9AED-A6E2A0C4C1F1"); ISchemeDataAccess dataAccess = A.Fake <ISchemeDataAccess>(); Scheme scheme = A.Fake <Scheme>(); A.CallTo(() => dataAccess.GetSchemeOrDefault(schemeId)).Returns(scheme); IWeeeAuthorization authorization = new AuthorizationBuilder() .AllowInternalAreaAccess() .Build(); var mapper = A.Fake <IMapper>(); SchemeData schemeData = A.Fake <SchemeData>(); A.CallTo(() => mapper.Map <Scheme, SchemeData>(scheme)) .Returns(schemeData); GetSchemeByIdHandler handler = new GetSchemeByIdHandler(dataAccess, mapper, authorization); GetSchemeById request = new GetSchemeById(schemeId); // Act SchemeData result = await handler.HandleAsync(request); // Assert Assert.Equal(schemeData, result); }
public GetSchemeByIdHandler(ISchemeDataAccess dataAccess, IMapper mapper, IWeeeAuthorization authorization) { this.dataAccess = dataAccess; this.mapper = mapper; this.authorization = authorization; }
public GetMemberRegistrationSchemesByComplianceYearHandlerTests() { this.authorization = A.Fake <IWeeeAuthorization>(); this.dataAccess = A.Fake <ISchemeDataAccess>(); this.schemeMap = A.Fake <IMap <Scheme, SchemeData> >(); this.context = A.Fake <WeeeContext>(); handler = new GetMemberRegistrationSchemesByComplianceYearHandler(authorization, schemeMap, context, dataAccess); }
public GetSchemeByOrganisationIdHandlerTests() { authorization = AuthorizationBuilder.CreateUserAllowedToAccessOrganisation(); dataAccess = A.Fake <ISchemeDataAccess>(); mapper = A.Fake <IMapper>(); handler = new GetSchemeByOrganisationIdHandler(dataAccess, mapper, authorization); }
public AddReturnSchemeHandlerTests() { fixture = new Fixture(); var weeeAuthorization = A.Fake <IWeeeAuthorization>(); returnSchemeDataAccess = A.Fake <IReturnSchemeDataAccess>(); schemeDataAccess = A.Fake <ISchemeDataAccess>(); returnDataAccess = A.Fake <IReturnDataAccess>(); handler = new AddReturnSchemeHandler(weeeAuthorization, returnSchemeDataAccess, returnDataAccess, schemeDataAccess); }
public GetSchemePublicInfoBySchemeIdHandler(ISchemeDataAccess dataAccess) { this.dataAccess = dataAccess; }