Esempio n. 1
0
        public void AddDateTimeTimeSpan()
        {
            DateTime from  = DateTime.Today;
            TimeSpan delta = TimeSpan.FromHours(73.5);

            Assert.AreEqual(from + delta, Operator.AddAlternative(from, delta));
        }
Esempio n. 2
0
        public void AddValue(int sourceRowIndex)
        {
            var value = _sourceColumn.GetValue(sourceRowIndex);
            TIn existingSourceValue;

            if (_sourceValues.TryGetValue(sourceRowIndex, out existingSourceValue))
            {
                CurrentValue = Operator.SubtractAlternative(CurrentValue, existingSourceValue);
            }
            CurrentValue = Operator.AddAlternative(CurrentValue, value);
            _sourceValues[sourceRowIndex] = value;
        }
Esempio n. 3
0
        public static void Test_Vector3_Generic_Normalize <TMathType>(TMathType a, TMathType b, TMathType c)
            where TMathType : struct, IComparable <TMathType>, IEquatable <TMathType>
        {
            //arrange
            Vector3 <TMathType> vec3 = new Vector3 <TMathType>(a, b, c);

            //act
            //Can't directly call extension method. Cast to dynamic for testing purposes only
            Vector3 <TMathType> nVec3 = (Vector3 <TMathType>)GrabExtensionMethod <Vector3 <TMathType> >(typeof(Vector3Extensions), "Normalized")
                                        .Invoke(null, new object[] { vec3 });

            //assert
            //Asserts that 1 is equal to the magnitude
            if (Operator <TMathType> .GreaterThan(InvokeVector3ExtensionMethod("SqrMagnitude", vec3), Vector3 <TMathType> .kEpsilon))
            {
                Assert.AreEqual(Operator.Convert <TMathType, double>(Operator.AddAlternative(Operator <TMathType> .Zero, 1d)), InvokeVector3ExtensionMethod("SqrMagnitude", nVec3),
                                (dynamic)Vector3 <TMathType> .kEpsilon);
            }
            else
            {
                Assert.AreEqual(Operator <TMathType> .Zero, InvokeVector3ExtensionMethod("SqrMagnitude", nVec3));               //if the vector was too small the new magnitude is 0.
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Returns an iterator which steps through the range, adding the specified amount
 /// on each iteration. If the step amount is logically negative, the returned iterator
 /// begins at the end point; otherwise it begins at the start point. This method
 /// is equivalent to Step(T stepAmount), but allows an alternative type to be used.
 /// The most common example of this is likely to be stepping a range of DateTimes
 /// by a TimeSpan.
 /// This method does not check for
 /// the availability of a suitable addition operator at compile-time; if you use it
 /// on a range where there is no such operator, it will fail at execution time.
 /// </summary>
 /// <param name="stepAmount">The amount to add on each iteration</param>
 public RangeIterator <T> Step <TAmount>(TAmount stepAmount)
 {
     return(Step(t => Operator.AddAlternative(t, stepAmount)));
 }
Esempio n. 5
0
 /// <summary>
 /// Returns an iterator which begins at the start of this range,
 /// adding the given step amount to the current value each iteration until the
 /// end is reached or passed. The start and end points are included
 /// or excluded according to this range. This method does not check for
 /// the availability of an addition operator at compile-time; if you use it
 /// on a range where there is no such operator, it will fail at execution time.
 /// </summary>
 /// <param name="stepAmount">Amount to add on each iteration</param>
 public RangeIterator <T> UpBy <TAmount>(TAmount stepAmount)
 {
     return(new RangeIterator <T>(this, t => Operator.AddAlternative(t, stepAmount)));
 }