public void Ctor_EmptyParameters_ObjectCreatedIsZero() { var actual = new Fixed8(); Asserting .That(actual) .IsZero(); }
public void SmallerThan_OperatorOneIsSmallerOperatorTwo_ReturnTrue() { var operatorOne = new Fixed8(5); var operatorTwo = new Fixed8(10); Asserting .That(operatorOne) .IsSmallerThan(operatorTwo); }
public void Abs_ProvidePositiveFixed8_ReturnTheSameValue() { var positiveFixed8 = new Fixed8(1); var resultAbsoluteFixed8 = positiveFixed8.Abs(); Asserting .That(resultAbsoluteFixed8) .IsEqual(positiveFixed8); }
public void Ceilling_Provide100000000Fixed8Object_NoCellingNeeded() { var actual = new Fixed8(100000000); var cellingValue = actual.Ceiling(); Asserting .That(cellingValue) .IsEqual(actual); }
public void OperatorUnaryNagation_ReturnNegativeFixed8() { var operatorOne = new Fixed8(1); var actual = -operatorOne; Asserting .That(actual) .AsLongValue(-1); }
public void Equal_Fixed8AndNull_NotEqual() { const long expectedLongValue = long.MaxValue; var firstOperator = new Fixed8(expectedLongValue); Asserting .That(firstOperator) .IsNotEqual(null); }
public void Ctor_WithLongMaxValue_ObjectCreateWithLongMaxValue() { const long expectedLongValue = long.MaxValue; var actual = new Fixed8(expectedLongValue); Asserting .That(actual) .AsLongValue(expectedLongValue); }
public void Min_ReturnFixed8ObjectWithLongMinValue() { const long expectedLongValue = long.MinValue; var minFixed8 = Fixed8.MinValue; Asserting .That(minFixed8) .AsLongValue(expectedLongValue); }
public void Equal_TwoFixed8FieldWithDifferentValues_NotEqual() { const long expectedLongValue = long.MaxValue; var firstOperator = new Fixed8(expectedLongValue); var secondOperator = new Fixed8(); Asserting .That(firstOperator) .IsNotEqual(secondOperator); }
public void OperatorAddition_ReturnSumOfValues() { var operatorOne = new Fixed8(10); var operatorTwo = new Fixed8(5); var actual = operatorOne + operatorTwo; Asserting .That(actual) .AsLongValue(15); }
public void OperatorSubtraction_ReturnDifferenceBetweenValues() { var operatorOne = new Fixed8(10); var operatorTwo = new Fixed8(5); var actual = operatorOne - operatorTwo; Asserting .That(actual) .AsLongValue(5); }
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); }
public void Ceilling_Provide100500000Fixed8Object_RemaiderLessThanZeroLogic() { var actual = new Fixed8(-100500000); var expectedCeillingFixed8 = new Fixed8(-100000000); var cellingValue = actual.Ceiling(); Asserting .That(cellingValue) .IsEqual(expectedCeillingFixed8); }
public void Abs_ProvideNegativeFixed8_ReturnPositiveVersionOfTheFixed8() { var negativeFixed8 = new Fixed8(-1); var expectedPositiveLongValue = negativeFixed8.Value * -1; var resultAbsoluteFixed8 = negativeFixed8.Abs(); Asserting .That(resultAbsoluteFixed8) .AsLongValue(expectedPositiveLongValue); }
public void OperatorMultiply_Fixed8ValueAndLongValue_ReturnMultiplicationOfValues() { var operatorOne = new Fixed8(500000000); const long operatorTwo = 5; var actual = operatorOne * operatorTwo; Asserting .That(actual) .AsLongValue(2500000000); }
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. }
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. }
public void Parse_ValidLongValueAsString_ParseIsOk() { const long longValue = 1; const int expectedFixed8LongValue = 100000000; var actual = Fixed8.Parse(longValue.ToString()); Asserting .That(actual) .AsLongValue(expectedFixed8LongValue); }
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. }
public void OperatorDivision_TwoFixed8Values_ReturnDivisionOfValues() { var operatorOne = new Fixed8(500000000); const long operatorTwo = 5; var actual = operatorOne / operatorTwo; Asserting .That(actual) .AsLongValue(100000000); }
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); }
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); }
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); }