protected async Task AddAuditEntries(WasteCodeDataAndNotificationData existingData, BaseWasteCodeViewModel viewModel, Guid id, NotificationAuditScreenType screenType) { if (!existingData.NotificationWasteCodeData[codeType].Any()) { await AuditService.AddAuditEntry(Mediator, id, User.GetUserId(), NotificationAuditType.Added, screenType); } else { if (CodeBeenRemoved(viewModel, existingData)) { await AuditService.AddAuditEntry(Mediator, id, User.GetUserId(), NotificationAuditType.Deleted, screenType); } if (CodeBeenAdded(viewModel, existingData)) { await AuditService.AddAuditEntry(Mediator, id, User.GetUserId(), NotificationAuditType.Updated, screenType); } } }
public ReasonForExportControllerTests() { this.mediator = A.Fake <IMediator>(); this.auditService = A.Fake <IAuditService>(); reasonForExportController = new ReasonForExportController(A.Fake <IMediator>(), this.auditService); A.CallTo(() => auditService.AddAuditEntry(this.mediator, notificationId, "user", NotificationAuditType.Added, NotificationAuditScreenType.ReasonForExport)); }
public FacilityControllerTests() { mediator = A.Fake <IMediator>(); this.auditService = A.Fake <IAuditService>(); A.CallTo(() => mediator.SendAsync(A <GetCountries> ._)).Returns(new List <CountryData> { new CountryData { Id = new Guid("4345FB05-F7DF-4E16-939C-C09FCA5C7D7B"), Name = "United Kingdom" }, new CountryData { Id = new Guid("29B0D09E-BA77-49FB-AF95-4171408C07C9"), Name = "Germany" } }); A.CallTo( () => mediator.SendAsync(A <GetNotificationBasicInfo> .That.Matches(p => p.NotificationId == notificationId))) .Returns(new NotificationBasicInfo { CompetentAuthority = UKCompetentAuthority.England, NotificationId = notificationId, NotificationNumber = "GB 0001 002000", NotificationType = NotificationType.Recovery }); facilityController = new FacilityController(mediator, new AddAddressBookEntryMap(), this.auditService); A.CallTo(() => auditService.AddAuditEntry(this.mediator, notificationId, "user", NotificationAuditType.Added, NotificationAuditScreenType.RecoveryFacilities)); }
public WasteGenerationProcessControllerTests() { this.mediator = A.Fake <IMediator>(); this.auditService = A.Fake <IAuditService>(); wasteGenerationProcessController = new WasteGenerationProcessController(A.Fake <IMediator>(), this.auditService); A.CallTo(() => auditService.AddAuditEntry(this.mediator, notificationId, "user", NotificationAuditType.Added, NotificationAuditScreenType.ProcessOfGeneration)); }
public SpecialHandlingControllerTests() { this.mediator = A.Fake <IMediator>(); this.auditService = A.Fake <IAuditService>(); specialHandlingController = new SpecialHandlingController(A.Fake <IMediator>(), this.auditService); A.CallTo(() => auditService.AddAuditEntry(this.mediator, notificationId, "user", NotificationAuditType.Added, NotificationAuditScreenType.SpecialHandling)); }
public PackagingTypesControllerTests() { this.mediator = A.Fake <IMediator>(); this.auditService = A.Fake <IAuditService>(); packagingTypesController = new PackagingTypesController(A.Fake <IMediator>(), this.auditService); A.CallTo(() => auditService.AddAuditEntry(this.mediator, notificationId, "user", NotificationAuditType.Added, NotificationAuditScreenType.PackagingTypes)); }
public ShipmentControllerTests() { this.mediator = A.Fake <IMediator>(); this.auditService = A.Fake <IAuditService>(); shipmentController = new ShipmentController(A.Fake <IMediator>(), this.auditService); A.CallTo(() => auditService.AddAuditEntry(this.mediator, notificationId, "user", NotificationAuditType.Added, NotificationAuditScreenType.AmountsAndDates)); }
public TransitStateControllerTests() { mediator = A.Fake <IMediator>(); this.auditService = A.Fake <IAuditService>(); var competentAuthorties = new[] { new CompetentAuthorityData { Id = environmentAgency.Id, Name = anyString } }; var entryOrExitPoints = new[] { new EntryOrExitPointData { Id = hull.Id, CountryId = hull.CountryId, Name = anyString } }; A.CallTo( () => mediator.SendAsync(A <GetTransitAuthoritiesAndEntryOrExitPointsByCountryId> .That.Matches(s => s.Id == hull.CountryId))) .Returns(new CompetentAuthorityAndEntryOrExitPointData() { CompetentAuthorities = competentAuthorties, EntryOrExitPoints = entryOrExitPoints }); transitStateController = new TransitStateController(mediator, new TestMap(), this.auditService); A.CallTo(() => auditService.AddAuditEntry(this.mediator, notificationId, "user", NotificationAuditType.Added, NotificationAuditScreenType.Transits)); }
public StateOfExportControllerTests() { mediator = A.Fake <IMediator>(); this.auditService = A.Fake <IAuditService>(); var competentAuthorties = new[] { new CompetentAuthorityData { Id = anyCompetentAuthorityId, Name = anyString } }; var entryOrExitPoints = new[] { new EntryOrExitPointData { Id = anyEntryOrExitPointId, CountryId = anyCountryId, Name = anyString } }; A.CallTo( () => mediator.SendAsync(A <GetCompetentAuthoritiesAndEntryOrExitPointsByCountryId> .That.Matches(s => s.Id == anyCountryId))) .Returns(new CompetentAuthorityAndEntryOrExitPointData() { CompetentAuthorities = competentAuthorties, EntryOrExitPoints = entryOrExitPoints }); stateOfExportController = new StateOfExportController(mediator, new TestMap(), this.auditService); A.CallTo( () => mediator.SendAsync(A <GetStateOfExportWithTransportRouteDataByNotificationId> .That.Matches(s => s.Id == notificationId))) .Returns(new StateOfExportWithTransportRouteData() { StateOfExport = new StateOfExportData() }); A.CallTo(() => auditService.AddAuditEntry(this.mediator, notificationId, "user", NotificationAuditType.Added, NotificationAuditScreenType.ExportRoute)); }
public PhysicalCharacteristicsControllerTests() { this.mediator = A.Fake <IMediator>(); this.auditService = A.Fake <IAuditService>(); physicalCharacteristicsController = new PhysicalCharacteristicsController(this.mediator, this.auditService); A.CallTo(() => auditService.AddAuditEntry(this.mediator, notificationId, "user", NotificationAuditType.Added, NotificationAuditScreenType.PhysicalCharacteristics)); }
public WasteRecoveryControllerTests() { mediator = A.Fake <IMediator>(); auditService = A.Fake <IAuditService>(); controller = new WasteRecoveryController(mediator, auditService); A.CallTo(() => auditService.AddAuditEntry(this.mediator, notificationId, "user", NotificationAuditType.Added, NotificationAuditScreenType.WasteRecovery)); }
public async Task <ActionResult> Add(AddCarrierViewModel model) { if (!ModelState.IsValid) { await this.BindCountryList(mediator); return(View(model)); } try { await mediator.SendAsync(model.ToRequest()); await auditService.AddAuditEntry(mediator, model.NotificationId, User.GetUserId(), NotificationAuditType.Added, NotificationAuditScreenType.IntendedCarrier); return(RedirectToAction("Index", "Overview")); } catch (ApiBadRequestException ex) { this.HandleBadRequest(ex); if (ModelState.IsValid) { throw; } } await this.BindCountryList(mediator); return(View(model)); }
public CarrierControllerTests() { mediator = A.Fake <IMediator>(); this.auditService = A.Fake <IAuditService>(); A.CallTo(() => mediator.SendAsync(A <GetCountries> ._)).Returns(new List <CountryData> { new CountryData { Id = new Guid("4345FB05-F7DF-4E16-939C-C09FCA5C7D7B"), Name = "United Kingdom" }, new CountryData { Id = new Guid("29B0D09E-BA77-49FB-AF95-4171408C07C9"), Name = "Germany" } }); A.CallTo( () => mediator.SendAsync(A <GetCarrierForNotification> .That.Matches(p => p.CarrierId == carrierId))) .Returns(CreateCarrier(carrierId)); carrierController = new CarrierController(mediator, new AddAddressBookEntryMap(), this.auditService); A.CallTo(() => auditService.AddAuditEntry(this.mediator, notificationId, "user", NotificationAuditType.Added, NotificationAuditScreenType.IntendedCarrier)); }
public ImporterControllerTests() { this.mediator = A.Fake <IMediator>(); this.auditService = A.Fake <IAuditService>(); importerController = new ImporterController(A.Fake <IMediator>(), A.Fake <IMapWithParameter <ImporterViewModel, AddressRecordType, AddAddressBookEntry> >(), this.auditService); A.CallTo(() => auditService.AddAuditEntry(this.mediator, notificationId, "user", NotificationAuditType.Added, NotificationAuditScreenType.Importer)); }
public ExporterControllerTests() { client = A.Fake <IMediator>(); auditService = A.Fake <IAuditService>(); exporterController = new ExporterController(client, new AddAddressBookEntryMap(), auditService); A.CallTo(() => auditService.AddAuditEntry(client, notificationId, "user", NotificationAuditType.Added, NotificationAuditScreenType.Exporter)); }
public async Task <ActionResult> TransitEntryPoint(Guid id, Guid transitStateId, TransitEntryPointViewModel model) { if (!ModelState.IsValid) { return(await TransitEntryPoint(id, transitStateId)); } await mediator.SendAsync(new UpdateTransitStateEntryOrExit(id, transitStateId, model.SelectedEntryPoint, null)); await auditService.AddAuditEntry(mediator, id, User.GetUserId(), NotificationAuditType.Updated, NotificationAuditScreenType.Transits); return(RedirectToAction("TransitEntryPointChanged", new { id, transitStateId })); }
public WasteOperationsControllerTests() { this.mediator = A.Fake <IMediator>(); this.auditService = A.Fake <IAuditService>(); wasteOperationsController = new WasteOperationsController(mediator, this.auditService); A.CallTo(() => mediator.SendAsync(A <SetTechnologyEmployed> .Ignored)) .Returns(Guid.Empty); A.CallTo(() => auditService.AddAuditEntry(this.mediator, notificationId, "user", NotificationAuditType.Added, NotificationAuditScreenType.RecoveryCodes)); }
public BaseWasteCodeControllerTests() { this.mediator = A.Fake <IMediator>(); this.auditService = A.Fake <IAuditService>(); controller = new TestController(mediator, CodeType.Y, this.auditService); viewModel = new TestViewModel { EnterWasteCodesViewModel = new EnterWasteCodesViewModel { SelectedWasteCodes = selectedCodes } }; A.CallTo(() => auditService.AddAuditEntry(this.mediator, AnyGuid, "user", NotificationAuditType.Added, NotificationAuditScreenType.BaselOecdCodes)); }
public ChemicalCompositionControllerTests() { mediator = A.Fake <IMediator>(); this.auditService = A.Fake <IAuditService>(); chemicalCompositionController = new ChemicalCompositionController(mediator, new ChemicalCompositionMap(), this.auditService); A.CallTo( () => mediator.SendAsync(A <GetWasteType> .That.Matches(p => p.NotificationId == notificationId))) .Returns(new WasteTypeData() { WasteCompositionData = new List <WasteCompositionData>() { A.Fake <WasteCompositionData>() } }); A.CallTo( () => mediator.SendAsync(A <GetNotificationAuditTable> .That.Matches (p => p.NotificationId == notificationId))) .Returns(CreateTestAuditTable()); A.CallTo(() => auditService.AddAuditEntry(this.mediator, notificationId, "user", NotificationAuditType.Added, NotificationAuditScreenType.ChemicalComposition)); }
public async Task Exporter_AddExporter_AuditMustBeCalled() { await auditService.AddAuditEntry(this.mediator, notificationId, userId.ToString(), NotificationAuditType.Added, NotificationAuditScreenType.Exporter); A.CallTo(() => mediator.SendAsync(A <CreateNotificationAudit> .Ignored)).MustHaveHappened(Repeated.AtLeast.Once); }