コード例 #1
0
        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);
                }
            }
        }
コード例 #2
0
 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));
 }
コード例 #3
0
        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));
        }
コード例 #4
0
 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));
 }
コード例 #5
0
 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));
 }
コード例 #6
0
 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));
 }
コード例 #7
0
 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));
 }
コード例 #8
0
        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));
        }
コード例 #9
0
        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));
        }
コード例 #10
0
 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));
 }
コード例 #11
0
 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));
 }
コード例 #12
0
ファイル: CarrierController.cs プロジェクト: DEFRA/prsd-iws
        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));
        }
コード例 #13
0
        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));
        }
コード例 #14
0
 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));
 }
コード例 #15
0
        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));
        }
コード例 #16
0
        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 }));
        }
コード例 #17
0
        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));
        }
コード例 #18
0
        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));
        }
コード例 #19
0
        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));
        }
コード例 #20
0
        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);
        }