Example #1
0
        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));
        }
Example #2
0
        public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit()
        {
            var quantity = new SpecificArea();

            Assert.Equal(0, quantity.Value);
            Assert.Equal(SpecificAreaUnit.SquareFootPerTon, quantity.Unit);
        }
Example #3
0
        public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit()
        {
            var quantity00 = SpecificArea.From(1, SpecificAreaUnit.SquareFootPerTon);

            AssertEx.EqualTolerance(1, quantity00.SquareFootPerTons, SquareFootPerTonsTolerance);
            Assert.Equal(SpecificAreaUnit.SquareFootPerTon, quantity00.Unit);
        }
Example #4
0
        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));
        }
Example #5
0
        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);
        }
Example #6
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);
        }
Example #7
0
        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));
        }
Example #8
0
        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);
        }
Example #9
0
        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);
        }
Example #10
0
        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);
        }
Example #11
0
        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
        }
Example #12
0
        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
        }
Example #13
0
        public void GetHashCode_Equals()
        {
            var quantity = SpecificArea.FromSquareFootPerTons(1.0);

            Assert.Equal(new { SpecificArea.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
Example #14
0
        public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException()
        {
            var v = SpecificArea.FromSquareFootPerTons(1);

            Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(SpecificArea.FromSquareFootPerTons(1), -1, ComparisonType.Relative));
        }
Example #15
0
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = SpecificArea.FromSquareFootPerTons(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
Example #16
0
        public void Convert_ChangeType_QuantityType_EqualsQuantityType()
        {
            var quantity = SpecificArea.FromSquareFootPerTons(1.0);

            Assert.Equal(QuantityType.SpecificArea, Convert.ChangeType(quantity, typeof(QuantityType)));
        }
Example #17
0
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = SpecificArea.FromSquareFootPerTons(1.0);

            Assert.Equal(SpecificArea.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
Example #18
0
        public void ToString_NullArgs_ThrowsArgumentNullException()
        {
            var quantity = SpecificArea.FromSquareFootPerTons(1.0);

            Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null));
        }
Example #19
0
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = SpecificArea.FromSquareFootPerTons(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(SpecificAreaUnit)));
        }
Example #20
0
        public void Convert_ToString_EqualsToString()
        {
            var quantity = SpecificArea.FromSquareFootPerTons(1.0);

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
Example #21
0
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = SpecificArea.FromSquareFootPerTons(1.0);

            Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity));
        }
Example #22
0
        public void Convert_ToInt16_EqualsValueAsSameType()
        {
            var quantity = SpecificArea.FromSquareFootPerTons(1.0);

            Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity));
        }
Example #23
0
        public void Convert_ToSingle_EqualsValueAsSameType()
        {
            var quantity = SpecificArea.FromSquareFootPerTons(1.0);

            Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity));
        }
Example #24
0
        public void Convert_ToDecimal_EqualsValueAsSameType()
        {
            var quantity = SpecificArea.FromSquareFootPerTons(1.0);

            Assert.Equal((decimal)quantity.Value, Convert.ToDecimal(quantity));
        }
Example #25
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            SpecificArea squarefootperton = SpecificArea.FromSquareFootPerTons(1);

            Assert.False(squarefootperton.Equals(new object()));
        }
Example #26
0
        public void ToString_NullProvider_EqualsCurrentUICulture()
        {
            var quantity = SpecificArea.FromSquareFootPerTons(1.0);

            Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g"));
        }
Example #27
0
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value)
        {
            var quantity = SpecificArea.FromSquareFootPerTons(value);

            Assert.Equal(SpecificArea.FromSquareFootPerTons(-value), -quantity);
        }
Example #28
0
        public void Convert_ChangeType_SelfType_EqualsSelf()
        {
            var quantity = SpecificArea.FromSquareFootPerTons(1.0);

            Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(SpecificArea)));
        }
Example #29
0
        public void Convert_ToDateTime_ThrowsInvalidCastException()
        {
            var quantity = SpecificArea.FromSquareFootPerTons(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity));
        }
Example #30
0
        public void EqualsReturnsFalseOnNull()
        {
            SpecificArea squarefootperton = SpecificArea.FromSquareFootPerTons(1);

            Assert.False(squarefootperton.Equals(null));
        }