public void ClassSetUp()
        {
            _factory = new MockRepository(MockBehavior.Loose);

            _reportsUnitOfWork       = _factory.Create <IReportsUnitOfWork>();
            _summariesUnitOfWork     = _factory.Create <ISummariesUnitOfWork>();
            _classicImagesRepository = _factory.Create <IClassicImagesRepository>();
            _reportDerived           = new ReportDerived(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), ModuleType.Incident, true);
            _case                       = new Domain.Summaries.Case.Case(Guid.NewGuid(), Guid.NewGuid(), "number");
            _summaryDerived             = new SummaryDerived(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), ModuleType.Incident, "number", _case);
            _reportAttachment           = new ReportAttachment(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid());
            _reportAttachment.FileName  = FileName;
            _reportAttachment.Source    = "InformRMSWeb";
            _summaryAttachment          = new SummaryAttachment(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid());
            _summaryAttachment.FileName = FileName;
            _summaryAttachment.Source   = "InformRMSWeb";
            _reportsUnitOfWork.Setup(mock => mock.Find <ReportAttachment>(It.IsAny <Guid>(), It.IsAny <TrackingMode>(), It.IsAny <ThrowIf>()))
            .Returns(_reportAttachment);

            _reportsUnitOfWork.Setup(mock => mock.Find <Report>(It.IsAny <Guid>(), It.IsAny <TrackingMode>(), It.IsAny <ThrowIf>()))
            .Returns(_reportDerived);
            _summariesUnitOfWork.Setup(mock => mock.Find <Summary>(It.IsAny <Guid>(), It.IsAny <TrackingMode>(), It.IsAny <ThrowIf>()))
            .Returns(_summaryDerived);
            _summariesUnitOfWork.Setup(mock => mock.Find <SummaryAttachment>(It.IsAny <Guid>(), It.IsAny <TrackingMode>(), It.IsAny <ThrowIf>()))
            .Returns(_summaryAttachment);
            _attachmentQueryService = new AttachmentQueryService(_reportsUnitOfWork.Object, _summariesUnitOfWork.Object, _classicImagesRepository.Object, Mock.Of <ILog>(),
                                                                 Mock.Of <IServiceAuthorizationPolicy>(), Mock.Of <IServiceIdentityProvider>());
        }
Пример #2
0
        public Guid CreateCallForServiceSummary(Guid agencyId, string caseNumber, string reportNumber, CallForServiceSummaryDetails details)
        {
            // Verify that a summary doesn't already exist.
            // TODO: This throws an Exception if the ID already exists in the data store. Evaluate this usage.
            //reportNumber is the CallNumber

            EnsureNonExistingIdentifier <CallForServiceSummary>(details.Id);

            // Associate the summary with its parent Case.
            var parentCase = UnitOfWork.GetEntityQuery <Domain.Summaries.Case.Case>().FirstOrDefault(x => x.Number == caseNumber && x.AgencyId == agencyId);

            if (parentCase == null)
            {
                parentCase = new Domain.Summaries.Case.Case(IdentityId, agencyId, caseNumber);
                UnitOfWork.Add(parentCase);
            }

            // Create the summary.
            var callForServiceSummary = new CallForServiceSummary(IdentityId, agencyId, details.Id, reportNumber, parentCase);

            UnitOfWork.Add(callForServiceSummary);
            UnitOfWork.Commit();

            return(callForServiceSummary.Id);
        }
        private void DomainObjectsIntialization()
        {
            _case = new Domain.Summaries.Case.Case(_identityId, _agencyId, Number);

            _fieldInterviewSummary = new FieldInterviewSummary(_identityId, _agencyId, _fieldInterviewSummaryDetails.Id, Number, null);
            _fieldInterviewEvent   = new FieldInterviewEvent(_identityId, _agencyId, _fieldInterviewEventDetails.Id);
            _fieldInterviewSource  = new FieldInterviewSource(_identityId, _agencyId, _fieldInterviewSummaryDetails.Id);
        }
