Beispiel #1
0
        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);
        }
Beispiel #2
0
        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());
        }
Beispiel #3
0
        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();
            //}
        }
Beispiel #4
0
        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());
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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());
        }
Beispiel #7
0
        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);
        }
Beispiel #8
0
        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);
        }
Beispiel #9
0
        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());
        }