Esempio n. 1
0
        public void Ctor_EmptyParameters_ObjectCreatedIsZero()
        {
            var actual = new Fixed8();

            Asserting
            .That(actual)
            .IsZero();
        }
Esempio n. 2
0
        public void SmallerThan_OperatorOneIsSmallerOperatorTwo_ReturnTrue()
        {
            var operatorOne = new Fixed8(5);
            var operatorTwo = new Fixed8(10);

            Asserting
            .That(operatorOne)
            .IsSmallerThan(operatorTwo);
        }
Esempio n. 3
0
        public void Abs_ProvidePositiveFixed8_ReturnTheSameValue()
        {
            var positiveFixed8 = new Fixed8(1);

            var resultAbsoluteFixed8 = positiveFixed8.Abs();

            Asserting
            .That(resultAbsoluteFixed8)
            .IsEqual(positiveFixed8);
        }
Esempio n. 4
0
        public void Ceilling_Provide100000000Fixed8Object_NoCellingNeeded()
        {
            var actual = new Fixed8(100000000);

            var cellingValue = actual.Ceiling();

            Asserting
            .That(cellingValue)
            .IsEqual(actual);
        }
Esempio n. 5
0
        public void OperatorUnaryNagation_ReturnNegativeFixed8()
        {
            var operatorOne = new Fixed8(1);

            var actual = -operatorOne;

            Asserting
            .That(actual)
            .AsLongValue(-1);
        }
Esempio n. 6
0
        public void Equal_Fixed8AndNull_NotEqual()
        {
            const long expectedLongValue = long.MaxValue;

            var firstOperator = new Fixed8(expectedLongValue);

            Asserting
            .That(firstOperator)
            .IsNotEqual(null);
        }
Esempio n. 7
0
        public void Ctor_WithLongMaxValue_ObjectCreateWithLongMaxValue()
        {
            const long expectedLongValue = long.MaxValue;

            var actual = new Fixed8(expectedLongValue);

            Asserting
            .That(actual)
            .AsLongValue(expectedLongValue);
        }
Esempio n. 8
0
        public void Min_ReturnFixed8ObjectWithLongMinValue()
        {
            const long expectedLongValue = long.MinValue;

            var minFixed8 = Fixed8.MinValue;

            Asserting
            .That(minFixed8)
            .AsLongValue(expectedLongValue);
        }
Esempio n. 9
0
        public void Equal_TwoFixed8FieldWithDifferentValues_NotEqual()
        {
            const long expectedLongValue = long.MaxValue;

            var firstOperator  = new Fixed8(expectedLongValue);
            var secondOperator = new Fixed8();

            Asserting
            .That(firstOperator)
            .IsNotEqual(secondOperator);
        }
Esempio n. 10
0
        public void OperatorAddition_ReturnSumOfValues()
        {
            var operatorOne = new Fixed8(10);
            var operatorTwo = new Fixed8(5);

            var actual = operatorOne + operatorTwo;

            Asserting
            .That(actual)
            .AsLongValue(15);
        }
Esempio n. 11
0
        public void OperatorSubtraction_ReturnDifferenceBetweenValues()
        {
            var operatorOne = new Fixed8(10);
            var operatorTwo = new Fixed8(5);

            var actual = operatorOne - operatorTwo;

            Asserting
            .That(actual)
            .AsLongValue(5);
        }
Esempio n. 12
0
        public void Equal_TwoFixed8FieldsWithSameValue_IsEqual()
        {
            const long expectedLongValue = long.MaxValue;

            var firstOperator  = new Fixed8(expectedLongValue);
            var secondOperator = new Fixed8(expectedLongValue);

            Asserting
            .That(firstOperator)
            .IsEqual(secondOperator);
        }
Esempio n. 13
0
        public void Ceilling_Provide100500000Fixed8Object_RemaiderLessThanZeroLogic()
        {
            var actual = new Fixed8(-100500000);
            var expectedCeillingFixed8 = new Fixed8(-100000000);

            var cellingValue = actual.Ceiling();

            Asserting
            .That(cellingValue)
            .IsEqual(expectedCeillingFixed8);
        }