Пример #4
0
        private void SetUpCase()
        {
            var caseList    = new List <Domain.Summaries.Case.Case>();
            var caseDetails = new Domain.Summaries.Case.Case(DataEntryUnitTestFixture.IdentityId, _arrestReport.AgencyId, _arrestReport.Number);

            caseList.Add(caseDetails);
            _summariesUnitOfWork.Setup(mock => mock.GetEntityQuery <Domain.Summaries.Case.Case>(It.IsAny <TrackingMode>())).Returns(caseList.AsQueryable());
        }
        /// <summary>
        /// Build a Navigation Graph from its parts.
        /// </summary>
        /// <param name="cCase">The Case</param>
        /// <param name="summaries">The Summaries</param>
        /// <param name="reports">The Reports</param>
        /// <returns></returns>
        public static CaseNavigationGraph BuildNavigationGraph(Domain.Summaries.Case.Case cCase, List <Summary> summaries, List <Report> reports)
        {
            var graph = CreateCaseGraph(cCase);

            AddSummaryItems(graph, summaries);
            AddReportItems(graph, reports);
            return(graph);
        }
Пример #6
0
 public void ClassSetUp()
 {
     _factory             = new MockRepository(MockBehavior.Loose);
     _summariesUnitOfWork = _factory.Create <ISummariesUnitOfWork>();
     _agency           = DataEntryUnitTestFixture.AgencyDetails;
     _case             = new Domain.Summaries.Case.Case(Guid.NewGuid(), _agency.Id, CaseNumber);
     _caseQueryService = new CaseQueryService(_summariesUnitOfWork.Object, Mock.Of <ILog>(), Mock.Of <IServiceAuthorizationPolicy>(), Mock.Of <IServiceIdentityProvider>());
 }
Пример #7
0
 private void DomainObjectsIntialization()
 {
     _citationSummary         = new CitationSummary(_identityId, _agencyId, _citationSummaryDetails.Id, Number, null);
     _citationEvent           = new DomainEntities.Citation.CitationEvent(_identityId, _agencyId, _citationEventDetails.Id);
     _citationAlcoholDrugTest = new DomainEntities.Citation.CitationAlcoholDrugTest(_identityId, _agencyId, _citationAlcoholDrugTestDetails.Id);
     _citationFeesPayments    = new DomainEntities.PublicSafetyFeesPayments(_identityId, _agencyId, _citationFeesPaymentsDetails.Id);
     _case = new Domain.Summaries.Case.Case(_identityId, _agencyId, Number);
 }
Пример #8
0
 public void ClassSetUp()
 {
     _factory               = new MockRepository(MockBehavior.Loose);
     _summariesUnitOfWork   = _factory.Create <ISummariesUnitOfWork>();
     _reportsUnitOfWork     = _factory.Create <IReportsUnitOfWork>();
     _caseNavigationService = new CaseNavigationService(_reportsUnitOfWork.Object, _summariesUnitOfWork.Object, Mock.Of <ILog>(), Mock.Of <IServiceAuthorizationPolicy>(), Mock.Of <IServiceIdentityProvider>());
     _agency = DataEntryUnitTestFixture.AgencyDetails;
     _case   = new Domain.Summaries.Case.Case(Guid.NewGuid(), _agency.Id, CaseNumber);
     _summariesUnitOfWork.Setup(item => item.Find <Domain.Summaries.Case.Case>(It.IsAny <Guid>(), TrackingMode.Automatic, ThrowIf.Anything))
     .Returns(_case);
 }
 private void DomainObjectsIntialization()
 {
     _incidentSummary                 = new IncidentSummary(_identityId, _agencyId, _incidentSummaryDetails.Id, Number, null);
     _incidentEvent                   = new DomainEntities.Incident.IncidentEvent(_identityId, _agencyId, _incidentEventDetails.Id);
     _incidentPersonOther             = new DomainEntities.PublicSafetyPerson(_identityId, _agencyId, _incidentPersonOtherDetails.Id);
     _incidentOrganization            = new DomainEntities.PublicSafetyOrganization(_identityId, _agencyId, _incidentOrganizationDetails.Id);
     _incidentOffense                 = new DomainEntities.Incident.IncidentOffense(_identityId, _agencyId, _incidentOffenseDetails.Id);
     _incidentOfficerInvolvedShooting = new DomainEntities.Incident.IncidentOfficerInvolvedShooting(_identityId, _agencyId, _incidentOfficerInvolvedShootingDetails.Id);
     _incidentPersonVictim            = new DomainEntities.Incident.IncidentPersonVictim(_identityId, _agencyId, _incidentPersonVictimDetails.Id);
     _incidentPersonSuspect           = new DomainEntities.Incident.IncidentPersonSuspect(_identityId, _agencyId, _incidentPersonSuspectDetails.Id);
     _case = new Domain.Summaries.Case.Case(_identityId, _agencyId, Number);
 }
