public void When_to_string_Then_pretty(string format, string expected) { var km = new Kilometers(25); string actual = km.ToString(format); Assert.That(actual, Is.EqualTo(expected)); }
public void When_converting_kilometers_Then_works(decimal distanceValue, Type type, decimal expected) { var distance = new Kilometers(distanceValue); var actual = distance.ConvertTo(type); Assert.That(actual.Value, Is.EqualTo(expected).Within(0.000001M)); }
public void Convert_Kilometers_and_NauticalMiles() { double M_km = new NauticalMiles(100).To<Kilometers>(); // 185.2 double km_M = new Kilometers(50).To<NauticalMiles>(); // 26.9978 Assert.AreEqual(185.2, Math.Round(M_km, 4)); Assert.AreEqual(26.9978, Math.Round(km_M, 4)); }
public void When_multiplying_Then_works() { var km = new Kilometers(1.25M); var actual = km.Multiply(2); Assert.That(actual.Value, Is.EqualTo(2.5M)); }
public void When_dividing_Then_works() { var km = new Kilometers(5M); var actual = km.Divide(2); Assert.That(actual.Value, Is.EqualTo(2.5M)); }
public void Convert_Kilometers_and_NauticalMiles() { double M_km = new NauticalMiles(100).To <Kilometers>(); // 185.2 double km_M = new Kilometers(50).To <NauticalMiles>(); // 26.9978 Assert.AreEqual(185.2, Math.Round(M_km, 4)); Assert.AreEqual(26.9978, Math.Round(km_M, 4)); }
public void When_equaling_Then_works() { var km = new Kilometers(1); var m = new Meters(1000); var actual = km.Equals(m); Assert.That(actual, Is.EqualTo(true)); }
public void When_substracting_Then_works() { var mi = new Miles(1); var km = new Kilometers(1); var actual = mi.Substract(km); Assert.That(actual.Value, Is.EqualTo(0.378628808).Within(0.000001)); }
public void When_adding_Then_works() { var km = new Kilometers(1); var mi = new Miles(1); var actual = km.Add(mi); Assert.That(actual.Value, Is.EqualTo(2.609344M).Within(0.000001)); }
static void Main(string[] args) { Miles m = new Miles(100); Kilometers k = m; Console.WriteLine("kilometers: {0}", k.Distance); int intMiles = (int)m; Console.WriteLine("Int miles: {0}", intMiles); Console.ReadKey(); }
static void Main(string[] args) { Miles m = new Miles(100); Kilometers k = m; // implicity convert miles to km Console.WriteLine("Kilometers: {0}", k.Distance); int intMiles = (int)m; // explicitly convert miles to int Console.WriteLine("Int miles: {0}", intMiles); }
public KilometrePipeline(BlockingCollection <string> queue) { _queue = queue; _kilo = new Kilometers(); _jsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true }; Receive <InputData>(i => { var result = JsonSerializer.Serialize(_kilo.CalculateSpeed(i), options: _jsonSerializerOptions); _queue.Add(result); }); }
// The .NET runtime provides a set of conversion methods that are used to perform casting.You can also write your own type conversion operators for your data // classes so that programs can perform implicit and explicit conversions between types. public void TypeConversion() { Miles m = new Miles(100); Kilometers k = m; // implicitly converts miles to km int intMiles = (int)m; // explicitly converts miles to int // The System.Convert class provides a set of static methods that can be used to perform type conversion between.NET types. As an example, the code next // converts a string into an integer: int age = Convert.ToInt32("24"); // The convert method will throw an exception if the string provided cannot be converted into an integer. }
public static void RunTypeConversion() { Miles m = new Miles(156); Kilometers k = m; // implicitly convert miles to km Console.WriteLine("Kilometers: {0}", k.Distance); int intMiles = (int)m; // explicitly convert miles to int Console.WriteLine("Int miles: {0}", intMiles); Console.ReadLine(); }
/// <summary> /// Gets the current filter values for the csv exported version. /// </summary> /// <returns></returns> protected override Dictionary <string, string> GetFilterValues() { return(new Dictionary <string, string> { { CultureManager.GetEntity("PARENTI01"), cbEmpresa.Selected > 0 ? DAOFactory.EmpresaDAO.FindById(cbEmpresa.Selected).RazonSocial : "Todos" }, { CultureManager.GetEntity("PARENTI02"), ddlBase.Selected > 0 ? DAOFactory.LineaDAO.FindById(ddlBase.Selected).DescripcionCorta : "Todos" }, { CultureManager.GetLabel("KM_SUPERADOS"), npKm.Value.ToString() }, { String.Empty, String.Empty }, { CultureManager.GetLabel("CANTIDAD_KILOMETROS_TOTALES"), Kilometers.ToString() }, { CultureManager.GetLabel("CANTIDAD_VEHICULOS"), Vehicles.ToString() }, { CultureManager.GetLabel("DESDE"), String.Concat(dpDesde.SelectedDate.GetValueOrDefault().ToShortDateString(), String.Empty, dpDesde.SelectedDate.GetValueOrDefault().ToShortTimeString()) }, { CultureManager.GetLabel("HASTA"), String.Concat(dpHasta.SelectedDate.GetValueOrDefault().ToShortDateString(), String.Empty, dpHasta.SelectedDate.GetValueOrDefault().ToShortTimeString()) } }); }
static void ImplicitExplicitDemo() { Miles m = new Miles(100.5); // implicitly convert miles to km Kilometers k = m; Console.WriteLine("Kilometers: {0}", k.Distance); // explicitly convert miles to int int milesInInt = (int)m; Console.WriteLine("Miles in int: {0}", milesInInt); }
public void TestName() { Meters meters = new Meters(1000); Miles miles = LinearUnitConverter.ToMiles(meters); Assertion.AssertEquals(0.62137, miles.Value, 0.001); Kilometers km1 = LinearUnitConverter.ToKilometers(miles); Assertion.AssertEquals(1, km1.Value); Kilometers km = LinearUnitConverter.ToKilometers(meters); Assertion.AssertEquals(1, km.Value); }
private static void TypeConversionExample() { Miles m = new Miles(100.5); /* A program can assign a variable of type Miles value into a variable of type Kilometer. * During the assignment the implicit conversion operator is called automatically. */ Kilometers k = m; //implicitly convert miles Console.WriteLine("kilometers: {0}", k.Distance); // To use an explicit conversion the programmer must use a cast as below int intMiles = (int)m; //explicitly convert miles to int Console.WriteLine("Int miles: {0}", intMiles); }
private static void CastingTest() { Miles m = new Miles { Distance = 1 }; Kilometers k = m; System.Console.WriteLine(k.Distance); Miles m2 = k; System.Console.WriteLine(m2.Distance); m2.Distance = 1.4; System.Console.WriteLine((int)m2); System.Console.WriteLine(k.Distance); }
public async Task <SumKilometersResult> GetSum() { Kilometers kilometers = await this.sumAll.Execute(); return(new SumKilometersResult(kilometers)); }
public async Task <SumKilometersResult> GetSum(Guid id) { Kilometers sumKilometers = await this.sumUserRecords.Execute(id); return(new SumKilometersResult(sumKilometers)); }
public void Kilometers_2_inches() { FloatCompare(39370.079f, Kilometers.Inches(1)); }
public void Kilometers_2_feet() { FloatCompare(3280.84f, Kilometers.Feet(1), 6); }
public void Kilometers_2_miles() { FloatCompare(0.62137119f, Kilometers.Miles(1)); }
public void Kilometers_2_centimeters() { FloatCompare(100000f, Kilometers.Centimeters(1)); }
public void Kilometers_2_millimeters() { FloatCompare(1000000f, Kilometers.Millimeters(1)); }
public SumKilometersResult(Kilometers kilometers) { this.TotalSumKilometers = kilometers.Value; }