コード例 #1
0
        public void TestCreateGetSevisBatchProcessingDTOsToUploadQuery_DoesNotHaveSubmitDate()
        {
            var model = new SevisBatchProcessing
            {
                BatchId = "batch id",
                DownloadDispositionCode = "download code",
                Id = 1,
                ProcessDispositionCode = "process code",
                RetrieveDate           = DateTimeOffset.UtcNow.AddDays(1.0),
                SendString             = "send string",
                SubmitDate             = null,
                TransactionLogString   = "transaction log",
                UploadDispositionCode  = "upload code"
            };

            context.SevisBatchProcessings.Add(model);

            var results = SevisBatchProcessingQueries.CreateGetSevisBatchProcessingDTOQuery(context).ToList();

            Assert.AreEqual(1, results.Count);

            var firstResult = results.First();

            Assert.AreEqual(model.BatchId, firstResult.BatchId);
        }
コード例 #2
0
        public void TestCreateGetSevisBatchInfoDTOByBatchIdQuery()
        {
            var batch = new SevisBatchProcessing
            {
                BatchId = "batchId",
                DownloadDispositionCode = DispositionCode.BatchNeverSubmitted.Code,
                DownloadTries           = 1,
                Id = 2,
                LastDownloadTry        = DateTimeOffset.UtcNow.AddDays(1.0),
                LastUploadTry          = DateTimeOffset.UtcNow.AddDays(2.0),
                ProcessDispositionCode = DispositionCode.BatchNotYetProcessed.Code,
                RetrieveDate           = DateTimeOffset.UtcNow.AddDays(3.0),
                SendString             = "send string",
                SevisOrgId             = "sevis org Id",
                SevisUsername          = "******",
                SubmitDate             = DateTimeOffset.UtcNow.AddDays(4.0),
                TransactionLogString   = "transaction log",
                UploadDispositionCode  = DispositionCode.BusinessRuleViolations.Code,
                UploadTries            = 4
            };

            context.SevisBatchProcessings.Add(batch);
            var result = SevisBatchProcessingQueries.CreateGetSevisBatchInfoDTOByBatchIdQuery(context, batch.BatchId).ToList();

            Assert.AreEqual(1, result.Count);
        }
コード例 #3
0
        public void TestCreateGetSevisGroupedParticipantsQuery_CheckProperties()
        {
            var project = new Project
            {
                ProjectId = 1
            };
            var participant = new Participant
            {
                ParticipantId = 10,
                ProjectId     = project.ProjectId,
                Project       = project
            };
            var participantPerson = new ParticipantPerson
            {
                ParticipantId = participant.ParticipantId,
                Participant   = participant,
                SevisId       = "sevis id"
            };

            participant.ParticipantPerson = participantPerson;

            var status = new ParticipantPersonSevisCommStatus
            {
                Id                = 1,
                AddedOn           = DateTimeOffset.Now,
                ParticipantId     = participant.ParticipantId,
                ParticipantPerson = participantPerson,
                SevisCommStatusId = SevisCommStatus.QueuedToSubmit.Id,
                SevisOrgId        = "org",
                SevisUsername     = "******"
            };

            participantPerson.ParticipantPersonSevisCommStatuses.Add(status);

            context.Projects.Add(project);
            context.ParticipantPersons.Add(participantPerson);
            context.Participants.Add(participant);
            context.ParticipantPersonSevisCommStatuses.Add(status);

            var results = SevisBatchProcessingQueries.CreateGetSevisGroupedParticipantsQuery(context).ToList();

            Assert.AreEqual(1, results.Count);

            var firstResult = results.First();

            Assert.AreEqual(status.SevisOrgId, firstResult.SevisOrgId);
            Assert.AreEqual(status.SevisUsername, firstResult.SevisUsername);
            Assert.AreEqual(1, firstResult.Participants.Count());

            var firstParticipant = firstResult.Participants.First();

            Assert.AreEqual(participant.ParticipantId, firstParticipant.ParticipantId);
            Assert.AreEqual(project.ProjectId, firstParticipant.ProjectId);
            Assert.AreEqual(participantPerson.SevisId, firstParticipant.SevisId);
            Assert.AreEqual(status.SevisCommStatusId, firstParticipant.SevisCommStatusId);
        }
コード例 #4
0
        public void TestCreateGetSevisBatchInfoDTOByBatchIdQuery_BatchDoesNotExist()
        {
            var batch = new SevisBatchProcessing
            {
                BatchId = "batchId",
            };

            context.SevisBatchProcessings.Add(batch);
            var result = SevisBatchProcessingQueries.CreateGetSevisBatchInfoDTOByBatchIdQuery(context, "somebatchid").ToList();

            Assert.AreEqual(0, result.Count);
        }