Пример #10
0
        public void DeleteCaseNote()
        {
            var caseDetails = new Domain.Summaries.Case.Case(Guid.NewGuid(), _agency.Id, CaseNumber);
            var caseNote    = caseDetails.CreateNote(Guid.NewGuid(), "Case Note Title", "Case Body");

            _summariesUnitOfWork.Setup(
                item => item.Find <CaseNote>(It.IsAny <Guid>(), TrackingMode.Automatic, ThrowIf.Anything))
            .Returns(caseNote);
            _caseCommandService.DeleteCaseNote(caseNote.Id);
            _summariesUnitOfWork.Verify(mock => mock.Remove(caseNote), Times.Once);
            _summariesUnitOfWork.Verify(mock => mock.Commit(It.IsAny <ConcurrencyMode>()), Times.Once);
        }
Пример #11
0
        public Guid CreateCase(Guid agencyId, string number, CaseDetails details)
        {
            // TODO: Permissions
            //RequireModulePermissions(agencyId, ModuleType.Case, new ModulePermissions() {CanCreate = true});

            var newCase = new Domain.Summaries.Case.Case(IdentityId, agencyId, number);

            details.MapInto(newCase);
            UnitOfWork.Add(newCase);
            UnitOfWork.Commit();

            return(newCase.Id);
        }
Пример #12
0
        public void UpdateCase()
        {
            var caseDetails = new Domain.Summaries.Case.Case(Guid.NewGuid(), _agency.Id, CaseNumber);

            _summariesUnitOfWork.Setup(
                item => item.Find <Domain.Summaries.Case.Case>(It.IsAny <Guid>(), TrackingMode.Automatic, ThrowIf.Anything))
            .Returns(caseDetails);
            var mockCaseDetails = MockObject.NewCaseDetails;

            _caseCommandService.UpdateCase(mockCaseDetails);
            mockCaseDetails.Description.Should().Be(caseDetails.Description);
            _summariesUnitOfWork.Verify(mock => mock.Commit(It.IsAny <ConcurrencyMode>()), Times.Once);
        }
Пример #13
0
        public void CreateCaseNote()
        {
            var caseDetails = new Domain.Summaries.Case.Case(Guid.NewGuid(), _agency.Id, CaseNumber);

            _summariesUnitOfWork.Setup(
                item => item.Find <Domain.Summaries.Case.Case>(It.IsAny <Guid>(), TrackingMode.Automatic, ThrowIf.Anything))
            .Returns(caseDetails);
            var newCaseNoteDetails = MockObject.NewCaseNoteDetails;
            var caseNoteId         = _caseCommandService.CreateCaseNote(caseDetails.Id, newCaseNoteDetails);

            caseNoteId.Should().NotBeEmpty();
            caseDetails.CaseNotes.Should().HaveCount(1);
            _summariesUnitOfWork.Verify(mock => mock.Commit(It.IsAny <ConcurrencyMode>()), Times.Once);
        }
Пример #14
0
        public void UpdateCaseNote()
        {
            var caseDetails = new Domain.Summaries.Case.Case(Guid.NewGuid(), _agency.Id, CaseNumber);
            var caseNote    = caseDetails.CreateNote(Guid.NewGuid(), "Case Note Title", "Case Body");

            _summariesUnitOfWork.Setup(
                item => item.Find <CaseNote>(It.IsAny <Guid>(), TrackingMode.Automatic, ThrowIf.Anything))
            .Returns(caseNote);
            var newCaseNoteDetails = MockObject.NewCaseNoteDetails;

            _caseCommandService.UpdateCaseNote(newCaseNoteDetails);
            caseNote.Title.Should().Be(newCaseNoteDetails.Title);
            caseNote.Body.Should().Be(newCaseNoteDetails.Body);
            _summariesUnitOfWork.Verify(mock => mock.Commit(It.IsAny <ConcurrencyMode>()), Times.Once);
        }
Пример #15
0
        /// <summary>
        /// Create a New Case using data from a Report.
        /// </summary>
        protected Domain.Summaries.Case.Case CreateCaseFromReport(Report report)
        {
            var newCase = new Domain.Summaries.Case.Case(report.CreatedBy, report.AgencyId, report.CaseNumber)
            {
                Description = "Case Created for " + report.ModuleType + " " + report.Number
            };

            UnitOfWork.Add(newCase);

            // Notify the System
            UnitOfWork.PendingMessages.Add(
                new SummaryCaseModified(newCase.CreatedBy, newCase.Id, report.ModuleType, newCase.GetType().Name, EventOperation.Create));

            return(newCase);
        }
