Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        public void AllLettersInAContainerNameMustBeLowercase(BatchId jobId)
        {
            var containerName = ContainerNameUtils.GetSafeContainerName(jobId.ToString());

            Assert.All(containerName,
                       ch => Assert.True(!Char.IsLetter(ch) || Char.IsLower(ch)));
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns true if ExecProviderEvent instances are equal
        /// </summary>
        /// <param name="other">Instance of ExecProviderEvent to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ExecProviderEvent other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     BatchId == other.BatchId ||
                     BatchId != null &&
                     BatchId.Equals(other.BatchId)
                     ) &&
                 (
                     ExeScript == other.ExeScript ||
                     ExeScript != null &&
                     ExeScript.Equals(other.ExeScript)
                 ) &&
                 (
                     EventType == other.EventType ||
                     EventType != null &&
                     EventType.Equals(other.EventType)
                 ) &&
                 (
                     ActivityId == other.ActivityId ||
                     ActivityId != null &&
                     ActivityId.Equals(other.ActivityId)
                 ));
        }
Exemplo n.º 5
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (BatchId != null)
         {
             hashCode = hashCode * 59 + BatchId.GetHashCode();
         }
         if (ExeScript != null)
         {
             hashCode = hashCode * 59 + ExeScript.GetHashCode();
         }
         if (EventType != null)
         {
             hashCode = hashCode * 59 + EventType.GetHashCode();
         }
         if (ActivityId != null)
         {
             hashCode = hashCode * 59 + ActivityId.GetHashCode();
         }
         return(hashCode);
     }
 }
Exemplo n.º 6
0
        internal string GetBatchBodyFooter()
        {
            var requestBody = $"--changeset_{ChangeSetId.ToString("N")}--" + Environment.NewLine;

            requestBody += $"--batch_{BatchId.ToString("N")}--" + Environment.NewLine;
            return(requestBody);
        }
Exemplo n.º 7
0
        internal string GetBatchBodyHeader()
        {
            var requestBody = $"--batch_{BatchId.ToString("N")}" + Environment.NewLine;

            requestBody += $"Content-Type: multipart/mixed;boundary=changeset_{ChangeSetId.ToString("N")}" + Environment.NewLine + Environment.NewLine;
            return(requestBody);
        }
 /// <summary>
 /// Handles the SelectedIndexChanged event of the ddlBatch control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 protected void ddlBatch_SelectedIndexChanged(object sender, EventArgs e)
 {
     BatchId = ddlBatch.SelectedValue.AsIntegerOrNull();
     this.SetBlockUserPreference(UserPreferenceKey.BatchId, BatchId.ToStringSafe());
     BindHtmlGrid();
     LoadRegistrationDropDowns();
 }
Exemplo n.º 9
0
        /// <summary>
        /// Creates a new default StagedSevisBatch.
        /// <param name="batchId">The id of the batch this staged batch belongs to.</param>
        /// <param name="maxCreateExchangeVisitorRecordsPerBatch">The maximum number of create records this batch will contain.</param>
        /// <param name="maxUpdateExchangeVisitorRecordPerBatch">The maximum number of update records this batch will contain.</param>
        /// <param name="sevisOrgId">The sevis org, or program, id to submit this batch with.</param>
        /// <param name="sevisUsername">The sevis username all exchange visitors will be submitted with.</param>
        /// </summary>
        public StagedSevisBatch(
            BatchId batchId,
            string sevisUsername,
            string sevisOrgId,
            int maxCreateExchangeVisitorRecordsPerBatch = MAX_CREATE_EXCHANGE_VISITOR_RECORDS_PER_BATCH_DEFAULT,
            int maxUpdateExchangeVisitorRecordPerBatch  = MAX_UPDATE_EXCHANGE_VISITOR_RECORD_PER_BATCH_DEFAULT)
        {
            Contract.Requires(batchId != null, "The batch id must not be null.");

            this.BatchId              = batchId;
            this.SevisUsername        = sevisUsername;
            this.SevisOrgId           = sevisOrgId;
            this.exchangeVisitors     = new List <ExchangeVisitor>();
            this.SevisBatchProcessing = new SevisBatchProcessing
            {
                BatchId       = this.BatchId.ToString(),
                SevisOrgId    = this.SevisOrgId,
                SevisUsername = this.SevisUsername,
                UploadTries   = 0,
                DownloadTries = 0
            };
            this.SEVISBatchCreateUpdateEV             = new SEVISBatchCreateUpdateEV();
            this.SEVISBatchCreateUpdateEV.userID      = sevisUsername;
            this.SEVISBatchCreateUpdateEV.BatchHeader = new BatchHeaderType
            {
                OrgID = this.SevisOrgId
            };
            this.SEVISBatchCreateUpdateEV.BatchHeader.SetBatchId(this.BatchId);
            this.SEVISBatchCreateUpdateEV.CreateEV       = null;
            this.SEVISBatchCreateUpdateEV.UpdateEV       = null;
            this.MaxCreateExchangeVisitorRecordsPerBatch = maxCreateExchangeVisitorRecordsPerBatch;
            this.MaxUpdateExchangeVisitorRecordPerBatch  = maxUpdateExchangeVisitorRecordPerBatch;
        }