コード例 #5
0
        public void TestCreateGetParticipantPersonsByBatchId_EnsureDistinct()
        {
            var batchId           = "batchId";
            var participantPerson = new ParticipantPerson
            {
                ParticipantId = 1
            };
            var readyToSubmit = new ParticipantPersonSevisCommStatus
            {
                Id = 1,
                SevisCommStatusId = SevisCommStatus.ReadyToSubmit.Id,
                ParticipantPerson = participantPerson,
                ParticipantId     = participantPerson.ParticipantId
            };
            var queuedToSubmit = new ParticipantPersonSevisCommStatus
            {
                Id = 2,
                SevisCommStatusId = SevisCommStatus.QueuedToSubmit.Id,
                ParticipantPerson = participantPerson,
                ParticipantId     = participantPerson.ParticipantId
            };
            var pendingSevisSend = new ParticipantPersonSevisCommStatus
            {
                Id = 3,
                SevisCommStatusId = SevisCommStatus.PendingSevisSend.Id,
                ParticipantPerson = participantPerson,
                ParticipantId     = participantPerson.ParticipantId,
                BatchId           = batchId
            };
            var otherBatchCommStatus = new ParticipantPersonSevisCommStatus
            {
                Id = 3,
                SevisCommStatusId = SevisCommStatus.SentToDhs.Id,
                ParticipantPerson = participantPerson,
                ParticipantId     = participantPerson.ParticipantId,
                BatchId           = batchId
            };

            participantPerson.ParticipantPersonSevisCommStatuses.Add(readyToSubmit);
            participantPerson.ParticipantPersonSevisCommStatuses.Add(queuedToSubmit);
            participantPerson.ParticipantPersonSevisCommStatuses.Add(pendingSevisSend);
            participantPerson.ParticipantPersonSevisCommStatuses.Add(otherBatchCommStatus);

            context.ParticipantPersons.Add(participantPerson);
            context.ParticipantPersonSevisCommStatuses.Add(readyToSubmit);
            context.ParticipantPersonSevisCommStatuses.Add(queuedToSubmit);
            context.ParticipantPersonSevisCommStatuses.Add(pendingSevisSend);
            context.ParticipantPersonSevisCommStatuses.Add(otherBatchCommStatus);
            var results = SevisBatchProcessingQueries.CreateGetParticipantPersonsByBatchId(context, batchId).ToList();

            Assert.AreEqual(1, results.Count);
            Assert.IsTrue(Object.ReferenceEquals(participantPerson, results.First()));
        }
コード例 #6
0
        public void TestCreateGetSevisGroupedParticipantsQuery_CheckLatestSevisCommStatus()
        {
            var project = new Project
            {
                ProjectId = 1
            };
            var participant = new Participant
            {
                ParticipantId = 10,
                ProjectId     = project.ProjectId,
                Project       = project
            };
            var participantPerson = new ParticipantPerson
            {
                ParticipantId = participant.ParticipantId,
                Participant   = participant,
                SevisId       = "sevis id"
            };

            participant.ParticipantPerson = participantPerson;

            var status1 = new ParticipantPersonSevisCommStatus
            {
                Id                = 1,
                AddedOn           = DateTimeOffset.Now.AddDays(-1.0),
                ParticipantId     = participant.ParticipantId,
                ParticipantPerson = participantPerson,
                SevisCommStatusId = SevisCommStatus.ReadyToSubmit.Id
            };
            var status2 = new ParticipantPersonSevisCommStatus
            {
                Id                = 2,
                AddedOn           = DateTimeOffset.Now.AddDays(1.0),
                ParticipantId     = participant.ParticipantId,
                ParticipantPerson = participantPerson,
                SevisCommStatusId = SevisCommStatus.QueuedToSubmit.Id
            };

            participantPerson.ParticipantPersonSevisCommStatuses.Add(status1);
            participantPerson.ParticipantPersonSevisCommStatuses.Add(status2);

            context.Projects.Add(project);
            context.ParticipantPersons.Add(participantPerson);
            context.Participants.Add(participant);
            context.ParticipantPersonSevisCommStatuses.Add(status1);

            var results = SevisBatchProcessingQueries.CreateGetSevisGroupedParticipantsQuery(context).ToList();

            Assert.AreEqual(1, results.Count);
        }