Пример #16
0
        /// <summary>
        /// Create a New CaseNavigationGraph from the Case object.
        /// </summary>
        private static CaseNavigationGraph CreateCaseGraph(Domain.Summaries.Case.Case cCase)
        {
            var graph = new CaseNavigationGraph()
            {
                NavigationItems = new List <CaseNavigationItem>()
            };

            if (cCase == null)
            {
                return(graph);
            }

            graph.CaseId     = cCase.Id;
            graph.CaseNumber = cCase.Number;

            return(graph);
        }
        public void ClassSetUp()
        {
            _identityId = Guid.NewGuid();
            var identityContext = new IdentityContext()
            {
                IdentityId = Guid.NewGuid()
            };

            _authorizationPolicy = new Mock <IServiceAuthorizationPolicy>();
            _authorizationPolicy.Setup(mock => mock.RequireViewPermissions(It.IsAny <IdentityContext>(), It.IsAny <Guid>(), It.IsAny <ModuleType>()));
            _identityProvider = new Mock <IServiceIdentityProvider>();
            _identityProvider.Setup(x => x.GetPrincipalIdentifier()).Returns(identityContext.IdentityId);
            _identityProvider.Setup(x => x.GetIdentityContext()).Returns(identityContext);

            _factory = new MockRepository(MockBehavior.Loose);

            _reportDerived     = new ReportDerived(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), ModuleType.Incident, true);
            _case              = new Domain.Summaries.Case.Case(Guid.NewGuid(), Guid.NewGuid(), "number");
            _summaryDerived    = new SummaryDerived(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), ModuleType.Incident, "number", _case);
            _reportAttachment  = new ReportAttachment(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid());
            _summaryAttachment = new SummaryAttachment(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid());
            //_eventDispatcher = _factory.Create<IEventDispatcher>();
            _messageBusClient = _factory.Create <IMessageBusPublishClient>();

            //MessageBus.SetInstance( //_eventDispatcher.Object, _messageBusClient.Object );
            //_eventDispatcher.Setup( mock => mock.Publish( It.IsAny<object>() ) );
            _reportsUnitOfWork   = _factory.Create <IReportsUnitOfWork>();
            _summariesUnitOfWork = _factory.Create <ISummariesUnitOfWork>();

            _reportsUnitOfWork.Setup(mock => mock.Find <ReportAttachment>(It.IsAny <Guid>(), It.IsAny <TrackingMode>(), It.IsAny <ThrowIf>()))
            .Returns(_reportAttachment);
            _reportsUnitOfWork.Setup(mock => mock.Find <Report>(It.IsAny <Guid>(), It.IsAny <TrackingMode>(), It.IsAny <ThrowIf>()))
            .Returns(_reportDerived);
            _summariesUnitOfWork.Setup(mock => mock.Find <SummaryAttachment>(It.IsAny <Guid>(), It.IsAny <TrackingMode>(), It.IsAny <ThrowIf>()))
            .Returns(_summaryAttachment);
            _summariesUnitOfWork.Setup(mock => mock.Find <Summary>(It.IsAny <Guid>(), It.IsAny <TrackingMode>(), It.IsAny <ThrowIf>()))
            .Returns(_summaryDerived);

            _reportsUnitOfWork.Setup(x => x.PendingMessages).Returns(new System.Collections.Generic.List <TriTech.InformRMS.Infrastructure.Messaging.Contracts.Messages.Message>());
            _summariesUnitOfWork.Setup(x => x.PendingMessages).Returns(new System.Collections.Generic.List <TriTech.InformRMS.Infrastructure.Messaging.Contracts.Messages.Message>());

            _attachmentCommandService = new AttachmentCommandService(
                _reportsUnitOfWork.Object,
                _summariesUnitOfWork.Object, Mock.Of <ILog>(), _authorizationPolicy.Object, _identityProvider.Object);
        }
        public Guid CreateOtherEventSummary(Guid agencyId, string number, OtherEventSummaryDetails details)
        {
            EnsureNonExistingIdentifier <OtherEventSummary>(details.Id);  // Verify that a summary doesn't already exist.

            var parentCase = UnitOfWork.GetEntityQuery <Domain.Summaries.Case.Case>().FirstOrDefault(x => x.Number == number && x.AgencyId == agencyId);

            if (parentCase == null)
            {
                parentCase = new Domain.Summaries.Case.Case(IdentityId, agencyId, number);
                UnitOfWork.Add(parentCase);
            }

            var otherEventSummary = new OtherEventSummary(IdentityId, agencyId, details.Id, number, parentCase);

            UnitOfWork.Add(otherEventSummary);
            UnitOfWork.Commit();

            return(otherEventSummary.Id);
        }
        public void Receive_CreateSummary()
        {
            SetUpIncidentReport();
            var caseList    = new List <Domain.Summaries.Case.Case>();
            var caseDetails = new Domain.Summaries.Case.Case(DataEntryUnitTestFixture.IdentityId, _incidentReport.AgencyId, _incidentReport.Number);

            caseList.Add(caseDetails);
            _summariesUnitOfWork.Setup(mock => mock.GetEntityQuery <Domain.Summaries.Case.Case>(It.IsAny <TrackingMode>()))
            .Returns(caseList.AsQueryable());
            _summariesUnitOfWork.Setup(mock => mock.Add(It.IsAny <IncidentSummary>()));
            _log.Setup(mock => mock.Debug(It.IsAny <string>()));
            _log.Setup(mock => mock.Info(It.IsAny <string>(), It.IsAny <object>(), It.IsAny <object>()));
            //_pendingCompleteReportProcessor.MessageHandler(new ReportPendingCompleteMessage(_incidentReport.Id));
            //_attachmentReportCommandService.Verify(mock => mock.GenerateReport(It.IsAny<Guid>()), Times.Once());
            _summariesUnitOfWork.Verify(mock => mock.Commit(It.IsAny <ConcurrencyMode>()), Times.Exactly(2));
            _log.VerifyAll();
            _summariesUnitOfWork.VerifyAll();
            _masterIndexService.Verify(mock => mock.ProcessMasterIndexes(It.IsAny <IncidentSummary>()), Times.Once);
        }
