public void ShouldCorrectlyConvertMinimum(object bounaryValue) { // Arrange var sut = new RangedRequest(typeof(int), typeof(int), bounaryValue, int.MaxValue); // Act var convertedValue = sut.GetConvertedMinimum(typeof(int)); // Assert Assert.Equal(42, convertedValue); }
public void ShouldCorrectlyConvertMinimum(object bounaryValue) { // Fixture setup var sut = new RangedRequest(typeof(int), typeof(int), bounaryValue, int.MaxValue); // Exercise system var convertedValue = sut.GetConvertedMinimum(typeof(int)); // Verify outcome Assert.Equal(42, convertedValue); // Teardown }
public void FailsWithMeaningfulExceptionWhenMinimumCannotBeConvertedWithoutOverflow() { // Arrange double valueWithOverflow = (double)long.MaxValue; var sut = new RangedRequest(typeof(long), typeof(double), valueWithOverflow, double.MaxValue); // Act & assert var actualEx = Assert.Throws <OverflowException>(() => sut.GetConvertedMinimum(typeof(long))); Assert.Contains("To solve the issue", actualEx.Message); }
public void FailsWithMeaningfulExceptionWhenMinimumCannotBeConvertedWithoutOverflow() { // Fixture setup double valueWithOverflow = (double)long.MaxValue; var sut = new RangedRequest(typeof(long), typeof(double), valueWithOverflow, double.MaxValue); // Exercise system and verify outcome var actualEx = Assert.Throws <OverflowException>(() => sut.GetConvertedMinimum(typeof(long))); Assert.Contains("To solve the issue", actualEx.Message); // Teardown }
public void ShouldConvertLiteralEnumValues() { // Arrange var sut = new RangedRequest( typeof(EnumType), typeof(string), nameof(EnumType.First), nameof(EnumType.Third)); // Act var convertedMin = sut.GetConvertedMinimum(typeof(EnumType)); var convertedMax = sut.GetConvertedMaximum(typeof(EnumType)); // Assert Assert.Equal(EnumType.First, convertedMin); Assert.Equal(EnumType.Third, convertedMax); }
public void ShouldCorrectlyConvertDateTime() { // Fixture setup var minimum = DateTime.MinValue; var maximum = DateTime.MaxValue; var sut = new RangedRequest(typeof(DateTime), typeof(DateTime), minimum.ToString("o"), maximum.ToString("o")); // Exercise system var convertedMinimumValue = sut.GetConvertedMinimum(typeof(DateTime)); var convertedMaximumValue = sut.GetConvertedMaximum(typeof(DateTime)); // Verify outcome Assert.Equal(minimum, convertedMinimumValue); Assert.Equal(maximum, convertedMaximumValue); // Teardown }
public void ShouldCorrectlyConvertTimeSpan() { // Fixture setup var minimum = TimeSpan.Zero; var maximum = TimeSpan.MaxValue; var sut = new RangedRequest(typeof(TimeSpan), typeof(TimeSpan), minimum.ToString(), maximum.ToString()); // Exercise system var convertedMinimumValue = sut.GetConvertedMinimum(typeof(TimeSpan)); var convertedMaximumValue = sut.GetConvertedMaximum(typeof(TimeSpan)); // Verify outcome Assert.Equal(minimum, convertedMinimumValue); Assert.Equal(maximum, convertedMaximumValue); // Teardown }