Esempio n. 14
0
        public void Abs_ProvideNegativeFixed8_ReturnPositiveVersionOfTheFixed8()
        {
            var negativeFixed8            = new Fixed8(-1);
            var expectedPositiveLongValue = negativeFixed8.Value * -1;

            var resultAbsoluteFixed8 = negativeFixed8.Abs();

            Asserting
            .That(resultAbsoluteFixed8)
            .AsLongValue(expectedPositiveLongValue);
        }
Esempio n. 15
0
        public void OperatorMultiply_Fixed8ValueAndLongValue_ReturnMultiplicationOfValues()
        {
            var        operatorOne = new Fixed8(500000000);
            const long operatorTwo = 5;

            var actual = operatorOne * operatorTwo;

            Asserting
            .That(actual)
            .AsLongValue(2500000000);
        }
Esempio n. 16
0
        public void TryParse_MinLongValueAsString_ParseReturnZero()
        {
            var minLongString = long.MinValue.ToString();

            var tryParseResult = Fixed8.TryParse(minLongString, out var fixed8Result);

            tryParseResult.Should().BeFalse();
            Asserting
            .That(fixed8Result)
            .IsZero();                      // TODO #411 [AboimPinto]: Don't know if ZERO is the correct value when the TryParse fail.
        }
Esempio n. 17
0
        public void TryParse_InvalidLongValueAsString_ParseReturnFormatException()
        {
            const string invalidString = "xxx";

            var tryParseResult = Fixed8.TryParse(invalidString, out var fixed8Result);

            tryParseResult.Should().BeFalse();
            Asserting
            .That(fixed8Result)
            .IsZero();                      // TODO #411 [AboimPinto]: Don't know if ZERO is the correct value when the TryParse fail.
        }
Esempio n. 18
0
        public void Parse_ValidLongValueAsString_ParseIsOk()
        {
            const long longValue = 1;
            const int  expectedFixed8LongValue = 100000000;

            var actual = Fixed8.Parse(longValue.ToString());

            Asserting
            .That(actual)
            .AsLongValue(expectedFixed8LongValue);
        }
Esempio n. 19
0
        public void TryParse_MaxLongValueAsString_ParseReturnZero()
        {
            var maxLongString = long.MaxValue.ToString();

            var tryParseResult = Fixed8.TryParse(maxLongString, out var fixed8Result);

            Assert.IsFalse(tryParseResult);
            Asserting
            .That(fixed8Result)
            .IsZero();                      // TODO [AboimPinto]: Don't know if ZERO is the correct value when the TryParse fail.
        }
Esempio n. 20
0
        public void OperatorDivision_TwoFixed8Values_ReturnDivisionOfValues()
        {
            var        operatorOne = new Fixed8(500000000);
            const long operatorTwo = 5;

            var actual = operatorOne / operatorTwo;

            Asserting
            .That(actual)
            .AsLongValue(100000000);
        }
Esempio n. 21
0
        public void TryParse_ValidLongValueAsString_ParseIsOk()
        {
            const long longValue = 1;
            const int  expectedFixed8LongValue = 100000000;

            var tryParseResult = Fixed8.TryParse(longValue.ToString(), out var fixed8Result);

            tryParseResult.Should().BeTrue();
            Asserting
            .That(fixed8Result)
            .AsLongValue(expectedFixed8LongValue);
        }
Esempio n. 22
0
        public void Min_ProvideSeveralFixed8Objects_ReturnObjectWithMinLongValue()
        {
            var zeroFixed8 = new Fixed8();
            var maxFixed8  = Fixed8.MaxValue;
            var minFixed8  = Fixed8.MinValue;

            var min = new[] { zeroFixed8, maxFixed8, minFixed8 }.Min();

            Asserting
            .That(minFixed8)
            .IsEqual(min);
        }
Esempio n. 23
0
        public void SerializeDeserialize_SerializeAndDeserializeFixed8AsTheSameValue()
        {
            var memoryByteArray = new byte[255];
            var actual          = new Fixed8(1000);
            var afterReadFixed8 = new Fixed8();

            using (var writer = new BinaryWriter(new MemoryStream(memoryByteArray)))
            {
                actual.Serialize(writer);
            }

            using (var reader = new BinaryReader(new MemoryStream(memoryByteArray)))
            {
                afterReadFixed8.Deserialize(reader);
            }

            Asserting
            .That(actual)
            .IsEqual(afterReadFixed8);
        }