コード例 #7
0
        public void TestCreateGetProcessedSevisBatchIdsForDeletionQuery_SevisBatchIsAfterCutoffDate()
        {
            var cutOffDate = DateTime.UtcNow;
            var batch      = new SevisBatchProcessing
            {
                Id                      = 1,
                RetrieveDate            = cutOffDate.AddDays(1.0),
                DownloadDispositionCode = DispositionCode.Success.Code,
                UploadDispositionCode   = DispositionCode.Success.Code,
                ProcessDispositionCode  = DispositionCode.Success.Code
            };

            context.SevisBatchProcessings.Add(batch);
            var results = SevisBatchProcessingQueries.CreateGetProcessedSevisBatchIdsForDeletionQuery(context, cutOffDate);

            Assert.AreEqual(0, results.Count());
        }
コード例 #8
0
        /// <summary>
        /// Returns the batch info with the given batch id.
        /// </summary>
        /// <param name="batchId">The batch id.</param>
        /// /// <param name="userId">The id of the user requesting the batch status.</param>
        /// <param name="participantId">The participant to get the status for.</param>
        /// <param name="projectId">The project id of the participant.</param>
        /// <returns>The info dto or null of it does not exist.</returns>
        public async Task <SevisBatchInfoDTO> GetBatchInfoByBatchIdAsync(int userId, int projectId, int participantId, string batchId)
        {
            var participant = Context.Participants.Find(participantId);

            throwIfModelDoesNotExist(participantId, participant, typeof(Participant));
            throwSecurityViolationIfParticipantDoesNotBelongToProject(userId, projectId, participant);
            var commStatuses = await CreateGetParticipantPersonSevisCommStatusQuery(participantId, batchId).CountAsync();

            if (commStatuses == 0)
            {
                return(null);
            }
            else
            {
                return(await SevisBatchProcessingQueries.CreateGetSevisBatchInfoDTOByBatchIdQuery(this.Context, batchId).FirstOrDefaultAsync());
            }
        }
コード例 #9
0
        public void TestCreateGetSevisBatchProcessingDTOQuery()
        {
            var model = new SevisBatchProcessing
            {
                BatchId = "batch id",
                DownloadDispositionCode = "download code",
                Id = 1,
                ProcessDispositionCode = "process code",
                RetrieveDate           = DateTimeOffset.UtcNow.AddDays(1.0),
                SendString             = "send string",
                SubmitDate             = DateTimeOffset.UtcNow.AddDays(2.0),
                TransactionLogString   = "transaction log",
                UploadDispositionCode  = "upload code",
                SevisUsername          = "******",
                SevisOrgId             = "org",
                UploadTries            = 1,
                DownloadTries          = 2,
                LastUploadTry          = DateTimeOffset.UtcNow.AddDays(-10.0),
                LastDownloadTry        = DateTimeOffset.UtcNow.AddDays(-5.0)
            };

            context.SevisBatchProcessings.Add(model);

            var results = SevisBatchProcessingQueries.CreateGetSevisBatchProcessingDTOQuery(context).ToList();

            Assert.AreEqual(1, results.Count);

            var firstResult = results.First();

            Assert.AreEqual(model.BatchId, firstResult.BatchId);
            Assert.AreEqual(model.DownloadDispositionCode, firstResult.DownloadDispositionCode);
            Assert.AreEqual(model.Id, firstResult.Id);
            Assert.AreEqual(model.ProcessDispositionCode, firstResult.ProcessDispositionCode);
            Assert.AreEqual(model.RetrieveDate, firstResult.RetrieveDate);
            Assert.AreEqual(model.SendString, firstResult.SendString);
            Assert.AreEqual(model.SubmitDate, firstResult.SubmitDate);
            Assert.AreEqual(model.TransactionLogString, firstResult.TransactionLogString);
            Assert.AreEqual(model.UploadDispositionCode, firstResult.UploadDispositionCode);
            Assert.AreEqual(model.SevisUsername, firstResult.SevisUsername);
            Assert.AreEqual(model.SevisOrgId, firstResult.SevisOrgId);
            Assert.AreEqual(model.UploadTries, firstResult.UploadTries);
            Assert.AreEqual(model.DownloadTries, firstResult.DownloadTries);
            Assert.AreEqual(model.LastUploadTry, firstResult.LastUploadTry);
            Assert.AreEqual(model.LastDownloadTry, firstResult.LastDownloadTry);
        }
