public void ValueOfDefaultIsFOREVER()
        {
            Duration isInfinite = new Duration();

            bool result = isInfinite.Milliseconds > 1.0E18;
            Assert.True(result);
        }
Beispiel #2
0
        public LivelinessQosPolicyImpl(LivelinessQosPolicyKind kind, Duration getLeaseDuration, Bootstrap boostrap)
            :base(boostrap)
        {
            this.KindQos  = kind;
            this.LeaseDurationQos = getLeaseDuration;

        }
 public void TestAddSeconds()
 {
     Duration test = new Duration(5, 43200.0);
     Duration result = test.AddSeconds(45.123);
     Assert.AreEqual(5, result.Days);
     Assert.AreEqual(43245.123, result.Seconds);
 }
 public void DaysToWaitTwoDays()
 {
     Duration d = new Duration();
     d.StartDate = new DateTime(2016, 1, 1);
     d.EndDate = new DateTime(2016, 1, 3);
     Assert.AreEqual(2, d.DaysToWait);
 }
        public void TestCompareTo()
        {
            Duration duration1 = new Duration(1, 0.0);
            Duration duration2 = new Duration(1, 0.0);
            Assert.IsTrue(duration1.CompareTo(duration2) == 0);
            Assert.IsTrue(duration2.CompareTo(duration1) == 0);
            Assert.IsTrue(duration1 >= duration2);
            Assert.IsTrue(duration2 <= duration1);
            Assert.IsTrue(duration1 <= duration2);
            Assert.IsTrue(duration2 >= duration1);

            duration2 = new Duration(2, 0.0);
            Assert.IsTrue(duration1.CompareTo(duration2) < 0);
            Assert.IsTrue(duration2.CompareTo(duration1) > 0);
            Assert.IsTrue(duration1 < duration2);
            Assert.IsTrue(duration2 > duration1);
            Assert.IsTrue(duration1 <= duration2);
            Assert.IsTrue(duration2 >= duration1);

            duration2 = new Duration(1, 1.0);
            Assert.IsTrue(duration1.CompareTo(duration2) < 0);
            Assert.IsTrue(duration2.CompareTo(duration1) > 0);
            Assert.IsTrue(duration1 < duration2);
            Assert.IsTrue(duration2 > duration1);
            Assert.IsTrue(duration1 <= duration2);
            Assert.IsTrue(duration2 >= duration1);
        }
 public void DaysToWaitUsingLeapYear()
 {
     Duration d = new Duration();
     d.StartDate = new DateTime(2000, 1, 1);
     d.EndDate = new DateTime(2001, 1, 1);
     Assert.AreEqual(366, d.DaysToWait);
 }
 public void OperatorDivision_Int64(int days, long nanoOfDay, long divisor, int expectedDays, long expectedNanoOfDay)
 {
     var duration = new Duration(days, nanoOfDay);
     var actual = duration / divisor;
     var expected = new Duration(expectedDays, expectedNanoOfDay);
     Assert.AreEqual(expected, actual);
 }