Пример #20
0
        public void ClassSetUp()
        {
            _factory = new MockRepository(MockBehavior.Loose);

            _identityId = Guid.NewGuid();
            var identityContext = new IdentityContext()
            {
                IdentityId = Guid.NewGuid(), RoleIds = new List <Guid> {
                    Guid.NewGuid(), Guid.NewGuid()
                }
            };

            _authorizationPolicy = new Mock <IServiceAuthorizationPolicy>();
            _identityProvider    = new Mock <IServiceIdentityProvider>();
            _identityProvider.Setup(x => x.GetPrincipalIdentifier()).Returns(identityContext.IdentityId);
            _identityProvider.Setup(x => x.GetIdentityContext()).Returns(identityContext);

            _agency   = DataEntryUnitTestFixture.AgencyDetails;
            _workflow = _agency.CreateWorkflow("Workflow Title", null);
            _case     = new Domain.Summaries.Case.Case(Guid.NewGuid(), DataEntryUnitTestFixture.AgencyDetails.Id, CaseNumber);
        }
Пример #21
0
        /// <summary>
        /// Transfer a Report into its Summary.
        /// </summary>
        public virtual TSummary Begin()
        {
            // Check the Number
            if (string.IsNullOrWhiteSpace(Report.Number))
            {
                throw new Exception("Reports cannot be transfered without a valid number!");
            }

            // Find the Report's Summary in the Agency using the Report Number.
            var summary = UnitOfWork.GetEntityQuery <TSummary>()
                          .FirstOrDefault(x => x.AgencyId == Report.AgencyId &&
                                          x.Number == Report.Number);

            if (!string.IsNullOrWhiteSpace(Report.CaseNumber))
            {
                ParentCase = GetOrCreateParentCase();
            }

            // Copy data into the existing or new summary.
            var update = summary != null;

            // automapper doesn't aggregate the collections
            var s = update ? _UpdateSummary(summary) : Report.MapInto(_CreateSummary(Report));

            // Process Master Indexes
            _masterIndexService.ProcessMasterIndexes(s);

            // Commit the Work
            UnitOfWork.Commit();

            // TODO: Hack until the Surrogate Keys are introduced in the Data layer.
            // TODO: Currently the messages may get the wrong Id unless they are raised AFTER the database commit
            // TODO: because the database may override the Guid the Domain is trying to use.
            PublishSummaryMessages(s, update ? EventOperation.Update : EventOperation.Create, Report.Id);

            UnitOfWork.PublishPendingMessages();

            return(s);
        }
 private void DomainObjectsIntialization()
 {
     _otherEventSummary = new OtherEventSummary(_identityId, _agencyId, _otherEventSummaryDetails.Id, Number, null);
     _otherEventEvent   = new DomainEntities.OtherEvent.OtherEventEvent(_identityId, _agencyId, _otherEventEventDetails.Id);
     _case = new Domain.Summaries.Case.Case(_identityId, _agencyId, Number);
 }