Exemplo n.º 10
0
        public void TestGetHashCode()
        {
            var maxLong  = Int64.MaxValue;
            var instance = new BatchId(maxLong);

            Assert.AreEqual(maxLong.GetHashCode(), instance.GetHashCode());
        }
Exemplo n.º 11
0
        public void TestNewBatchId()
        {
            var batchId = BatchId.NewBatchId();

            Assert.IsNotNull(batchId.ToString());
            Assert.IsTrue(batchId.ToString().Length > 0);
        }
Exemplo n.º 12
0
 public override int GetHashCode()
 {
     unchecked
     {
         return((269 + Level * 23 + BatchId.GetHashCode()) * 23 + CellId.GetHashCode());
     }
 }
Exemplo n.º 13
0
        /// <summary>
        ///   The get bhs.
        /// </summary>
        /// <returns>
        ///   The <see cref="BHS" />.
        /// </returns>
        private BHS GetBhs()
        {
            var msh = new BHS();

            // BHS.3
            msh.OriginApplicationName = new BHS3 {
                Application = "СРЗ " + Batch.Sender.Code
            };

            // BHS.4
            msh.OriginOrganizationName = new BHS4 {
                CodeOfRegion = Batch.Sender.Code
            };

            // BHS.5
            msh.ApplicationName = new BHS5 {
                Application = "ЦК ЕРП"
            };

            // BHS.6
            msh.OrganizationName = new BHS6 {
                FomsCode = "00"
            };

            // BHS.9
            msh.TypeWork = ConfigManager.ExchangeSettings.ProcesingMode;

            // BHS.10
            msh.Identificator = BatchId.ToString();

            return(msh);
        }
Exemplo n.º 14
0
        public void ContainerNamesCanContainOnlyLettersNumbersAndDashes(BatchId jobId)
        {
            var containerName = ContainerNameUtils.GetSafeContainerName(jobId.ToString());

            Assert.All(containerName,
                       ch => Assert.True(Char.IsLetterOrDigit(ch) || ch == '-'));
        }
Exemplo n.º 15
0
        public void TestEquals_SameInstance()
        {
            var maxLong  = Int64.MaxValue;
            var instance = new BatchId(maxLong);

            Assert.IsTrue(instance.Equals(instance));
        }
Exemplo n.º 16
0
        public void TestEquals_DifferentObjectType()
        {
            var maxLong  = Int64.MaxValue;
            var instance = new BatchId(maxLong);

            Assert.IsFalse(instance.Equals(1));
        }
Exemplo n.º 17
0
        public void TestEquals_NullObject()
        {
            var maxLong  = Int64.MaxValue;
            var instance = new BatchId(maxLong);

            Assert.IsFalse(instance.Equals(null));
        }
Exemplo n.º 18
0
        public void TestToString()
        {
            var maxLong  = Int64.MaxValue;
            var instance = new BatchId(maxLong);

            Assert.AreEqual(instance.Id, instance.Id);
            Assert.IsNotNull(instance.ToString());
        }
