public void Equals_RelativeTolerance_IsImplemented() { var v = SpecificArea.FromSquareFootPerTons(1); Assert.True(v.Equals(SpecificArea.FromSquareFootPerTons(1), SquareFootPerTonsTolerance, ComparisonType.Relative)); Assert.False(v.Equals(SpecificArea.Zero, SquareFootPerTonsTolerance, ComparisonType.Relative)); }
public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { var quantity = new SpecificArea(); Assert.Equal(0, quantity.Value); Assert.Equal(SpecificAreaUnit.SquareFootPerTon, quantity.Unit); }
public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { var quantity00 = SpecificArea.From(1, SpecificAreaUnit.SquareFootPerTon); AssertEx.EqualTolerance(1, quantity00.SquareFootPerTons, SquareFootPerTonsTolerance); Assert.Equal(SpecificAreaUnit.SquareFootPerTon, quantity00.Unit); }
public void Equals_SameType_IsImplemented() { var a = SpecificArea.FromSquareFootPerTons(1); var b = SpecificArea.FromSquareFootPerTons(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); }
public void CompareToIsImplemented() { SpecificArea squarefootperton = SpecificArea.FromSquareFootPerTons(1); Assert.Equal(0, squarefootperton.CompareTo(squarefootperton)); Assert.True(squarefootperton.CompareTo(SpecificArea.Zero) > 0); Assert.True(SpecificArea.Zero.CompareTo(squarefootperton) < 0); }
async public Task <System.Net.HttpStatusCode> RegisterSpecificArea(SpecificArea packet) { var stringContent = new StringContent(JsonConvert.SerializeObject(packet), Encoding.UTF8, "application/json"); var response = await _client.PostAsync("/specific-area", stringContent); System.Diagnostics.Debug.WriteLine(response); // this line write on console return(response.StatusCode); }
public void Equals_QuantityAsObject_IsImplemented() { object a = SpecificArea.FromSquareFootPerTons(1); object b = SpecificArea.FromSquareFootPerTons(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); Assert.False(a.Equals((object)null)); }
public void ToUnit() { var squarefootperton = SpecificArea.FromSquareFootPerTons(1); var squarefootpertonQuantity = squarefootperton.ToUnit(SpecificAreaUnit.SquareFootPerTon); AssertEx.EqualTolerance(SquareFootPerTonsInOneSquareFootPerTon, (double)squarefootpertonQuantity.Value, SquareFootPerTonsTolerance); Assert.Equal(SpecificAreaUnit.SquareFootPerTon, squarefootpertonQuantity.Unit); }
public void ArithmeticOperators() { SpecificArea v = SpecificArea.FromSquareFootPerTons(1); AssertEx.EqualTolerance(-1, -v.SquareFootPerTons, SquareFootPerTonsTolerance); AssertEx.EqualTolerance(2, (SpecificArea.FromSquareFootPerTons(3) - v).SquareFootPerTons, SquareFootPerTonsTolerance); AssertEx.EqualTolerance(2, (v + v).SquareFootPerTons, SquareFootPerTonsTolerance); AssertEx.EqualTolerance(10, (v * 10).SquareFootPerTons, SquareFootPerTonsTolerance); AssertEx.EqualTolerance(10, (10 * v).SquareFootPerTons, SquareFootPerTonsTolerance); AssertEx.EqualTolerance(2, (SpecificArea.FromSquareFootPerTons(10) / 5).SquareFootPerTons, SquareFootPerTonsTolerance); AssertEx.EqualTolerance(2, SpecificArea.FromSquareFootPerTons(10) / SpecificArea.FromSquareFootPerTons(5), SquareFootPerTonsTolerance); }
public void ComparisonOperators() { SpecificArea oneSquareFootPerTon = SpecificArea.FromSquareFootPerTons(1); SpecificArea twoSquareFootPerTons = SpecificArea.FromSquareFootPerTons(2); Assert.True(oneSquareFootPerTon < twoSquareFootPerTons); Assert.True(oneSquareFootPerTon <= twoSquareFootPerTons); Assert.True(twoSquareFootPerTons > oneSquareFootPerTon); Assert.True(twoSquareFootPerTons >= oneSquareFootPerTon); Assert.False(oneSquareFootPerTon > twoSquareFootPerTons); Assert.False(oneSquareFootPerTon >= twoSquareFootPerTons); Assert.False(twoSquareFootPerTons < oneSquareFootPerTon); Assert.False(twoSquareFootPerTons <= oneSquareFootPerTon); }
public void EqualityOperators() { var a = SpecificArea.FromSquareFootPerTons(1); var b = SpecificArea.FromSquareFootPerTons(2); // ReSharper disable EqualExpressionComparison Assert.True(a == a); Assert.False(a != a); Assert.True(a != b); Assert.False(a == b); Assert.False(a == null); Assert.False(null == a); // ReSharper restore EqualExpressionComparison }
public void SpecificArea_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() { var quantity = new SpecificArea(1, SpecificAreaUnit.SquareFootPerTon); QuantityInfo <SpecificAreaUnit> quantityInfo = quantity.QuantityInfo; Assert.Equal(SpecificArea.Zero, quantityInfo.Zero); Assert.Equal("SpecificArea", quantityInfo.Name); Assert.Equal(QuantityType.SpecificArea, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues <SpecificAreaUnit>().Except(new[] { SpecificAreaUnit.Undefined }).ToArray(); var unitNames = units.Select(x => x.ToString()); // Obsolete members #pragma warning disable 618 Assert.Equal(units, quantityInfo.Units); Assert.Equal(unitNames, quantityInfo.UnitNames); #pragma warning restore 618 }
public void GetHashCode_Equals() { var quantity = SpecificArea.FromSquareFootPerTons(1.0); Assert.Equal(new { SpecificArea.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode()); }
public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() { var v = SpecificArea.FromSquareFootPerTons(1); Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(SpecificArea.FromSquareFootPerTons(1), -1, ComparisonType.Relative)); }
public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() { var quantity = SpecificArea.FromSquareFootPerTons(1.0); Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter))); }
public void Convert_ChangeType_QuantityType_EqualsQuantityType() { var quantity = SpecificArea.FromSquareFootPerTons(1.0); Assert.Equal(QuantityType.SpecificArea, Convert.ChangeType(quantity, typeof(QuantityType))); }
public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions() { var quantity = SpecificArea.FromSquareFootPerTons(1.0); Assert.Equal(SpecificArea.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions))); }
public void ToString_NullArgs_ThrowsArgumentNullException() { var quantity = SpecificArea.FromSquareFootPerTons(1.0); Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null)); }
public void Convert_ChangeType_UnitType_EqualsUnit() { var quantity = SpecificArea.FromSquareFootPerTons(1.0); Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(SpecificAreaUnit))); }
public void Convert_ToString_EqualsToString() { var quantity = SpecificArea.FromSquareFootPerTons(1.0); Assert.Equal(quantity.ToString(), Convert.ToString(quantity)); }
public void Convert_ToUInt64_EqualsValueAsSameType() { var quantity = SpecificArea.FromSquareFootPerTons(1.0); Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); }
public void Convert_ToInt16_EqualsValueAsSameType() { var quantity = SpecificArea.FromSquareFootPerTons(1.0); Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); }
public void Convert_ToSingle_EqualsValueAsSameType() { var quantity = SpecificArea.FromSquareFootPerTons(1.0); Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); }
public void Convert_ToDecimal_EqualsValueAsSameType() { var quantity = SpecificArea.FromSquareFootPerTons(1.0); Assert.Equal((decimal)quantity.Value, Convert.ToDecimal(quantity)); }
public void EqualsReturnsFalseOnTypeMismatch() { SpecificArea squarefootperton = SpecificArea.FromSquareFootPerTons(1); Assert.False(squarefootperton.Equals(new object())); }
public void ToString_NullProvider_EqualsCurrentUICulture() { var quantity = SpecificArea.FromSquareFootPerTons(1.0); Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); }
public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value) { var quantity = SpecificArea.FromSquareFootPerTons(value); Assert.Equal(SpecificArea.FromSquareFootPerTons(-value), -quantity); }
public void Convert_ChangeType_SelfType_EqualsSelf() { var quantity = SpecificArea.FromSquareFootPerTons(1.0); Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(SpecificArea))); }
public void Convert_ToDateTime_ThrowsInvalidCastException() { var quantity = SpecificArea.FromSquareFootPerTons(1.0); Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity)); }
public void EqualsReturnsFalseOnNull() { SpecificArea squarefootperton = SpecificArea.FromSquareFootPerTons(1); Assert.False(squarefootperton.Equals(null)); }