Beispiel #1
0
        public void mark_outofrange_specified()
        {
            TiedUp.Core.TiedUpSpec schedulledDaysSpec = new TiedUp.Core.TiedUpSpec("schedulledDays", 1, 31);

            TiedUp.Core.TiedUp tiedUp = new TiedUp.Core.TiedUp(schedulledDaysSpec);

            int r = tiedUp.Mark(0);

            Assert.Equal(TiedUp.Core.TiedUp.ERROR_OUT_OF_RANGE, r);
        }
Beispiel #2
0
 public static string Id(TiedUpSpec tiedUpSpec)
 {
     unsafe
     {
         char * pId   = tiedUpSpec.Id;
         string strId = new string(pId);
         strId = strId.TrimEnd('\0');
         return(strId);
     }
 }
Beispiel #3
0
        public void query_marked_outofrange_specified()
        {
            TiedUp.Core.TiedUpSpec schedulledDays = new TiedUp.Core.TiedUpSpec("schedulledDays", 1, 31);

            TiedUp.Core.TiedUp tiedUp = new TiedUp.Core.TiedUp(schedulledDays);

            bool marked = false;

            int r = tiedUp.Marked(0, ref marked);

            Assert.Equal(TiedUp.Core.TiedUp.ERROR_OUT_OF_RANGE, r);
        }
Beispiel #4
0
        public void tiedUp_storage_with_different_tiedUpSpec()
        {
            TiedUp.Core.TiedUpSpec schedulledDaysSpec = new TiedUp.Core.TiedUpSpec("schedulledDays", 1, 31);

            TiedUp.Core.TiedUp tiedUp = new TiedUp.Core.TiedUp(schedulledDaysSpec);

            int r = tiedUp.Mark(0);

            TiedUp.Core.TiedUpSpec anotherSpec = new TiedUp.Core.TiedUpSpec("schedulledDays", 1, 30);

            TiedUp.Core.TiedUp anotherTiedUp = new TiedUp.Core.TiedUp(anotherSpec);

            r = anotherTiedUp.Mark(0);

            Assert.Equal(r, TiedUp.Core.TiedUp.ERROR_TIEDUP_DIFFERENT_TIEDUP_SPEC);
        }
Beispiel #5
0
        public TiedUpSpec Build()
        {
            if (end <= start)
            {
                throw new ArgumentException("TiedUp Range invalid. The end is greater than start");
            }

            if (string.IsNullOrEmpty(id) || string.IsNullOrWhiteSpace(id))
            {
                throw new ArgumentException("TiedUp Id invalid. You need a not null or empty Id to TiedUp");
            }

            if (id.Length > Constants.MAX_LENGTH_FOR_ID)
            {
                throw new ArgumentException("TiedUp Id must be have a length between 01 and 30 chars");
            }

            TiedUpSpec tiedUpSpec = new TiedUpSpec();


            tiedUpSpec.Start = this.start;
            tiedUpSpec.End   = this.end;

            unsafe
            {
                // Initializing Header from struct
                tiedUpSpec.Header[0] = (byte)'T';
                tiedUpSpec.Header[1] = (byte)'I';
                tiedUpSpec.Header[2] = (byte)'E';
                // Version of Struct + File
                tiedUpSpec.Header[3] = (byte)'1';
                tiedUpSpec.Header[4] = (byte)'0';
                tiedUpSpec.Header[5] = (byte)'0';

                char[] managedCharArray = id.ToCharArray();
                char * pId = tiedUpSpec.Id;

                Marshal.Copy(managedCharArray, 0, (IntPtr)pId, Math.Min(id.Length, Constants.MAX_LENGTH_FOR_ID));
            }

            return(tiedUpSpec);
        }
Beispiel #6
0
 public TiedUp(TiedUpSpec tiedUpSpec)
 {
     this.tiedUpSpec = tiedUpSpec;
 }