Exemplo n.º 19
0
        public void TestConstructor_Id_ZeroValue()
        {
            var maxLong  = 0L;
            var instance = new BatchId(maxLong);

            Assert.AreEqual(instance.Id, instance.Id);
            Assert.AreEqual(BatchId.REQUEST_ID_LENGTH, instance.ToString().Length);
        }
Exemplo n.º 20
0
        public void TestConstructor_String_CheckUsesGivenPaddingChar()
        {
            var instance = BatchId.NewBatchId();

            var batchId = new BatchId(instance.ToString(), '|');

            Assert.AreEqual('|', batchId.PaddingChar);
        }
Exemplo n.º 21
0
        public void TestConstructor_String_CheckDefaultPaddingChar()
        {
            var instance = BatchId.NewBatchId();

            var batchId = new BatchId(instance.ToString());

            Assert.AreEqual(BatchId.DEFAULT_PADDING_CHARACTER, batchId.PaddingChar);
        }
Exemplo n.º 22
0
        public void TestToString_CheckUsesPadding()
        {
            var instance = new BatchId(0L);

            Assert.AreEqual(instance.Id, instance.Id);
            Assert.IsNotNull(instance.ToString());
            Assert.IsTrue(instance.ToString().Contains(BatchId.DEFAULT_PADDING_CHARACTER.ToString()));
        }
Exemplo n.º 23
0
        public void TestEquals_DifferentInstanceSameId()
        {
            var maxLong       = Int64.MaxValue;
            var instance      = new BatchId(maxLong);
            var otherInstance = new BatchId(maxLong);

            Assert.IsTrue(instance.Equals(otherInstance));
        }
Exemplo n.º 24
0
        public void TestGetBatchId_HasBatchId()
        {
            var expectedBatchId = BatchId.NewBatchId();
            var instance        = new BatchHeaderType();

            instance.BatchID = expectedBatchId.ToString();
            Assert.AreEqual(expectedBatchId, instance.GetBatchId());
        }
Exemplo n.º 25
0
        public void TestSetBatchId()
        {
            var expectedBatchId = BatchId.NewBatchId();
            var instance        = new BatchHeaderType();

            instance.BatchID = "batch id";
            instance.SetBatchId(expectedBatchId);
            Assert.AreEqual(expectedBatchId.ToString(), instance.BatchID);
        }
Exemplo n.º 26
0
        public void TestConstructor_BatchIdString()
        {
            var batchId         = BatchId.NewBatchId();
            var batchIdAsString = batchId.ToString();

            var instance = new BatchId(batchIdAsString);

            Assert.AreEqual(batchId.Id, instance.Id);
        }
Exemplo n.º 27
0
        public AbsoluteEntityCell(Vector3 worldSpace, int level)
        {
            Level = level;

            Vector3 localPosition = (worldSpace + Map.BATCH_DIMENSION_CENTERING.ToVector3()) / Map.BATCH_SIZE;

            BatchId = Int3.Floor(localPosition);
            CellId  = Int3.Floor(((localPosition - BatchId.ToVector3()) * GetCellsPerBlock()).AddScalar(0.0001f));
        }
Exemplo n.º 28
0
        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);
        }
Exemplo n.º 29
0
 public void JobOutputStorageContainerNameAgreesWithSafeContainerName(BatchId jobId)
 {
     using (var batchClient = BatchClient.Open(new FakeBatchServiceClient()))  // FsCheck doesn't like async tests
     {
         CloudJob job = batchClient.JobOperations.CreateJob();
         job.Id = jobId.ToString();
         var actualContainerName   = job.OutputStorageContainerName();
         var expectedContainerName = ContainerNameUtils.GetSafeContainerName(job.Id);
         Assert.Equal(expectedContainerName, actualContainerName);  // We have other tests for validating the outputs of GetSafeContainerName - we do not need to reproduce those here
     }
 }
Exemplo n.º 30
0
        public override int GetHashCode()
        {
            unchecked
            {
                int hash = BatchId != null?BatchId.GetHashCode() : 0;

                hash = (hash * 397) ^ (CellId != null ? CellId.GetHashCode() : 0);
                hash = (hash * 397) ^ Level;
                return(hash);
            }
        }