public void TestGetExchangeVisitorNamespaces() { var sevisOrgId = "org id"; var batchId = BatchId.NewBatchId(); var sevisUsername = "******"; var instance = new StagedSevisBatch(batchId, sevisUsername, sevisOrgId); var exchangeVisitor = GetExchangeVisitor("sevisId", 1, 2); var namespaces = instance.GetExchangeVisitorNamespaces(); var namespacesArray = namespaces.ToArray(); Assert.AreEqual(5, namespacesArray.Count()); var urls = namespacesArray.Select(x => x.Namespace).ToList(); Assert.IsTrue(urls.Contains(StagedSevisBatch.COMMON_NAMESPACE_URL)); Assert.IsTrue(urls.Contains(StagedSevisBatch.TABLE_NAMESPACE_URL)); Assert.IsTrue(urls.Contains(StagedSevisBatch.EXCHANGE_VISITOR_NAMESPACE_URL)); Assert.IsTrue(urls.Contains(StagedSevisBatch.XSD_NAMESPACE_URL)); Assert.IsTrue(urls.Contains(StagedSevisBatch.XSI_NAMESPACE_URL)); var prefixes = namespacesArray.Select(x => x.Name).ToList(); Assert.IsTrue(prefixes.Contains(StagedSevisBatch.COMMON_NAMESPACE_PREFIX)); Assert.IsTrue(prefixes.Contains(StagedSevisBatch.TABLE_NAMESPACE_PREFIX)); Assert.IsTrue(prefixes.Contains(StagedSevisBatch.EXCHANGE_VISITOR_NAMESPACE_PREFIX)); Assert.IsTrue(prefixes.Contains(StagedSevisBatch.XSI_NAMESPACE_PREFIX)); Assert.IsTrue(prefixes.Contains(StagedSevisBatch.XSD_NAMESPACE_PREFIX)); }
public void TestAddExchangeVisitor_SevisIdHasValue_ExceededGivenCount() { var sevisOrgId = "org id"; var batchId = BatchId.NewBatchId(); var sevisId = "sevisId"; var sevisUsername = "******"; var instance = new StagedSevisBatch(batchId, sevisUsername, sevisOrgId, 1, 1); var exchangeVisitor = GetExchangeVisitor(sevisId, 1, 2); var participant = new SevisGroupedParticipantDTO { ParticipantId = exchangeVisitor.Person.ParticipantId, SevisCommStatusId = SevisCommStatus.QueuedToSubmit.Id, }; instance.SEVISBatchCreateUpdateEV.UpdateEV = new Business.Sevis.Model.SEVISEVBatchTypeExchangeVisitor1[2]; var previouslySubmittedExchangeVisitor = GetPreviouslySubmittedExchangeVisitor(sevisId, 1, 2); Assert.IsTrue(exchangeVisitor.GetChangeDetail(previouslySubmittedExchangeVisitor).HasChanges()); var message = "This StagedSevisBatch can not accomodate the given exchange visitor."; Action a = () => instance.AddExchangeVisitor(participant, exchangeVisitor, previouslySubmittedExchangeVisitor); a.ShouldThrow <NotSupportedException>().WithMessage(message); }
public void TestConstructor_UseDefaults() { var sevisOrgId = "org id"; var batchId = BatchId.NewBatchId(); var sevisUsername = "******"; var instance = new StagedSevisBatch(batchId, sevisUsername, sevisOrgId); Assert.AreEqual(StagedSevisBatch.MAX_CREATE_EXCHANGE_VISITOR_RECORDS_PER_BATCH_DEFAULT, instance.MaxCreateExchangeVisitorRecordsPerBatch); Assert.AreEqual(StagedSevisBatch.MAX_UPDATE_EXCHANGE_VISITOR_RECORD_PER_BATCH_DEFAULT, instance.MaxUpdateExchangeVisitorRecordPerBatch); }
public void TestCanAccomodate_SevisIdIsEmpty() { var sevisOrgId = "org id"; var batchId = BatchId.NewBatchId(); var sevisUsername = "******"; var instance = new StagedSevisBatch(batchId, sevisUsername, sevisOrgId); var exchangeVisitor = GetExchangeVisitor(string.Empty, 1, 2); var participant = new SevisGroupedParticipantDTO { ParticipantId = exchangeVisitor.Person.ParticipantId, SevisCommStatusId = SevisCommStatus.QueuedToSubmit.Id, }; Assert.IsTrue(instance.CanAccomodate(participant, exchangeVisitor, sevisUsername, sevisOrgId)); }
public void TestSerializeSEVISBatchCreateUpdateEV_DoesNotHaveSevisId() { var sevisOrgId = "P-1-19833"; var batchId = BatchId.NewBatchId(); var sevisUsername = "******"; var instance = new StagedSevisBatch(batchId, sevisUsername, sevisOrgId); var exchangeVisitor = GetExchangeVisitor(null, 1, 2); var participant = new SevisGroupedParticipantDTO { ParticipantId = exchangeVisitor.Person.ParticipantId, SevisCommStatusId = SevisCommStatus.QueuedToSubmit.Id, }; Assert.IsNull(instance.SevisBatchProcessing.SendXml); instance.AddExchangeVisitor(participant, exchangeVisitor); Assert.IsNull(instance.SevisBatchProcessing.SendXml); instance.SerializeSEVISBatchCreateUpdateEV(); Assert.IsNotNull(instance.SevisBatchProcessing.SendXml); Assert.IsTrue(instance.SevisBatchProcessing.SendString.Contains(StagedSevisBatch.COMMON_NAMESPACE_PREFIX)); Assert.IsTrue(instance.SevisBatchProcessing.SendString.Contains(StagedSevisBatch.TABLE_NAMESPACE_PREFIX)); Assert.IsTrue(instance.SevisBatchProcessing.SendString.Contains(StagedSevisBatch.EXCHANGE_VISITOR_NAMESPACE_PREFIX)); Assert.IsTrue(instance.SevisBatchProcessing.SendString.Contains(StagedSevisBatch.XSD_NAMESPACE_PREFIX)); Assert.IsTrue(instance.SevisBatchProcessing.SendString.Contains(StagedSevisBatch.XSI_NAMESPACE_PREFIX)); Assert.IsTrue(instance.SevisBatchProcessing.SendString.Contains(StagedSevisBatch.COMMON_NAMESPACE_URL)); Assert.IsTrue(instance.SevisBatchProcessing.SendString.Contains(StagedSevisBatch.TABLE_NAMESPACE_URL)); Assert.IsTrue(instance.SevisBatchProcessing.SendString.Contains(StagedSevisBatch.EXCHANGE_VISITOR_NAMESPACE_URL)); Assert.IsTrue(instance.SevisBatchProcessing.SendString.Contains(StagedSevisBatch.XSD_NAMESPACE_URL)); Assert.IsTrue(instance.SevisBatchProcessing.SendString.Contains(StagedSevisBatch.XSI_NAMESPACE_URL)); //XmlReaderSettings settings = new XmlReaderSettings(); //settings.Schemas.Add("http://www.ice.gov/xmlschema/sevisbatch/alpha/Common", StagedSevisBatch.COMMON_NAMESPACE_URL); //settings.Schemas.Add("http://www.ice.gov/xmlschema/sevisbatch/alpha/Table", StagedSevisBatch.TABLE_NAMESPACE_URL); //settings.Schemas.Add("", StagedSevisBatch.EXCHANGE_VISITOR_NAMESPACE_URL); //settings.ValidationType = ValidationType.Schema; //using (XmlReader reader = XmlReader.Create(new StringReader(instance.SevisBatchProcessing.SendString), settings)) //{ // XmlDocument document = new XmlDocument(); // Action a = () => document.Load(reader); // a.ShouldNotThrow(); //} }
public void TestCanAccomodate_CreateEVArrayIsNotNull() { var sevisOrgId = "org id"; var batchId = BatchId.NewBatchId(); var sevisUsername = "******"; var instance = new StagedSevisBatch(batchId, sevisUsername, sevisOrgId); instance.SEVISBatchCreateUpdateEV.CreateEV = new List <SEVISEVBatchTypeExchangeVisitor>().ToArray(); var exchangeVisitor = GetExchangeVisitor(null, 1, 2); var participant = new SevisGroupedParticipantDTO { ParticipantId = exchangeVisitor.Person.ParticipantId, SevisCommStatusId = SevisCommStatus.QueuedToSubmit.Id, }; Assert.IsTrue(instance.CanAccomodate(participant, exchangeVisitor, sevisUsername, sevisOrgId)); }
public void TestAddExchangeVisitor_SevisIdIsEmpty() { var sevisOrgId = "org id"; var batchId = BatchId.NewBatchId(); var sevisUsername = "******"; var instance = new StagedSevisBatch(batchId, sevisUsername, sevisOrgId); var exchangeVisitor = GetExchangeVisitor(String.Empty, 1, 2); var participant = new SevisGroupedParticipantDTO { ParticipantId = exchangeVisitor.Person.ParticipantId, SevisCommStatusId = SevisCommStatus.QueuedToSubmit.Id, }; Assert.IsNull(instance.SEVISBatchCreateUpdateEV.CreateEV); instance.AddExchangeVisitor(participant, exchangeVisitor); Assert.AreEqual(1, instance.SEVISBatchCreateUpdateEV.CreateEV.Count()); }
public void TestCanAccomodate_SevisIdHasValue_PreviouslySubmittedExchangeVisitorIsNull() { var sevisOrgId = "org id"; var batchId = BatchId.NewBatchId(); var sevisUsername = "******"; var sevisId = "sevisId"; var instance = new StagedSevisBatch(batchId, sevisUsername, sevisOrgId); var exchangeVisitor = GetExchangeVisitor(sevisId, 1, 2); var participant = new SevisGroupedParticipantDTO { ParticipantId = exchangeVisitor.Person.ParticipantId, SevisCommStatusId = SevisCommStatus.QueuedToSubmit.Id, }; var expectedMessage = "The previously submitted exchange visitor must be supplied, since the exchange visitor has a sevis id."; Action a = () => instance.CanAccomodate(participant, exchangeVisitor, sevisUsername, sevisOrgId, null); a.ShouldThrow <NotSupportedException>().WithMessage(expectedMessage); }
public void TestCanAccomodate_SevisIdHasValue() { var sevisOrgId = "org id"; var batchId = BatchId.NewBatchId(); var sevisUsername = "******"; var sevisId = "sevisId"; var instance = new StagedSevisBatch(batchId, sevisUsername, sevisOrgId); var exchangeVisitor = GetExchangeVisitor(sevisId, 1, 2); var participant = new SevisGroupedParticipantDTO { ParticipantId = exchangeVisitor.Person.ParticipantId, SevisCommStatusId = SevisCommStatus.QueuedToSubmit.Id, }; var previouslySubmittedExchangeVisitor = GetPreviouslySubmittedExchangeVisitor(sevisId, 1, 2); Assert.IsTrue(exchangeVisitor.GetChangeDetail(previouslySubmittedExchangeVisitor).HasChanges()); Assert.IsTrue(instance.CanAccomodate(participant, exchangeVisitor, sevisUsername, sevisOrgId, previouslySubmittedExchangeVisitor)); }
public void TestAddExchangeVisitor_SevisIdDoesNotHaveValue_ExceededDefaultCount() { var sevisOrgId = "org id"; var batchId = BatchId.NewBatchId(); var sevisUsername = "******"; var instance = new StagedSevisBatch(batchId, sevisUsername, sevisOrgId); var exchangeVisitor = GetExchangeVisitor(null, 1, 2); var participant = new SevisGroupedParticipantDTO { ParticipantId = exchangeVisitor.Person.ParticipantId, SevisCommStatusId = SevisCommStatus.QueuedToSubmit.Id, }; instance.SEVISBatchCreateUpdateEV.CreateEV = new Business.Sevis.Model.SEVISEVBatchTypeExchangeVisitor[StagedSevisBatch.MAX_CREATE_EXCHANGE_VISITOR_RECORDS_PER_BATCH_DEFAULT]; var message = "This StagedSevisBatch can not accomodate the given exchange visitor."; Action a = () => instance.AddExchangeVisitor(participant, exchangeVisitor); a.ShouldThrow <NotSupportedException>().WithMessage(message); }
public void TestCanAccomodate_ExchangeVisitorIsQueuedToValidate() { var sevisOrgId = "org id"; var batchId = BatchId.NewBatchId(); var sevisUsername = "******"; var sevisId = "sevisId"; var instance = new StagedSevisBatch(batchId, sevisUsername, sevisOrgId); instance.SEVISBatchCreateUpdateEV.UpdateEV = new List <SEVISEVBatchTypeExchangeVisitor1>().ToArray(); var exchangeVisitor = GetExchangeVisitor(sevisId, 1, 2); var participant = new SevisGroupedParticipantDTO { ParticipantId = exchangeVisitor.Person.ParticipantId, SevisCommStatusId = SevisCommStatus.QueuedToValidate.Id, }; var previouslySubmittedExchangeVisitor = GetPreviouslySubmittedExchangeVisitor(sevisId, 1, 2); Assert.IsTrue(exchangeVisitor.GetChangeDetail(previouslySubmittedExchangeVisitor).HasChanges()); Assert.IsTrue(instance.CanAccomodate(participant, exchangeVisitor, sevisUsername, sevisOrgId, previouslySubmittedExchangeVisitor)); }
public void TestAddExchangeVisitor_IsQueuedToValidate_ExchangeVisitorHasNotChanged() { var sevisOrgId = "org id"; var sevisId = "sevisId"; var batchId = BatchId.NewBatchId(); var sevisUsername = "******"; var instance = new StagedSevisBatch(batchId, sevisUsername, sevisOrgId); var exchangeVisitor = GetExchangeVisitor(sevisId, 1, 2); var participant = new SevisGroupedParticipantDTO { ParticipantId = exchangeVisitor.Person.ParticipantId, SevisCommStatusId = SevisCommStatus.QueuedToValidate.Id, }; Assert.IsNull(instance.SEVISBatchCreateUpdateEV.CreateEV); Assert.IsFalse(exchangeVisitor.GetChangeDetail(exchangeVisitor).HasChanges()); instance.AddExchangeVisitor(participant, exchangeVisitor, exchangeVisitor); Assert.AreEqual(1, instance.SEVISBatchCreateUpdateEV.UpdateEV.Count()); }
public void TestAddExchangeVisitor_SevisIdHasValue_PreviousSubmittedExchangeVisitorIsNull() { var sevisOrgId = "org id"; var batchId = BatchId.NewBatchId(); var sevisId = "sevisId"; var sevisUsername = "******"; var instance = new StagedSevisBatch(batchId, sevisUsername, sevisOrgId, 1, 1); var exchangeVisitor = GetExchangeVisitor(sevisId, 1, 2); var participant = new SevisGroupedParticipantDTO { ParticipantId = exchangeVisitor.Person.ParticipantId, SevisCommStatusId = SevisCommStatus.QueuedToSubmit.Id, }; instance.SEVISBatchCreateUpdateEV.UpdateEV = new Business.Sevis.Model.SEVISEVBatchTypeExchangeVisitor1[2]; var message = "The previously submitted exchange visitor must be supplied, since the exchange visitor has a sevis id."; Action a = () => instance.AddExchangeVisitor(participant, exchangeVisitor, null); a.ShouldThrow <NotSupportedException>().WithMessage(message); }
public void TestAddExchangeVisitor_IsQueuedToValidate_ExceededDefaultCount() { var sevisOrgId = "org id"; var batchId = BatchId.NewBatchId(); var sevisUsername = "******"; var instance = new StagedSevisBatch(batchId, sevisUsername, sevisOrgId); var exchangeVisitor = GetExchangeVisitor("sevisId", 1, 2); var participant = new SevisGroupedParticipantDTO { ParticipantId = exchangeVisitor.Person.ParticipantId, SevisCommStatusId = SevisCommStatus.QueuedToValidate.Id, }; instance.SEVISBatchCreateUpdateEV.UpdateEV = new Business.Sevis.Model.SEVISEVBatchTypeExchangeVisitor1[StagedSevisBatch.MAX_UPDATE_EXCHANGE_VISITOR_RECORD_PER_BATCH_DEFAULT]; Assert.IsFalse(exchangeVisitor.GetChangeDetail(exchangeVisitor).HasChanges()); var message = "This StagedSevisBatch can not accomodate the given exchange visitor."; Action a = () => instance.AddExchangeVisitor(participant, exchangeVisitor, exchangeVisitor); a.ShouldThrow <NotSupportedException>().WithMessage(message); }
public void TestAddExchangeVisitor_ExchangeVisitorAlreadyAdded() { var sevisOrgId = "org id"; var batchId = BatchId.NewBatchId(); var sevisUsername = "******"; var sevisId = "sevisId"; var instance = new StagedSevisBatch(batchId, sevisUsername, sevisOrgId); var exchangeVisitor = GetExchangeVisitor(sevisId, 1, 2); var participant = new SevisGroupedParticipantDTO { ParticipantId = exchangeVisitor.Person.ParticipantId, SevisCommStatusId = SevisCommStatus.QueuedToSubmit.Id, }; var previouslySubmittedExchangeVisitor = GetPreviouslySubmittedExchangeVisitor(sevisId, 1, 2); Assert.IsTrue(exchangeVisitor.GetChangeDetail(previouslySubmittedExchangeVisitor).HasChanges()); instance.AddExchangeVisitor(participant, exchangeVisitor, previouslySubmittedExchangeVisitor); Assert.AreEqual(1, instance.GetExchangeVisitors().Count()); instance.AddExchangeVisitor(participant, exchangeVisitor, previouslySubmittedExchangeVisitor); Assert.AreEqual(1, instance.GetExchangeVisitors().Count()); }
public void TestAddExchangeVisitor_SevisIdHasValue() { var sevisOrgId = "org id"; var batchId = BatchId.NewBatchId(); var sevisUsername = "******"; var sevisId = "sevisId"; var instance = new StagedSevisBatch(batchId, sevisUsername, sevisOrgId); var exchangeVisitor = GetExchangeVisitor(sevisId, 1, 2); var participant = new SevisGroupedParticipantDTO { ParticipantId = exchangeVisitor.Person.ParticipantId, SevisCommStatusId = SevisCommStatus.QueuedToSubmit.Id, }; Assert.IsNull(instance.SEVISBatchCreateUpdateEV.CreateEV); var previouslySubmittedExchangeVisitor = GetPreviouslySubmittedExchangeVisitor(sevisId, 1, 2); Assert.IsTrue(exchangeVisitor.GetChangeDetail(previouslySubmittedExchangeVisitor).HasChanges()); instance.AddExchangeVisitor(participant, exchangeVisitor, previouslySubmittedExchangeVisitor); Assert.AreEqual(exchangeVisitor.GetSEVISEVBatchTypeExchangeVisitor1Collection(sevisUsername, previouslySubmittedExchangeVisitor).Count(), instance.SEVISBatchCreateUpdateEV.UpdateEV.Count()); }
public void TestConstructor() { var sevisOrgId = "org id"; var batchId = BatchId.NewBatchId(); var sevisUsername = "******"; var maxCreated = 10; var maxUpdated = 20; var instance = new StagedSevisBatch(batchId, sevisUsername, sevisOrgId, maxCreated, maxUpdated); Assert.IsNotNull(instance.BatchId); Assert.AreEqual(batchId, instance.BatchId); Assert.AreEqual(sevisOrgId, instance.SevisOrgId); Assert.AreEqual(sevisUsername, instance.SevisUsername); Assert.IsNotNull(instance.SevisBatchProcessing); Assert.AreEqual(batchId.ToString(), instance.SevisBatchProcessing.BatchId); Assert.AreEqual(sevisOrgId, instance.SevisBatchProcessing.SevisOrgId); Assert.AreEqual(sevisUsername, instance.SevisBatchProcessing.SevisUsername); Assert.AreEqual(0, instance.SevisBatchProcessing.UploadTries); Assert.AreEqual(0, instance.SevisBatchProcessing.DownloadTries); Assert.IsNotNull(instance.SEVISBatchCreateUpdateEV); Assert.AreEqual(sevisUsername, instance.SEVISBatchCreateUpdateEV.userID); Assert.IsNotNull(instance.SEVISBatchCreateUpdateEV.BatchHeader); Assert.AreEqual(batchId.ToString(), instance.SEVISBatchCreateUpdateEV.BatchHeader.BatchID); Assert.AreEqual(sevisOrgId, instance.SEVISBatchCreateUpdateEV.BatchHeader.OrgID); Assert.IsNull(instance.SEVISBatchCreateUpdateEV.CreateEV); Assert.IsNull(instance.SEVISBatchCreateUpdateEV.UpdateEV); Assert.IsNotNull(instance.GetExchangeVisitors()); Assert.AreEqual(0, instance.GetExchangeVisitors().Count()); Assert.AreEqual(maxCreated, instance.MaxCreateExchangeVisitorRecordsPerBatch); Assert.AreEqual(maxUpdated, instance.MaxUpdateExchangeVisitorRecordPerBatch); }
/// <summary> /// Writes to the console the new batch that was created. /// </summary> /// <param name="batch">The new batch.</param> public void NotifyStagedSevisBatchCreated(StagedSevisBatch batch) { Console.WriteLine(String.Format("A new sevis batch with id [{0}] was created.", batch.BatchId)); }