public void TestEqualityWithWrongType() { UnitSpherical first = new UnitSpherical(1.0, 2.0); Cartographic second = new Cartographic(1.0, 2.0, 3.0); Assert.IsFalse(first.Equals(second)); }
public void TestHoldValue() { UnitSpherical test = new UnitSpherical(1.0, 2.0); Assert.AreEqual(1.0, test.Clock); Assert.AreEqual(2.0, test.Cone); }
/// <summary> /// Writes a <see cref="UnitSpherical"/> value as an array in Clock, Cone order. /// </summary> /// <param name="output">The stream to which to write the value.</param> /// <param name="value">The value to write.</param> public static void WriteUnitSpherical(CesiumOutputStream output, UnitSpherical value) { output.WriteStartSequence(); output.WriteValue(value.Clock); output.WriteValue(value.Cone); output.WriteEndSequence(); }
public void TestEqualsEpsilonExact() { UnitSpherical first = new UnitSpherical(0.1, 0.1); UnitSpherical second = new UnitSpherical(0.1, 0.1); Assert.IsTrue(second.EqualsEpsilon(first, 0)); }
public void TestEqualityWithWrongType() { UnitSpherical first = new UnitSpherical(1.0, 2.0); Cartographic second = new Cartographic(1.0, 2.0, 3.0); // ReSharper disable once SuspiciousTypeConversion.Global Assert.IsFalse(first.Equals(second)); }
public void TestFromUnitCartesian() { double fortyFiveDegrees = Math.PI / 4.0; double sixtyDegrees = Math.PI / 3.0; UnitSpherical test = new UnitSpherical(new UnitCartesian(1.0, Math.Sqrt(3.0), -2.0)); Assert.AreEqual(sixtyDegrees, test.Clock, Constants.Epsilon15); Assert.AreEqual(fortyFiveDegrees + Math.PI / 2.0, test.Cone, Constants.Epsilon15); }
public void TestFromArray() { double[] values = { 2.0, 3.0 }; UnitSpherical test = new UnitSpherical(values); Assert.AreEqual(values.Length, test.Length); Assert.AreEqual(test.Clock, test[0]); Assert.AreEqual(test.Cone, test[1]); }
public void TestGetHashCode() { UnitSpherical object1 = new UnitSpherical(1.0, 2.0); UnitSpherical object2 = new UnitSpherical(1.0, 2.0); UnitSpherical object3 = new UnitSpherical(1.0, 2.1); Assert.AreEqual(object1.GetHashCode(), object2.GetHashCode()); Assert.AreNotEqual(object1.GetHashCode(), object3.GetHashCode()); }
public void TestEqualsEpsilon() { UnitSpherical first = new UnitSpherical(1e-1, 1e-2); UnitSpherical second = new UnitSpherical(1.1e-1, 1.1e-2); Assert.IsTrue(second.EqualsEpsilon(first, 1e-1)); Assert.IsTrue(second.EqualsEpsilon(first, 1e-2)); Assert.IsFalse(second.EqualsEpsilon(first, 1e-3)); Assert.IsFalse(second.EqualsEpsilon(first, 1e-4)); Assert.IsFalse(second.EqualsEpsilon(first, 1e-5)); }
public void TestFromUnitCartesian() { const double fortyFiveDegrees = Math.PI / 4.0; const double sixtyDegrees = Math.PI / 3.0; UnitSpherical test = new UnitSpherical(new UnitCartesian(1.0, Math.Sqrt(3.0), -2.0)); Assert.AreEqual(sixtyDegrees, test.Clock, Constants.Epsilon15); Assert.AreEqual(fortyFiveDegrees + Math.PI / 2.0, test.Cone, Constants.Epsilon15); }
public void TestToString() { StringBuilder builder = new StringBuilder(); builder.Append((-Math.PI).ToString(CultureInfo.CurrentCulture)); builder.Append(", "); builder.Append(Math.PI.ToString(CultureInfo.CurrentCulture)); UnitSpherical test = new UnitSpherical(-Math.PI, Math.PI); Assert.AreEqual(builder.ToString(), test.ToString()); }
public void TestEquality() { UnitSpherical first = new UnitSpherical(1.0, 2.0); UnitSpherical second = new UnitSpherical(1.0, 2.0); Assert.AreEqual(first, second); Assert.AreEqual(second, first); Assert.IsTrue(first == second); Assert.IsTrue(second == first); Assert.IsFalse(first != second); Assert.IsFalse(second != first); Assert.IsTrue(first.Equals(second)); Assert.IsTrue(second.Equals(first)); second = new UnitSpherical(1.0, 2.1); Assert.AreNotEqual(first, second); Assert.AreNotEqual(second, first); Assert.IsFalse(first == second); Assert.IsFalse(second == first); Assert.IsTrue(first != second); Assert.IsTrue(second != first); Assert.IsFalse(first.Equals(second)); Assert.IsFalse(second.Equals(first)); }
/// <summary> /// Writes time-tagged <see cref="UnitSpherical"/> values as an array in [Time, Clock, Cone] order. /// Times are epoch seconds since an epoch that is determined from the first date to be written. /// The epoch property is written as well. /// </summary> /// <param name="output">The stream to which to write the array.</param> /// <param name="propertyName">The name of the property to write.</param> /// <param name="dates">The dates at which the value is specified.</param> /// <param name="values">The corresponding value for each date.</param> /// <param name="startIndex">The index of the first element to use in the <paramref name="values"/> collection.</param> /// <param name="length">The number of elements to use from the <paramref name="values"/> collection.</param> public static void WriteUnitSpherical(CesiumOutputStream output, string propertyName, IList <JulianDate> dates, IList <UnitSpherical> values, int startIndex, int length) { if (dates.Count != values.Count) { throw new ArgumentException(CesiumLocalization.MismatchedNumberOfDatesAndValues, "values"); } JulianDate epoch = GetAndWriteEpoch(output, dates, startIndex, length); output.WritePropertyName(propertyName); output.WriteStartSequence(); int last = startIndex + length; for (int i = startIndex; i < last; ++i) { output.WriteValue(epoch.SecondsDifference(dates[i])); UnitSpherical value = values[i]; output.WriteValue(value.Clock); output.WriteValue(value.Cone); output.WriteLineBreak(); } output.WriteEndSequence(); }
public void TestIndexTooHigh() { UnitSpherical first = new UnitSpherical(1.0, 2.0); double bad = first[2]; }
public void TestIndexTooLow() { UnitSpherical first = new UnitSpherical(1.0, 2.0); double bad = first[-1]; }
public void TestInitializationFromNull() { double[] array = null; UnitSpherical first = new UnitSpherical(array, 0); }
public void TestInitializationFromBadArray() { double[] array = new double[1]; UnitSpherical first = new UnitSpherical(array, 0); }
public void TestToString() { StringBuilder s = new StringBuilder(80); s.Append((-Math.PI).ToString(CultureInfo.CurrentCulture)); s.Append(", "); s.Append(Math.PI.ToString(CultureInfo.CurrentCulture)); UnitSpherical test = new UnitSpherical(-Math.PI, Math.PI); Assert.AreEqual(s.ToString(), test.ToString()); }