Beispiel #8
0
        public void TestEquality()
        {
            Duration first = new Duration(5, 565.0);
            Duration second = new Duration(5, 565.0);
            Assert.AreEqual(first, second);
            Assert.IsTrue(first.Equals(second));
            Assert.IsTrue(second.Equals(first));
            Assert.IsTrue(first == second);
            Assert.IsTrue(second == first);
            Assert.IsFalse(first != second);
            Assert.IsFalse(second != first);
            Assert.AreEqual(0, first.CompareTo(second));
            Assert.AreEqual(0, second.CompareTo(first));

            first = new Duration(5, 0.00001);
            second = new Duration(4, 86399.99999);
            Assert.AreNotEqual(first, second);
            Assert.IsFalse(first.Equals(second));
            Assert.IsFalse(second.Equals(first));
            Assert.IsFalse(first == second);
            Assert.IsFalse(second == first);
            Assert.IsTrue(first != second);
            Assert.IsTrue(second != first);
            Assert.AreNotEqual(0, first.CompareTo(second));
            Assert.AreNotEqual(0, second.CompareTo(first));
            Assert.IsTrue(first.EqualsEpsilon(second, 1e-4));
            Assert.IsTrue(second.EqualsEpsilon(first, 1e-4));

            // Make sure a Duration compared with a non-Duration returns false
            Assert.IsFalse(first.Equals(5));
        }
 public void TestAddDays()
 {
     Duration test = new Duration(5, 43200.0);
     Duration result = test.AddDays(45.5);
     Assert.AreEqual(51, result.Days);
     Assert.AreEqual(0.0, result.Seconds);
 }
 public void DaysPassedSinceJan01ToDec31()
 {
     Duration d = new Duration();
     d.StartDate = new DateTime(2015, 1, 1);
     d.EndDate = new DateTime(2015, 12, 31);
     Assert.AreEqual(1, d.DaysPassed);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AsyncDebouncedAction" /> class.
 /// </summary>
 /// <param name="action">The action.</param>
 /// <param name="duration">The duration is the amount of time the result of a successful execution is held, after the point a successful request was made.</param>
 /// <param name="minimumGap">The minimum gap, is the time left after a successful execution before the action can be run again.</param>
 public AsyncDebouncedAction(
     [NotNull] Func<Task> action,
     Duration duration,
     Duration minimumGap = default(Duration))
     : this(token => action(), duration, minimumGap)
 {
     if (action == null) throw new ArgumentNullException("action");
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DurationValidator" /> class.
 /// </summary>
 /// <param name="minValue">The minimum duration allowed to pass validation (inclusive).</param>
 /// <param name="maxValue">The maximum duration allowed to pass validation (exclusive).</param>
 /// <param name="rangeIsExclusive">If set to <see langword="true" /> the value must be outside the given range.</param>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="minValue" /> is greater than <paramref name="maxValue" />.</exception>
 public DurationValidator(Duration minValue, Duration maxValue, bool rangeIsExclusive = false)
 {
     if (minValue > maxValue)
         throw new ArgumentOutOfRangeException(nameof(minValue), Resources.Validator_MinGreaterThanMax);
     _minValue = minValue;
     _maxValue = maxValue;
     _exclusive = rangeIsExclusive;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CheckBoxBehavior" /> class.
 /// </summary>
 public CheckBoxBehavior()
     : base("CheckBehavior")
 {
     Duration duration = new Duration(TimeSpan.FromSeconds(.4f));
     this.fadeIn = new SingleAnimation(0, 1, duration);
     this.fadeOut = new SingleAnimation(1, 0, duration);
     this.isChecked = false;
 }
 public DurabilityServiceQosPolicyImpl(HistoryQosPolicyKind kind, Duration serviceCleanupDelay
     , int historyDepth, int getMaxSamplesQos, int getMaxInstancesQos, int getMaxSamplesPerInstanceQos, Bootstrap boostrap)
     : base(boostrap)
 {
     this.HistoryQosPolicyKind = kind;
     this.ServiceCleanupDelay = serviceCleanupDelay;
     this.HistoryDepth = historyDepth;
     this.MaxSamplesQos = getMaxSamplesQos;
     this.MaxInstancesQos = getMaxInstancesQos;
     this.MaxSamplesPerInstanceQos = getMaxSamplesPerInstanceQos;
 }
        public bool Get(long DocProformaInvoice_ID)
        {
            string Err = null;
            Clear();
            string sql = @"select
                            dpi.IssueDate,
                            dpi.DocDuration,
                            dpi.DocDurationType,
                            dpi.TermsOfPayment_ID,
                            dpi.MethodOfPayment_ID,
                            mop.Atom_BankAccount_ID,
                            top.Description as TermsOfPayment_Description,
                            mop.PaymentType,
                            aba.TRR,
                            ao.Name,
                            ao.Tax_ID,
                            ao.Registration_ID
                            from DocProformaInvoice dpi
                            left join  TermsOfPayment top on dpi.TermsOfPayment_ID = top.ID
                            left join  MethodOfPayment mop on dpi.MethodOfPayment_ID = mop.ID
                            left join  Atom_BankAccount aba on mop.Atom_BankAccount_ID = aba.ID
                            left join  Atom_Bank ab on aba.Atom_Bank_ID = ab.ID
                            left join  Atom_Organisation ao on ab.Atom_Organisation_ID = ao.ID
                            where dpi.ID = " + DocProformaInvoice_ID.ToString();
            DataTable dt = new DataTable();
            if (DBSync.DBSync.ReadDataTable(ref dt, sql, ref Err))
            {
                if (dt.Rows.Count > 0)
                {
                    m_IssueDate = DocProformaInvoice_AddOn.IssueDate.Set(dt.Rows[0]["IssueDate"]);
                    m_Duration = DocProformaInvoice_AddOn.Duration.Set(dt.Rows[0]["DocDuration"],
                                                                       dt.Rows[0]["DocDurationType"]);

                    m_TermsOfPayment = DocProformaInvoice_AddOn.TermsOfPayment.Set(dt.Rows[0]["TermsOfPayment_ID"],
                                                                                   dt.Rows[0]["TermsOfPayment_Description"]);

                    m_MethodOfPayment = DocProformaInvoice_AddOn.MethodOfPayment.Set(dt.Rows[0]["MethodOfPayment_ID"],
                                                                                     dt.Rows[0]["PaymentType"],
                                                                                     dt.Rows[0]["Name"],
                                                                                     dt.Rows[0]["Tax_ID"],
                                                                                     dt.Rows[0]["Registration_ID"],
                                                                                     dt.Rows[0]["TRR"],
                                                                                     dt.Rows[0]["Atom_BankAccount_ID"]);
                }
                return true;
            }
            else
            {
                LogFile.Error.Show("ERROR:TangentaDB:DocProformaInvoice_AddOn:Get:sql=" + sql + "\r\nErr=" + Err);
                return false;
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ScheduledActionResult"/> class.
 /// </summary>
 /// <param name="due">The due.</param>
 /// <param name="started">The started.</param>
 /// <param name="duration">The duration.</param>
 /// <param name="exception">The exception.</param>
 /// <param name="cancelled">if set to <see langword="true"/> the action was cancelled.</param>
 /// <remarks></remarks>
 protected ScheduledActionResult(
     Instant due,
     Instant started,
     Duration duration,
     [CanBeNull] Exception exception,
     bool cancelled)
 {
     Due = due;
     Started = started;
     Duration = duration;
     Exception = exception;
     Cancelled = cancelled;
 }
        public void UnsupportedOperations_ThrowNotSupportedException()
        {
            LocalInstant when = new LocalInstant();
            Duration duration = new Duration();

            AssertUnsupported(x => x.Add(when, 0));
            AssertUnsupported(x => x.Add(when, 0L));
            AssertUnsupported(x => x.GetDifference(when, when));
            AssertUnsupported(x => x.GetDuration(10));
            AssertUnsupported(x => x.GetDuration(10, when));
            AssertUnsupported(x => x.GetInt64Difference(when, when));
            AssertUnsupported(x => x.GetInt64Value(duration));
            AssertUnsupported(x => x.GetInt64Value(duration, when));
            AssertUnsupported(x => x.GetValue(duration));
            AssertUnsupported(x => x.GetValue(duration, when));
            AssertUnsupported(x => x.Subtract(when, 0));
            AssertUnsupported(x => x.Subtract(when, 0L));
        }
Beispiel #18
0
 public Track()
 {
     End = false;
     m_channel = new Channel();
     m_events = new List<Events.Event>(32);
     m_index = 0;
     m_delta = 0;
     GlobalTick = 0;
     m_needle = 0.0;
     #if true
     Duration = TimeSpan.FromMilliseconds(0);
     #else
     Duration = new Duration(TimeSpan.FromMilliseconds(0));
     #endif
     BPM = DEFAULT_BPM;
     RecordGate(15.0 / 16.0);
     RecordGate(0);
 }
Beispiel #19
0
        public override Score ReadScore()
        {
            try
            {
                CreateDefaultScore();
                _curChPos = 0;
                _currentDuration = Duration.Quarter;
                NextChar();
                NewSy();
                Score();

                _score.Finish();
                return _score;
            }
            catch (Exception)
            {
                throw new UnsupportedFormatException();
            }
        }
Beispiel #20
0
        public void TestNormalization()
        {
            // A duration's day and time should either be both negative or both positive
            Duration duration = new Duration(1, 100.0);
            Assert.AreEqual(1, duration.Days);
            Assert.AreEqual(100.0, duration.Seconds);

            duration = new Duration(-1, -100.0);
            Assert.AreEqual(-1, duration.Days);
            Assert.AreEqual(-100.0, duration.Seconds);

            duration = new Duration(-1, 100.0);
            Assert.AreEqual(0, duration.Days);
            Assert.AreEqual(-86300.0, duration.Seconds);

            duration = new Duration(1, -100.0);
            Assert.AreEqual(0, duration.Days);
            Assert.AreEqual(86300.0, duration.Seconds);
        }
        public void TestAddition()
        {
            Duration original = new Duration(5, 1000.0);
            Duration add = Duration.FromSeconds(50.0);
            Duration result = original + add;
            Assert.AreEqual(5, result.Days);
            Assert.AreEqual(1050.0, result.Seconds);

            original = new Duration(5, 8382.1);
            add = new Duration(1, 10.0);
            result = original + add;
            Assert.AreEqual(6, result.Days);
            Assert.AreEqual(8392.1, result.Seconds);

            original = new Duration(5, 86000.0);
            add = Duration.FromSeconds(1000.0);
            result = original + add;
            Assert.AreEqual(6, result.Days);
            Assert.AreEqual(600.0, result.Seconds);
        }
 public Activity(string name, DateTime openingHour, DateTime closingHour, DaysOpen daysOpen,
                 int minParticipants, int maxParticipants, Price studentPrice, Price adultPrice,
                 string address, EnergyNeeded energyNeeded, string materialNeeded, Transport transport,
                 Duration duration, Temperature temperature, Category category)
 {
     Name = name;
     OpeningHour = openingHour;
     ClosingHour = closingHour;
     DaysOpen = daysOpen;
     MinimumParticipants = minParticipants;
     MaximumParticipants = maxParticipants;
     StudentPrice = studentPrice;
     AdultPrice = adultPrice;
     Address = address;
     EnergyNeeded = energyNeeded;
     MaterialNeeded = materialNeeded;
     Transport = transport;
     Duration = duration;
     Temperature = temperature;
     Category = category;
 }
 private void GetDurations(int currentTotalLength, Duration duration, out int soundDuration, out int pauseDuration)
 {
     switch (duration)
     {
         case Duration.None:
             soundDuration = 0;
             pauseDuration = currentTotalLength;
             return;
         case Duration.Legato:
             soundDuration = currentTotalLength;
             pauseDuration = 0;
             return;
         case Duration.Normal:
             soundDuration = currentTotalLength*7/8;
             pauseDuration = currentTotalLength*1/8;
             return;
         case Duration.Stacatto:
             soundDuration = currentTotalLength*2/3;
             pauseDuration = currentTotalLength*1/3;
             return;
     }
     throw new NotSupportedException(string.Format("Unsupported duration {0}", duration));
 }
Beispiel #24
0
 public static extern ReturnCode wait_for_acknowledgments(
     IntPtr _this,
     ref Duration max_wait
     );
 //
 public static TimeSpan ToNMSTimespan(Duration duration)
 {
     if (duration.Milliseconds > Int64.MaxValue)
     {
         TimeSpan result = new TimeSpan(Int64.MaxValue);
         return result;
     }
     else
     {
         TimeSpan result = new TimeSpan((Int64)duration.Milliseconds);
         return result;
     }
 }
 //
 public static Duration ToQpidDuration(TimeSpan timespan)
 {
     if (timespan.TotalMilliseconds <= 0)
     {
         Duration result = DurationConstants.IMMEDIATE;
         return result;
     }
     else if (timespan.TotalMilliseconds > (Double)DurationConstants.FORVER.Milliseconds)
     {
         Duration result = DurationConstants.FORVER;
         return result;
     }
     else
     {
         Duration result = new Duration((UInt64)timespan.TotalMilliseconds);
         return result;
     }
 }
Beispiel #27
0
 public void TestSecondsGreaterThanADay()
 {
     Duration duration = new Duration(0, 107000.0);
     Assert.AreEqual(1, duration.Days);
     Assert.AreEqual(20600.0, duration.Seconds);
 }
Beispiel #28
0
        public void TestReallySmallSeconds()
        {
            Duration duration = new Duration(10, -Constants.Epsilon13);
            Assert.AreEqual(duration.Days, 10);
            Assert.AreEqual(0.0, duration.Seconds);

            duration = new Duration(-10, Constants.Epsilon13);
            Assert.AreEqual(duration.Days, -10);
            Assert.AreEqual(0.0, duration.Seconds);
        }
Beispiel #29
0
 public void TestToString()
 {
     Duration duration = new Duration(1, 43200.0);
     Assert.AreEqual(duration.ToString(), "1:43200");
 }
Beispiel #30
0
 public void TestTotalDays()
 {
     Duration duration = new Duration(1, 43200.0);
     Assert.AreEqual(1.5, duration.TotalDays);
 }