public void ReverseTest() { var c = new ReverseInteger(); // example1 var target = 123; var result = c.Reverse(target); var expected = 321; Assert.AreEqual(expected, result); // example2 target = -123; result = c.Reverse(target); expected = -321; Assert.AreEqual(expected, result); //example3 target = 120; result = c.Reverse(target); expected = 21; Assert.AreEqual(expected, result); target = 0; result = c.Reverse(target); expected = 0; Assert.AreEqual(expected, result); }
public void Reverse_WhenCalledWithExample1_ReturnsCorrectResult() { // Arrange var input = 123; var expected = 321; // Act var result = _reverseInteger.Reverse(input); // Assert Assert.AreEqual(expected, result); }
public void GivenNullValue_ShouldThrowArgumentException(int?value) { Action action = () => ReverseInteger.Reverse(value); action.Should().Throw <ArgumentException>() .WithMessage("Value can not be null"); }
public void Reverse(int num, int expected) { var ri = new ReverseInteger(); var result = ri.Reverse(num); result.Should().Be(expected); }
public void ReverseInteger() { ReverseInteger reverseInteger = new ReverseInteger(); int num = 123; Assert.AreEqual(reverseInteger.Reverse(num), 321); }
public void TestSolution(int input, int expectedResult) { var soln = new ReverseInteger(); var result = soln.Reverse(input); Assert.Equal(expectedResult, result); }
public void Reverse_Basic() { var srv = new ReverseInteger(); int r = srv.Reverse(123); Assert.AreEqual(321, r); }
public void Reverse_Overflow_Return_0() { var srv = new ReverseInteger(); int r = srv.Reverse(int.MaxValue); Assert.AreEqual(0, r); }
public void Reverse_Under_0() { var srv = new ReverseInteger(); int r = srv.Reverse(-123); Assert.AreEqual(-321, r); }
public void ReverseTest() { var xList = new[] { 123, -120, 0 }; var expecteds = new[] { 321, -21, 00 }; foreach (var(x, expected) in xList.Zip(expecteds)) { ReverseInteger.Reverse(x).Should().Be(expected); } }
public void ZeroAtTheEndDoesNotCount() { //Arrange var calculation = new ReverseInteger(); //act var reversed = calculation.Reverse(120); //Assert Assert.Equal(21, reversed); }
public void ThreeMinusNumbersReturnRevresedAndStillMinus() { //Arrange var calculation = new ReverseInteger(); //act var reversed = calculation.Reverse(-123); //Assert Assert.Equal(-321, reversed); }
public void NumberReturnedIsNotHigherThanThe32BitIntegerRange() { //Arrange var calculation = new ReverseInteger(); //Act var reversed = calculation.Reverse(1534236469); //Assert Assert.Equal(0, reversed); }
public void ThreeNumbersAreReveresed() { //Arrange var calculation = new ReverseInteger(); //act var reversed = calculation.Reverse(123); //Assert Assert.Equal(321, reversed); }
public void OneNumberReturnsNumber() { //Arrange var calculation = new ReverseInteger(); //act var reversed = calculation.Reverse(1); //Assert Assert.Equal(1, reversed); }
public void NumberReturnedIsNotLowerThanThe32BitIntegerRange() { //Arrange var calculation = new ReverseInteger(); //Act var reversed = calculation.Reverse(-2147483648); //Assert Assert.Equal(0, reversed); }
public void ReverseInteger(int input, int expected) { // Arrange var sut = new ReverseInteger(); // Act var result = sut.Reverse(input); // Assert result.Should().Be(expected); }
public void Input1534236469() { //Arrange var reverseInteger = new ReverseInteger(); var expected = 0; var intput = 1534236469; //Act var act = reverseInteger.Reverse(intput); //Assert Assert.AreEqual(expected, act); }
public void Input123Oupt321() { //Arrange var reverseInteger = new ReverseInteger(); var expected = 321; var intput = 123; //Act var act = reverseInteger.Reverse(intput); //Assert Assert.AreEqual(expected, act); }
private static void ReverseIntegerTest() { Console.WriteLine("\nReverse Integer question:"); int[] testNumbers = new int[] { 123, -123, 120, 1534236469 }; ReverseInteger reverseInteger = new ReverseInteger(); foreach (int number in testNumbers) { Console.WriteLine("{0} -> {1}", number, reverseInteger.Reverse(number)); } }
public void OverflowNegativeLargeNumberTest() { // arrange int inputNumber = -1234567899;// this reversed will be 9,987,654,321 which is beyond the Int32 int expectedReversedNumber = 0; // act ReverseInteger reverseInteger = new ReverseInteger(); int actualReversedNumber = reverseInteger.Reverse(inputNumber); // assert Assert.AreEqual(expectedReversedNumber, actualReversedNumber); }
public void ReversePositiveNumberTest() { // arrange int inputNumber = 123; int expectedReversedNumber = 321; // act ReverseInteger reverseInteger = new ReverseInteger(); int actualReversedNumber = reverseInteger.Reverse(inputNumber); // assert Assert.AreEqual(expectedReversedNumber, actualReversedNumber); }
public void ReverseIntegerTest() { var solution = new ReverseInteger(); Assert.Equal(321, solution.Reverse(123)); Assert.Equal(-321, solution.Reverse(-123)); Assert.Equal(21, solution.Reverse(120)); Assert.Equal(-1, solution.Reverse(-1)); Assert.Equal(0, solution.Reverse(0)); Assert.Equal(0, solution.Reverse(1534236469)); Assert.Equal(0, solution.Reverse(-2147483648)); }
public void Reverse_PassedNegative2147483648_ThrowsException() { Exception exception = null; try { ReverseInteger.Reverse(-2147483648); } catch (Exception ex) { exception = ex; } Assert.IsNotNull(exception); }
public void Examples(int input, int expected) { // Given // When _stopwatch.Start(); var result = _sut.Reverse(input); _stopwatch.Stop(); // Then result.Should().Be(expected); Console.WriteLine($"Ran for: {_stopwatch.Elapsed.Milliseconds} ms"); Console.WriteLine($"Ran for: {_stopwatch.Elapsed.Ticks} ticks"); }
public void ReversesAllIntegerInput() { // Arrange var reverser = new ReverseInteger(); // Act | Assert Assert.AreEqual("0", reverser.Reverse(0)); Assert.AreEqual("9", reverser.Reverse(9)); Assert.AreEqual("01", reverser.Reverse(10)); Assert.AreEqual("51", reverser.Reverse(15)); Assert.AreEqual("84", reverser.Reverse(48)); Assert.AreEqual("415", reverser.Reverse(514)); Assert.AreEqual("4201", reverser.Reverse(1024)); }
public void ReverseTest_Examples() { // Arrange ReverseInteger algo = new ReverseInteger(); int[] input = { 123, -123, 120 }; int[] expected = { 321, -321, 21 }; for (int i = 0; i < input.Length; i++) { // Act int result = algo.Reverse(input[i]); // Assert Assert.AreEqual(result, expected[i]); } }
public void TestReverseInteger() { var r = ReverseInteger.Reverse(123); Assert.AreEqual(r, 321); r = ReverseInteger.Reverse(-123); Assert.AreEqual(r, -321); r = ReverseInteger.Reverse(120); Assert.AreEqual(r, 21); r = ReverseInteger.Reverse(2147483647); Assert.AreEqual(r, 0); r = ReverseInteger.Reverse(-2147483648); Assert.AreEqual(r, 0); }
public void PostiveNumber() { int result = ReverseInteger.Reverse(8734); Assert.Equal(4378, result); }
public void PositiveNumberBorderline() { int result = ReverseInteger.Reverse(2147483647); Assert.Equal(0, result); }