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); }
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); }
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); }
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()); }
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); }
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()); }
public void TestCreateGetSevisBatchInfoDTOsQuery_SevisBatchIsActiveCheckProperties() { 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.CreateGetSevisBatchInfoDTOsQuery(context).ToList(); Assert.AreEqual(1, result.Count); var first = result.First(); Assert.AreEqual(batch.BatchId, first.BatchId); Assert.IsNull(first.CancelledOn); Assert.IsNull(first.CancelledReason); Assert.AreEqual(batch.DownloadDispositionCode, first.DownloadDispositionCode); Assert.AreEqual(batch.DownloadTries, first.DownloadTries); Assert.AreEqual(batch.Id, first.Id); Assert.IsFalse(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); }
public async Task TestProcessTransactionLog_TransactionLogHasNewParticipantAndNewDependent() { var expectedParticipantSevisId = "N0000158857"; var expectedDependentSevisId = "N0000158274"; var transactionXml = ECA.Business.Test.Properties.Resources.TransactionLogWithNewParticipantAndNewDependent; var batchXml = ECA.Business.Test.Properties.Resources.NewParticipantWithNewDependentBatchXml; var user = new User(1); var yesterday = DateTimeOffset.UtcNow.AddDays(-1.0); var otherUser = new User(user.Id + 1); var batchId = "----kynEn47azQ"; Participant participant = null; ParticipantPerson participantPerson = null; PersonDependent personDependent = null; Data.Person person = null; SevisBatchProcessing batch = null; ExchangeVisitorHistory history = null; var personId = 63280; var participantId = 59079; context.SetupActions.Add(() => { batch = new SevisBatchProcessing { BatchId = batchId, Id = 1, SendString = batchXml }; participant = new Participant { ParticipantId = participantId }; participantPerson = new ParticipantPerson { ParticipantId = participant.ParticipantId, Participant = participant, SevisBatchResult = "sevis batch result", }; participantPerson.History.CreatedBy = otherUser.Id; participantPerson.History.CreatedOn = yesterday; participantPerson.History.RevisedBy = otherUser.Id; participantPerson.History.RevisedOn = yesterday; participant.ParticipantPerson = participantPerson; person = new Data.Person { PersonId = personId }; participant.Person = person; participant.PersonId = person.PersonId; personDependent = new PersonDependent { DependentId = 6, Person = person, PersonId = person.PersonId }; person.Family.Add(personDependent); history = new ExchangeVisitorHistory { ParticipantId = participantId }; context.ExchangeVisitorHistories.Add(history); context.PersonDependents.Add(personDependent); context.Participants.Add(participant); context.ParticipantPersons.Add(participantPerson); context.People.Add(person); context.SevisBatchProcessings.Add(batch); }); Action tester = () => { Assert.AreEqual(expectedParticipantSevisId, participantPerson.SevisId); Assert.AreEqual(expectedDependentSevisId, personDependent.SevisId); }; context.Revert(); service.ProcessTransactionLog(user, batchId, transactionXml, fileProvider.Object); tester(); context.Revert(); await service.ProcessTransactionLogAsync(user, batchId, transactionXml, fileProvider.Object); tester(); }