Package br.com.six2six.fixturefactory.function.impl

Examples of br.com.six2six.fixturefactory.function.impl.RandomFunction


        assertTrue("Generated at least one equal to end", values.contains(end));
  }

  public void randomDoubleRangeTest() {
      Double start = 85.1, end = 85.2;
      RandomFunction randomFunction = new RandomFunction(Double.class, new Range(start, end));
        for (int i=0; i<10; i++) {
            Object value = randomFunction.generateValue();
            assertNotNull("Generated double can not be null", value);
            assertTrue("Generated double does not exist in the range", (start <= (Double) value && (Double) value <= end));
        }
  }
View Full Code Here


  }

  @Test
  public void randomBigDecimalRangeChoosesStartScaleTest() {
      BigDecimal start = new BigDecimal("2.313"), end = new BigDecimal("3.73");
      BigDecimal value = new RandomFunction(BigDecimal.class, new Range(start, end)).generateValue();
      assertNotNull("Generated BigDecimal can not be null", value);
      assertTrue("Generated BigDecimal does not exist in the range", (start.compareTo(value) <= 0 && value.compareTo(end) <= 0));
      assertTrue("Generated BigDecimal should most precise scale", value.scale() == start.scale());
  }
View Full Code Here

  }

  @Test
  public void randomBigDecimalRangeChoosesEndScaleTest() {
      BigDecimal start = new BigDecimal("2.31"), end = new BigDecimal("3.731");
      BigDecimal value = new RandomFunction(BigDecimal.class, new Range(start, end)).generateValue();
      assertNotNull("Generated BigDecimal can not be null", value);
      assertTrue("Generated BigDecimal does not exist in the range", (start.compareTo(value) <= 0 && value.compareTo(end) <= 0));
      assertTrue("Generated BigDecimal should most precise scale", value.scale() == end.scale());
  }
View Full Code Here

  }

  @Test
  public void randomBigIntegerRangeTest() {
      BigInteger start = new BigInteger("2147483648"), end = new BigInteger("2147483650");
      BigInteger value = new RandomFunction(BigInteger.class, new Range(start, end)).generateValue();
      assertNotNull("Generated BigInteger can not be null", value);
      assertTrue("Generated BigInteger does not exist in the range", (start.compareTo(value) <= 0 && value.compareTo(end) <= 0));
  }
View Full Code Here

  }

  @Test
  public void randomBigIntegerDistributionTest() {
      BigInteger start = new BigInteger("2147483648"), end = new BigInteger("2147483649");
      RandomFunction randomFunction = new RandomFunction(BigInteger.class, new Range(start, end));
      Set<BigInteger> values = new HashSet<BigInteger>();
      for (int i=0; i<10; i++) {
          values.add((BigInteger) randomFunction.generateValue());
      }
      assertTrue("Generated at least one equal to start", values.contains(start));
      assertTrue("Generated at least one equal to end", values.contains(end));
  }
View Full Code Here

  }

  @Test(expected = IllegalArgumentException.class)
  public void randomLongRangeIncorrectTest() {
    Long start = 80L, end = 80L;
    new RandomFunction(Long.class, new Range(start, end)).generateValue();
  }
View Full Code Here

  }

  @Test(expected = IllegalArgumentException.class)
  public void randomDoubleRangeIncorrectTest() {
    Double start = 80.0, end = 80.0;
    new RandomFunction(Long.class, new Range(start, end)).generateValue();
  }
View Full Code Here

  }
 
  @Test
  public void randomFunction() {
    Function[] functions = {new NameFunction(), new NameFunction(Gender.MALE), new NameFunction(Gender.FEMALE)};
    Object value = new RandomFunction(functions).generateValue();
    assertNotNull("Generated value can not be null", value);
  }
View Full Code Here

    assertNotNull("Generated value can not be null", value);
  }
 
  @Test
  public void randomEnum() {
    Object value = new RandomFunction(Gender.class).generateValue();
    assertNotNull("Generated enum can not be null", value);
    assertTrue("Generated value is not a Enum", value instanceof Enum);
  }
View Full Code Here

TOP

Related Classes of br.com.six2six.fixturefactory.function.impl.RandomFunction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.