コード例 #10
0
        public void TestCreateGetProcessedSevisBatchIdsForDeletionQuery_HasSuccessfulUploadAndDownload_HasBusinessValidationProcessCode()
        {
            var cutOffDate = DateTime.UtcNow;
            var batch      = new SevisBatchProcessing
            {
                Id                      = 1,
                RetrieveDate            = cutOffDate.AddDays(-1.0),
                DownloadDispositionCode = DispositionCode.Success.Code,
                UploadDispositionCode   = DispositionCode.Success.Code,
                ProcessDispositionCode  = DispositionCode.BusinessRuleViolations.Code
            };

            context.SevisBatchProcessings.Add(batch);
            var results = SevisBatchProcessingQueries.CreateGetProcessedSevisBatchIdsForDeletionQuery(context, cutOffDate);

            Assert.AreEqual(1, results.Count());
            Assert.AreEqual(batch.Id, results.First());
        }
コード例 #11
0
        public void TestCreateGetSevisBatchInfoDTOsQuery_SevisBatchIsCancelledCheckProperties()
        {
            var batch = new CancelledSevisBatchProcessing
            {
                BatchId = "batchId",
                DownloadDispositionCode = DispositionCode.BatchNeverSubmitted.Code,
                DownloadTries           = 1,
                Id = 2,
                LastDownloadTry        = DateTimeOffset.UtcNow.AddDays(1.0),
                LastUploadTry          = DateTimeOffset.UtcNow.AddDays(2.0),
                ProcessDispositionCode = DispositionCode.BatchNotYetProcessed.Code,
                RetrieveDate           = DateTimeOffset.UtcNow.AddDays(3.0),
                SendString             = "send string",
                SevisOrgId             = "sevis org Id",
                SevisUsername          = "******",
                SubmitDate             = DateTimeOffset.UtcNow.AddDays(4.0),
                TransactionLogString   = "transaction log",
                UploadDispositionCode  = DispositionCode.BusinessRuleViolations.Code,
                UploadTries            = 4,
                CancelledOn            = DateTimeOffset.UtcNow.AddDays(5.0),
                Reason = "cancel reason",
            };

            context.CancelledSevisBatchProcessings.Add(batch);
            var result = SevisBatchProcessingQueries.CreateGetSevisBatchInfoDTOsQuery(context).ToList();

            Assert.AreEqual(1, result.Count);
            var first = result.First();

            Assert.AreEqual(batch.BatchId, first.BatchId);
            Assert.AreEqual(batch.CancelledOn, first.CancelledOn);
            Assert.AreEqual(batch.Reason, first.CancelledReason);
            Assert.AreEqual(batch.DownloadDispositionCode, first.DownloadDispositionCode);
            Assert.AreEqual(batch.DownloadTries, first.DownloadTries);
            Assert.AreEqual(batch.Id, first.Id);
            Assert.IsTrue(first.IsCancelled);
            Assert.AreEqual(batch.LastDownloadTry, first.LastDownloadTry);
            Assert.AreEqual(batch.LastUploadTry, first.LastUploadTry);
            Assert.AreEqual(batch.ProcessDispositionCode, first.ProcessDispositionCode);
            Assert.AreEqual(batch.RetrieveDate, first.RetrieveDate);
            Assert.AreEqual(batch.SubmitDate, first.SubmitDate);
            Assert.AreEqual(batch.UploadDispositionCode, first.UploadDispositionCode);
            Assert.AreEqual(batch.UploadTries, first.UploadTries);
        }
コード例 #12
0
        public void TestCreateGetSevisGroupedParticipantsQuery_IsNotQueuedToSubmitOrIsQueuedToValidate()
        {
            var project = new Project
            {
                ProjectId = 1
            };
            var participant = new Participant
            {
                ParticipantId = 10,
                ProjectId     = project.ProjectId,
                Project       = project
            };
            var participantPerson = new ParticipantPerson
            {
                ParticipantId = participant.ParticipantId,
                Participant   = participant,
                SevisId       = "sevis id"
            };

            participant.ParticipantPerson = participantPerson;

            var status = new ParticipantPersonSevisCommStatus
            {
                Id                = 1,
                AddedOn           = DateTimeOffset.Now,
                ParticipantId     = participant.ParticipantId,
                ParticipantPerson = participantPerson,
                SevisCommStatusId = SevisCommStatus.ReadyToSubmit.Id
            };

            participantPerson.ParticipantPersonSevisCommStatuses.Add(status);

            context.Projects.Add(project);
            context.ParticipantPersons.Add(participantPerson);
            context.Participants.Add(participant);
            context.ParticipantPersonSevisCommStatuses.Add(status);

            var results = SevisBatchProcessingQueries.CreateGetSevisGroupedParticipantsQuery(context).ToList();

            Assert.AreEqual(0, results.Count);
        }