//******************************************************************************************************// SpeedTest.cs - Gbtc//// Copyright © 2012, Grid Protection Alliance. All Rights Reserved.//// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See// the NOTICE file distributed with this work for additional information regarding copyright ownership.// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may// not use this file except in compliance with the License. You may obtain a copy of the License at://// http://www.opensource.org/licenses/MIT//// Unless agreed to in writing, the subject software distributed under the License is distributed on an// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the// License for the specific language governing permissions and limitations.//// Code Modification History:// ----------------------------------------------------------------------------------------------------// 02/01/2011 - Denis Kholine// 12/13/2012 - Starlynn Danyelle Gilliam// Modified Header.////****************************************************************************************************** #region [ University of Illinois/NCSA Open Source License ]/*Copyright © <2012> <University of Illinois>All rights reserved. Developed by: <ITI><University of Illinois><http://www.iti.illinois.edu/>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal with the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:• Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimers.• Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimers in the documentation and/or other materials provided with the distribution.• Neither the names of <Name of Development Group, Name of Institution>, nor the names of its contributors may be used to endorse or promote products derived from this Software without specific prior written permission.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.*/#endregion using System;using System.Collections.Generic;using System.Globalization;using GSF.Units;using Microsoft.VisualStudio.TestTools.UnitTesting; namespace GSF.Core.Tests{ /// <summary> ///This is a test class for SpeedTest and is intended ///to contain all SpeedTest Unit Tests ///</summary> [TestClass] public class SpeedTest { private TestContext testContextInstance; /// <summary> ///Gets or sets the test context which provides ///information about and functionality for the current test run. ///</summary> public TestContext TestContext { get { return testContextInstance; } set { testContextInstance = value; } } #region Additional test attributes // //You can use the following additional attributes as you write your tests: // //Use ClassInitialize to run code before running the first test in the class //[ClassInitialize()] //public static void MyClassInitialize(TestContext testContext) //{ //} // //Use ClassCleanup to run code after all tests in a class have run //[ClassCleanup()] //public static void MyClassCleanup() //{ //} // //Use TestInitialize to run code before running each test //[TestInitialize()] //public void MyTestInitialize() //{ //} // //Use TestCleanup to run code after each test has run //[TestCleanup()] //public void MyTestCleanup() //{ //} // #endregion /// <summary> /// A test for Speed Constructor /// Creates a new <see cref="Speed"/>. /// </summary> /// <param name="value">New speed value in meters per second.</param> [TestMethod] public void SpeedConstructorTest() { List<Double> values = new List<Double>(); //Initialization values.Add(0); foreach (Double value in values) { Speed target = new Speed(value); Assert.IsInstanceOfType(target, typeof(Speed)); Assert.IsNotNull(target); } values.Clear(); } /// <summary> /// A test for CompareTo /// Compares this instance to a specified <see cref="Speed"/> and returns an indication of their /// relative values. /// </summary> /// <param name="value">A <see cref="Speed"/> to compare.</param> /// <returns> /// A signed number indicating the relative values of this instance and value. Returns less than zero /// if this instance is less than value, zero if this instance is equal to value, or greater than zero /// if this instance is greater than value. /// </returns> [TestMethod] public void CompareToSpeenTest() { Speed target = new Speed(10F); Speed value = new Speed(10F); int expected = 0; int actual; actual = target.CompareTo(value); Assert.AreEqual(expected, actual); } /// <summary> /// A test for CompareTo /// Compares this instance to a specified object and returns an indication of their relative values. /// </summary> /// <param name="value">An object to compare, or null.</param> /// <returns> /// A signed number indicating the relative values of this instance and value. Returns less than zero /// if this instance is less than value, zero if this instance is equal to value, or greater than zero /// if this instance is greater than value. /// </returns> /// <exception cref="ArgumentException">value is not a <see cref="Double"/> or <see cref="Speed"/>.</exception> [TestMethod] public void CompareToObjectTest() { Speed target = new Speed(10F); object value = new Speed(10F); int expected = 0; int actual; actual = target.CompareTo(value); Assert.AreEqual(expected, actual); } /// <summary> /// A test for CompareTo /// Compares this instance to a specified <see cref="Double"/> and returns an indication of their /// relative values. /// </summary> /// <param name="value">A <see cref="Double"/> to compare.</param> /// <returns> /// A signed number indicating the relative values of this instance and value. Returns less than zero /// if this instance is less than value, zero if this instance is equal to value, or greater than zero /// if this instance is greater than value. /// </returns> [TestMethod] public void CompareToDoubleTest() { Speed target = new Speed(10F); double value = 10F; int expected = 0; int actual; actual = target.CompareTo(value); Assert.AreEqual(expected, actual); } /// <summary> /// A test for Equals /// Returns a value indicating whether this instance is equal to a specified <see cref="Double"/> value. /// </summary> /// <param name="obj">A <see cref="Double"/> value to compare to this instance.</param> /// <returns> /// True if obj has the same value as this instance; otherwise, False. /// </returns> [TestMethod] public void EqualsDoubleTest() { Speed target = new Speed(10F); double obj = 10F; bool expected = true; bool actual; actual = target.Equals(obj); Assert.AreEqual(expected, actual); } /// <summary> /// A test for Equals /// Returns a value indicating whether this instance is equal to a specified object. /// </summary> /// <param name="obj">An object to compare, or null.</param> /// <returns> /// True if obj is an instance of <see cref="Double"/> or <see cref="Speed"/> and equals the value of this instance; /// otherwise, False. /// </returns> [TestMethod] public void EqualsObjectTest() { Speed target = new Speed(10F); object obj = new Speed(10F); bool expected = true; bool actual; actual = target.Equals(obj); Assert.AreEqual(expected, actual); } /// <summary> /// A test for Equals /// Returns a value indicating whether this instance is equal to a specified <see cref="Speed"/> value. /// </summary> /// <param name="obj">A <see cref="Speed"/> value to compare to this instance.</param> /// <returns> /// True if obj has the same value as this instance; otherwise, False. /// </returns> [TestMethod] public void EqualsSpeedTest() { Speed target = new Speed(10F); Speed obj = new Speed(10F); bool expected = true; bool actual; actual = target.Equals(obj); Assert.AreEqual(expected, actual); } ///// <summary> ///// A test for FromFeetPerMinute ///// Creates a new <see cref="Speed"/> value from the specified <paramref name="value"/> in feet per minute. ///// </summary> ///// <param name="value">New <see cref="Speed"/> value in feet per minute.</param> ///// <returns>New <see cref="Speed"/> object from the specified <paramref name="value"/> in feet per minute.</returns> //[TestMethod] //public void FromFeetPerMinuteTest() //{ // double value = 10F; // Speed expected = new Speed(0.0508); // Speed actual; // actual = Speed.FromFeetPerMinute(value); // Assert.AreEqual(expected, actual); //} /// <summary> /// A test for FromInchesPerSecond /// Creates a new <see cref="Speed"/> value from the specified <paramref name="value"/> in inches per second. /// </summary> /// <param name="value">New <see cref="Speed"/> value in inches per second.</param> /// <returns>New <see cref="Speed"/> object from the specified <paramref name="value"/> in inches per second.</returns> [TestMethod] public void FromInchesPerSecondTest() { double value = 10F; Speed expected = new Speed(0.254); Speed actual; actual = Speed.FromInchesPerSecond(value); Assert.AreEqual(expected, actual); } /// <summary> /// A test for FromKilometersPerHour /// Creates a new <see cref="Speed"/> value from the specified <paramref name="value"/> in kilometers per hour. /// </summary> /// <param name="value">New <see cref="Speed"/> value in kilometers per hour.</param> /// <returns>New <see cref="Speed"/> object from the specified <paramref name="value"/> in kilometers per hour.</returns> [TestMethod] public void FromKilometersPerHourTest() { double value = 10F; Speed expected = new Speed(2.777778); Speed actual; actual = Speed.FromKilometersPerHour(value); Assert.AreEqual(expected, actual); } /// <summary> /// A test for FromKnots /// Creates a new <see cref="Speed"/> value from the specified <paramref name="value"/> in knots (International). /// </summary> /// <param name="value">New <see cref="Speed"/> value in knots.</param> /// <returns>New <see cref="Speed"/> object from the specified <paramref name="value"/> in knots.</returns> [TestMethod] public void FromKnotsTest() { double value = 10F; Speed expected = new Speed(5.14444); Speed actual; actual = Speed.FromKnots(value); Assert.AreEqual(expected, actual); } ///// <summary> ///// A test for FromMach ///// Creates a new <see cref="Speed"/> value from the specified <paramref name="value"/> in mach. ///// </summary> ///// <param name="value">New <see cref="Speed"/> value in mach.</param> ///// <returns>New <see cref="Speed"/> object from the specified <paramref name="value"/> in mach.</returns> //[TestMethod] //public void FromMachTest() //{ // double value = 10F; // Speed expected = new Speed(3310); // Speed actual; // actual = Speed.FromMach(value); // Assert.AreEqual(expected, actual); //} /// <summary> /// A test for FromMilesPerHour /// Creates a new <see cref="Speed"/> value from the specified <paramref name="value"/> in miles per hour. /// </summary> /// <param name="value">New <see cref="Speed"/> value in miles per hour.</param> /// <returns>New <see cref="Speed"/> object from the specified <paramref name="value"/> in miles per hour.</returns> [TestMethod] public void FromMilesPerHourTest() { double value = 10F; Speed expected = new Speed(4.4704); Speed actual; actual = Speed.FromMilesPerHour(value); Assert.AreEqual(expected, actual); } /// <summary> /// A test for GetHashCode /// Returns the hash code for this instance. /// </summary> /// <returns> /// A 32-bit signed integer hash code. /// </returns> [TestMethod] public void GetHashCodeTest() { Speed target = new Speed(10F); int expected = 1076101120; int actual; actual = target.GetHashCode(); Assert.AreEqual(expected, actual); } /// <summary> /// A test for GetTypeCode /// Returns the <see cref="TypeCode"/> for value type <see cref="Double"/>. /// </summary> /// <returns>The enumerated constant, <see cref="TypeCode.Double"/>.</returns> [TestMethod] public void GetTypeCodeTest() { Speed target = new Speed(10F); TypeCode expected = new TypeCode(); expected = Type.GetTypeCode(typeof(Double)); TypeCode actual; actual = target.GetTypeCode(); Assert.AreEqual(expected, actual); } /// <summary> /// A test for Parse /// Converts the string representation of a number in a specified style to its <see cref="Speed"/> equivalent. /// </summary> /// <param name="s">A string containing a number to convert.</param> /// <param name="style"> /// A bitwise combination of System.Globalization.NumberStyles values that indicates the permitted format of s. /// </param> /// <returns> /// A <see cref="Speed"/> equivalent to the number contained in s. /// </returns> /// <exception cref="ArgumentException"> /// style is not a System.Globalization.NumberStyles value. -or- style is not a combination of /// System.Globalization.NumberStyles.AllowHexSpecifier and System.Globalization.NumberStyles.HexNumber values. /// </exception> /// <exception cref="ArgumentNullException">s is null.</exception> /// <exception cref="OverflowException"> /// s represents a number less than <see cref="Speed.MinValue"/> or greater than <see cref="Speed.MaxValue"/>. /// </exception> /// <exception cref="FormatException">s is not in a format compliant with style.</exception> [TestMethod] public void ParseStyleTest() { double value = 10F; string s = value.ToString(); NumberStyles style = new NumberStyles(); Speed expected = new Speed(value); Speed actual; actual = Speed.Parse(s, style); Assert.AreEqual(expected, actual); } /// <summary> /// A test for Parse /// Converts the string representation of a number in a specified style and culture-specific format to its <see cref="Speed"/> equivalent. /// </summary> /// <param name="s">A string containing a number to convert.</param> /// <param name="style"> /// A bitwise combination of System.Globalization.NumberStyles values that indicates the permitted format of s. /// </param> /// <param name="provider"> /// A <see cref="System.IFormatProvider"/> that supplies culture-specific formatting information about s. /// </param> /// <returns> /// A <see cref="Speed"/> equivalent to the number contained in s. /// </returns> /// <exception cref="ArgumentException"> /// style is not a System.Globalization.NumberStyles value. -or- style is not a combination of /// System.Globalization.NumberStyles.AllowHexSpecifier and System.Globalization.NumberStyles.HexNumber values. /// </exception> /// <exception cref="ArgumentNullException">s is null.</exception> /// <exception cref="OverflowException"> /// s represents a number less than <see cref="Speed.MinValue"/> or greater than <see cref="Speed.MaxValue"/>. /// </exception> /// <exception cref="FormatException">s is not in a format compliant with style.</exception> [TestMethod] public void ParseStyleProviderTest() { double value = 10F; string s = value.ToString(); NumberStyles style = new NumberStyles(); IFormatProvider provider = null; Speed expected = new Speed(value); Speed actual; actual = Speed.Parse(s, style, provider); Assert.AreEqual(expected, actual); } /// <summary> /// A test for Parse /// Converts the string representation of a number in a specified culture-specific format to its <see cref="Speed"/> equivalent. /// </summary> /// <param name="s">A string containing a number to convert.</param> /// <param name="provider"> /// A <see cref="System.IFormatProvider"/> that supplies culture-specific formatting information about s. /// </param> /// <returns> /// A <see cref="Speed"/> equivalent to the number contained in s. /// </returns> /// <exception cref="ArgumentNullException">s is null.</exception> /// <exception cref="OverflowException"> /// s represents a number less than <see cref="Speed.MinValue"/> or greater than <see cref="Speed.MaxValue"/>. /// </exception> /// <exception cref="FormatException">s is not in the correct format.</exception> [TestMethod] public void ParseProviderTest() { double value = 10F; string s = value.ToString(); IFormatProvider provider = null; Speed expected = new Speed(value); Speed actual; actual = Speed.Parse(s, provider); Assert.AreEqual(expected, actual); } /// <summary> /// A test for Parse /// Converts the string representation of a number to its <see cref="Speed"/> equivalent. /// </summary> /// <param name="s">A string containing a number to convert.</param> /// <returns> /// A <see cref="Speed"/> equivalent to the number contained in s. /// </returns> /// <exception cref="ArgumentNullException">s is null.</exception> /// <exception cref="OverflowException"> /// s represents a number less than <see cref="Speed.MinValue"/> or greater than <see cref="Speed.MaxValue"/>. /// </exception> /// <exception cref="FormatException">s is not in the correct format.</exception> [TestMethod] public void ParseStringTest() { double value = 10F; string s = value.ToString(); Speed expected = new Speed(10F); Speed actual; actual = Speed.Parse(s); Assert.AreEqual(expected, actual); }Lines 1–500 of 1158. Load more
//****************************************************************************************************** // SpeedTest.cs - Gbtc // // Copyright © 2012, Grid Protection Alliance. All Rights Reserved. // // Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See // the NOTICE file distributed with this work for additional information regarding copyright ownership. // The GPA licenses this file to you under the MIT License (MIT), the "License"; you may // not use this file except in compliance with the License. You may obtain a copy of the License at: // // http://www.opensource.org/licenses/MIT // // Unless agreed to in writing, the subject software distributed under the License is distributed on an // "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the // License for the specific language governing permissions and limitations. // // Code Modification History: // ---------------------------------------------------------------------------------------------------- // 02/01/2011 - Denis Kholine // 12/13/2012 - Starlynn Danyelle Gilliam // Modified Header. // //****************************************************************************************************** #region [ University of Illinois/NCSA Open Source License ] /* Copyright © <2012> <University of Illinois> All rights reserved. Developed by: <ITI> <University of Illinois> <http://www.iti.illinois.edu/> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal with the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimers. • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimers in the documentation and/or other materials provided with the distribution. • Neither the names of <Name of Development Group, Name of Institution>, nor the names of its contributors may be used to endorse or promote products derived from this Software without specific prior written permission. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. */ #endregion using System; using System.Collections.Generic; using System.Globalization; using GSF.Units; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace GSF.Core.Tests { /// <summary> ///This is a test class for SpeedTest and is intended ///to contain all SpeedTest Unit Tests ///</summary> [TestClass] public class SpeedTest { private TestContext testContextInstance; /// <summary> ///Gets or sets the test context which provides ///information about and functionality for the current test run. ///</summary> public TestContext TestContext { get { return testContextInstance; } set { testContextInstance = value; } } #region Additional test attributes // //You can use the following additional attributes as you write your tests: // //Use ClassInitialize to run code before running the first test in the class //[ClassInitialize()] //public static void MyClassInitialize(TestContext testContext) //{ //} // //Use ClassCleanup to run code after all tests in a class have run //[ClassCleanup()] //public static void MyClassCleanup() //{ //} // //Use TestInitialize to run code before running each test //[TestInitialize()] //public void MyTestInitialize() //{ //} // //Use TestCleanup to run code after each test has run //[TestCleanup()] //public void MyTestCleanup() //{ //} // #endregion /// <summary> /// A test for Speed Constructor /// Creates a new <see cref="Speed"/>. /// </summary> /// <param name="value">New speed value in meters per second.</param> [TestMethod] public void SpeedConstructorTest() { List<Double> values = new List<Double>(); //Initialization values.Add(0); foreach (Double value in values) { Speed target = new Speed(value); Assert.IsInstanceOfType(target, typeof(Speed)); Assert.IsNotNull(target); } values.Clear(); } /// <summary> /// A test for CompareTo /// Compares this instance to a specified <see cref="Speed"/> and returns an indication of their /// relative values. /// </summary> /// <param name="value">A <see cref="Speed"/> to compare.</param> /// <returns> /// A signed number indicating the relative values of this instance and value. Returns less than zero /// if this instance is less than value, zero if this instance is equal to value, or greater than zero /// if this instance is greater than value. /// </returns> [TestMethod] public void CompareToSpeenTest() { Speed target = new Speed(10F); Speed value = new Speed(10F); int expected = 0; int actual; actual = target.CompareTo(value); Assert.AreEqual(expected, actual); } /// <summary> /// A test for CompareTo /// Compares this instance to a specified object and returns an indication of their relative values. /// </summary> /// <param name="value">An object to compare, or null.</param> /// <returns> /// A signed number indicating the relative values of this instance and value. Returns less than zero /// if this instance is less than value, zero if this instance is equal to value, or greater than zero /// if this instance is greater than value. /// </returns> /// <exception cref="ArgumentException">value is not a <see cref="Double"/> or <see cref="Speed"/>.</exception> [TestMethod] public void CompareToObjectTest() { Speed target = new Speed(10F); object value = new Speed(10F); int expected = 0; int actual; actual = target.CompareTo(value); Assert.AreEqual(expected, actual); } /// <summary> /// A test for CompareTo /// Compares this instance to a specified <see cref="Double"/> and returns an indication of their /// relative values. /// </summary> /// <param name="value">A <see cref="Double"/> to compare.</param> /// <returns> /// A signed number indicating the relative values of this instance and value. Returns less than zero /// if this instance is less than value, zero if this instance is equal to value, or greater than zero /// if this instance is greater than value. /// </returns> [TestMethod] public void CompareToDoubleTest() { Speed target = new Speed(10F); double value = 10F; int expected = 0; int actual; actual = target.CompareTo(value); Assert.AreEqual(expected, actual); } /// <summary> /// A test for Equals /// Returns a value indicating whether this instance is equal to a specified <see cref="Double"/> value. /// </summary> /// <param name="obj">A <see cref="Double"/> value to compare to this instance.</param> /// <returns> /// True if obj has the same value as this instance; otherwise, False. /// </returns> [TestMethod] public void EqualsDoubleTest() { Speed target = new Speed(10F); double obj = 10F; bool expected = true; bool actual; actual = target.Equals(obj); Assert.AreEqual(expected, actual); } /// <summary> /// A test for Equals /// Returns a value indicating whether this instance is equal to a specified object. /// </summary> /// <param name="obj">An object to compare, or null.</param> /// <returns> /// True if obj is an instance of <see cref="Double"/> or <see cref="Speed"/> and equals the value of this instance; /// otherwise, False. /// </returns> [TestMethod] public void EqualsObjectTest() { Speed target = new Speed(10F); object obj = new Speed(10F); bool expected = true; bool actual; actual = target.Equals(obj); Assert.AreEqual(expected, actual); } /// <summary> /// A test for Equals /// Returns a value indicating whether this instance is equal to a specified <see cref="Speed"/> value. /// </summary> /// <param name="obj">A <see cref="Speed"/> value to compare to this instance.</param> /// <returns> /// True if obj has the same value as this instance; otherwise, False. /// </returns> [TestMethod] public void EqualsSpeedTest() { Speed target = new Speed(10F); Speed obj = new Speed(10F); bool expected = true; bool actual; actual = target.Equals(obj); Assert.AreEqual(expected, actual); } ///// <summary> ///// A test for FromFeetPerMinute ///// Creates a new <see cref="Speed"/> value from the specified <paramref name="value"/> in feet per minute. ///// </summary> ///// <param name="value">New <see cref="Speed"/> value in feet per minute.</param> ///// <returns>New <see cref="Speed"/> object from the specified <paramref name="value"/> in feet per minute.</returns> //[TestMethod] //public void FromFeetPerMinuteTest() //{ // double value = 10F; // Speed expected = new Speed(0.0508); // Speed actual; // actual = Speed.FromFeetPerMinute(value); // Assert.AreEqual(expected, actual); //} /// <summary> /// A test for FromInchesPerSecond /// Creates a new <see cref="Speed"/> value from the specified <paramref name="value"/> in inches per second. /// </summary> /// <param name="value">New <see cref="Speed"/> value in inches per second.</param> /// <returns>New <see cref="Speed"/> object from the specified <paramref name="value"/> in inches per second.</returns> [TestMethod] public void FromInchesPerSecondTest() { double value = 10F; Speed expected = new Speed(0.254); Speed actual; actual = Speed.FromInchesPerSecond(value); Assert.AreEqual(expected, actual); } /// <summary> /// A test for FromKilometersPerHour /// Creates a new <see cref="Speed"/> value from the specified <paramref name="value"/> in kilometers per hour. /// </summary> /// <param name="value">New <see cref="Speed"/> value in kilometers per hour.</param> /// <returns>New <see cref="Speed"/> object from the specified <paramref name="value"/> in kilometers per hour.</returns> [TestMethod] public void FromKilometersPerHourTest() { double value = 10F; Speed expected = new Speed(2.777778); Speed actual; actual = Speed.FromKilometersPerHour(value); Assert.AreEqual(expected, actual); } /// <summary> /// A test for FromKnots /// Creates a new <see cref="Speed"/> value from the specified <paramref name="value"/> in knots (International). /// </summary> /// <param name="value">New <see cref="Speed"/> value in knots.</param> /// <returns>New <see cref="Speed"/> object from the specified <paramref name="value"/> in knots.</returns> [TestMethod] public void FromKnotsTest() { double value = 10F; Speed expected = new Speed(5.14444); Speed actual; actual = Speed.FromKnots(value); Assert.AreEqual(expected, actual); } ///// <summary> ///// A test for FromMach ///// Creates a new <see cref="Speed"/> value from the specified <paramref name="value"/> in mach. ///// </summary> ///// <param name="value">New <see cref="Speed"/> value in mach.</param> ///// <returns>New <see cref="Speed"/> object from the specified <paramref name="value"/> in mach.</returns> //[TestMethod] //public void FromMachTest() //{ // double value = 10F; // Speed expected = new Speed(3310); // Speed actual; // actual = Speed.FromMach(value); // Assert.AreEqual(expected, actual); //} /// <summary> /// A test for FromMilesPerHour /// Creates a new <see cref="Speed"/> value from the specified <paramref name="value"/> in miles per hour. /// </summary> /// <param name="value">New <see cref="Speed"/> value in miles per hour.</param> /// <returns>New <see cref="Speed"/> object from the specified <paramref name="value"/> in miles per hour.</returns> [TestMethod] public void FromMilesPerHourTest() { double value = 10F; Speed expected = new Speed(4.4704); Speed actual; actual = Speed.FromMilesPerHour(value); Assert.AreEqual(expected, actual); } /// <summary> /// A test for GetHashCode /// Returns the hash code for this instance. /// </summary> /// <returns> /// A 32-bit signed integer hash code. /// </returns> [TestMethod] public void GetHashCodeTest() { Speed target = new Speed(10F); int expected = 1076101120; int actual; actual = target.GetHashCode(); Assert.AreEqual(expected, actual); } /// <summary> /// A test for GetTypeCode /// Returns the <see cref="TypeCode"/> for value type <see cref="Double"/>. /// </summary> /// <returns>The enumerated constant, <see cref="TypeCode.Double"/>.</returns> [TestMethod] public void GetTypeCodeTest() { Speed target = new Speed(10F); TypeCode expected = new TypeCode(); expected = Type.GetTypeCode(typeof(Double)); TypeCode actual; actual = target.GetTypeCode(); Assert.AreEqual(expected, actual); } /// <summary> /// A test for Parse /// Converts the string representation of a number in a specified style to its <see cref="Speed"/> equivalent. /// </summary> /// <param name="s">A string containing a number to convert.</param> /// <param name="style"> /// A bitwise combination of System.Globalization.NumberStyles values that indicates the permitted format of s. /// </param> /// <returns> /// A <see cref="Speed"/> equivalent to the number contained in s. /// </returns> /// <exception cref="ArgumentException"> /// style is not a System.Globalization.NumberStyles value. -or- style is not a combination of /// System.Globalization.NumberStyles.AllowHexSpecifier and System.Globalization.NumberStyles.HexNumber values. /// </exception> /// <exception cref="ArgumentNullException">s is null.</exception> /// <exception cref="OverflowException"> /// s represents a number less than <see cref="Speed.MinValue"/> or greater than <see cref="Speed.MaxValue"/>. /// </exception> /// <exception cref="FormatException">s is not in a format compliant with style.</exception> [TestMethod] public void ParseStyleTest() { double value = 10F; string s = value.ToString(); NumberStyles style = new NumberStyles(); Speed expected = new Speed(value); Speed actual; actual = Speed.Parse(s, style); Assert.AreEqual(expected, actual); } /// <summary> /// A test for Parse /// Converts the string representation of a number in a specified style and culture-specific format to its <see cref="Speed"/> equivalent. /// </summary> /// <param name="s">A string containing a number to convert.</param> /// <param name="style"> /// A bitwise combination of System.Globalization.NumberStyles values that indicates the permitted format of s. /// </param> /// <param name="provider"> /// A <see cref="System.IFormatProvider"/> that supplies culture-specific formatting information about s. /// </param> /// <returns> /// A <see cref="Speed"/> equivalent to the number contained in s. /// </returns> /// <exception cref="ArgumentException"> /// style is not a System.Globalization.NumberStyles value. -or- style is not a combination of /// System.Globalization.NumberStyles.AllowHexSpecifier and System.Globalization.NumberStyles.HexNumber values. /// </exception> /// <exception cref="ArgumentNullException">s is null.</exception> /// <exception cref="OverflowException"> /// s represents a number less than <see cref="Speed.MinValue"/> or greater than <see cref="Speed.MaxValue"/>. /// </exception> /// <exception cref="FormatException">s is not in a format compliant with style.</exception> [TestMethod] public void ParseStyleProviderTest() { double value = 10F; string s = value.ToString(); NumberStyles style = new NumberStyles(); IFormatProvider provider = null; Speed expected = new Speed(value); Speed actual; actual = Speed.Parse(s, style, provider); Assert.AreEqual(expected, actual); } /// <summary> /// A test for Parse /// Converts the string representation of a number in a specified culture-specific format to its <see cref="Speed"/> equivalent. /// </summary> /// <param name="s">A string containing a number to convert.</param> /// <param name="provider"> /// A <see cref="System.IFormatProvider"/> that supplies culture-specific formatting information about s. /// </param> /// <returns> /// A <see cref="Speed"/> equivalent to the number contained in s. /// </returns> /// <exception cref="ArgumentNullException">s is null.</exception> /// <exception cref="OverflowException"> /// s represents a number less than <see cref="Speed.MinValue"/> or greater than <see cref="Speed.MaxValue"/>. /// </exception> /// <exception cref="FormatException">s is not in the correct format.</exception> [TestMethod] public void ParseProviderTest() { double value = 10F; string s = value.ToString(); IFormatProvider provider = null; Speed expected = new Speed(value); Speed actual; actual = Speed.Parse(s, provider); Assert.AreEqual(expected, actual); } /// <summary> /// A test for Parse /// Converts the string representation of a number to its <see cref="Speed"/> equivalent. /// </summary> /// <param name="s">A string containing a number to convert.</param> /// <returns> /// A <see cref="Speed"/> equivalent to the number contained in s. /// </returns> /// <exception cref="ArgumentNullException">s is null.</exception> /// <exception cref="OverflowException"> /// s represents a number less than <see cref="Speed.MinValue"/> or greater than <see cref="Speed.MaxValue"/>. /// </exception> /// <exception cref="FormatException">s is not in the correct format.</exception> [TestMethod] public void ParseStringTest() { double value = 10F; string s = value.ToString(); Speed expected = new Speed(10F); Speed actual; actual = Speed.Parse(s); Assert.AreEqual(expected, actual); }