Examples of RandomFunction


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

      assertTrue("Generated value should have a precision of 3", ((BigDecimal) value).precision() == 3);
  }

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

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

      assertTrue("Generated value is not a BigInteger", value instanceof BigInteger);
  }

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

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

  }
 
  @Test
  public void randomDatasetTest() {
    String[] names = {"Anderson", "Arthur", "Douglas"};
    Object value = new RandomFunction(names).generateValue();
    assertNotNull("Generated name can not be null", value);
    assertTrue("Generated name does not exist in the dataset names", Arrays.asList(names).contains(value));
  }
View Full Code Here

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

  }

  @Test
  public void randomByteRangeTest() {
      Byte start = 1, end = 100;
      Byte value = new RandomFunction(Byte.class, new Range(start, end)).generateValue();
      assertNotNull("Generated byte must not be null", value);
      assertTrue("Generated byte does not exist in the range", (start <= value && value <= end));
  }
View Full Code Here

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

  }

  @Test
  public void randomShortRangeTest() {
      Short start = 1, end = 100;
      Short value = new RandomFunction(Short.class, new Range(start, end)).generateValue();
      assertNotNull("Generated short must not be null", value);
      assertTrue("Generated short does not exist in the range", (start <= value && value <= end));
  }
View Full Code Here

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

  }

  @Test
  public void randomLongRangeTest() {
    Long start = 85L, end = 86L;
        Object value = new RandomFunction(Long.class, new Range(start, end)).generateValue();
    assertNotNull("Generated long can not be null", value);
    assertTrue("Generated long does not exist in the range", (start <= (Long) value && (Long) value <= end));
  }
View Full Code Here

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

  }

  @Test
  public void randomLongDistributionTest() {
      Long start = 85L, end = 86L;
        RandomFunction randomFunction = new RandomFunction(Long.class, new Range(start, end));
        Set<Long> values = new HashSet<Long>();
        for (int i=0; i<10; i++) {
            values.add((Long) 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

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

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

  }

  @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

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

  }

  @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
TOP
Copyright © 2018 www.massapi.com. 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.