Ejemplo n.º 1
0
        public void Generate_WhenPassedWithDateTime_ReturnsUtcString()
        {
            var testInput = new DateTime(2020, 02, 07, 10, 00, 00);
            var sut       = new DateTimeGenerator();
            var result    = sut.Generate(testInput);

            result.Should().Be("2020-02-07T10:00:00+00:00");
        }
Ejemplo n.º 2
0
        public void DateTimeGeneratorWithDefaultTest()
        {
            IGenerator <DateTime> dtg = new DateTimeGenerator();
            var checkme = (DateTime)dtg.Generate();
            var current = DateTime.Now;

            Assert.IsNotNull(checkme);
            Assert.That(checkme, Is.InRange(current.AddYears(-10), current.AddYears(10)));
        }
Ejemplo n.º 3
0
        public void DateTimeGeneratorWithOverrideValues()
        {
            var mymin = Convert.ToDateTime("1/1/1972");
            var mymax = Convert.ToDateTime("1/1/1980");

            IGenerator <DateTime> dtg = new DateTimeGenerator(mymin, mymax);
            var checkme = (DateTime)dtg.Generate();

            Assert.That(checkme, Is.InRange(mymin, mymax));
        }
        public void GenerateWorks(int precision, int maxLength, DateTime value, string expected)
        {
            // Arrange
            var random = new Mock <IRandomNumber>();

            random.Setup(x => x.Next(It.IsAny <DateTime>(), It.IsAny <DateTime>())).Returns(value);

            var sut = new DateTimeGenerator(random.Object, precision, maxLength);

            // Act
            var result = sut.Generate();

            // assert
            Assert.Equal(expected, result);
        }
        public void GenerateWorksWithOffset(DateTime value, TimeSpan offset, bool offsetPositive, string expected)
        {
            // Arrange
            var random = new Mock <IRandomNumber>();

            random.Setup(x => x.Next(It.IsAny <DateTime>(), It.IsAny <DateTime>())).Returns(value);
            random.Setup(x => x.Next(new DateTime(1, 1, 1), new DateTime(1, 1, 1, 14, 0, 0))).Returns(new DateTime(1, 1, 1) + offset);
            random.Setup(x => x.Next(0, 1)).Returns(offsetPositive ? 1 : 0);

            var sut = new DateTimeGenerator(random.Object, 34, 10); // DateTimeOffset

            // Act
            var result = sut.Generate();

            // assert
            Assert.Equal(expected, result);
        }
Ejemplo n.º 6
0
        public void DateTimeGeneratorWithOverrideValues()
        {
            var mymin = Convert.ToDateTime("1/1/1972");
            var mymax = Convert.ToDateTime("1/1/1980");

            IGenerator<DateTime> dtg = new DateTimeGenerator(mymin, mymax);
            var checkme = (DateTime) dtg.Generate();
            Assert.That(checkme, Is.InRange(mymin, mymax));
        }
Ejemplo n.º 7
0
 public void DateTimeGeneratorWithDefaultTest()
 {
     IGenerator<DateTime> dtg = new DateTimeGenerator();
     var checkme = (DateTime) dtg.Generate();
     var current = DateTime.Now;
     Assert.IsNotNull(checkme);
     Assert.That(checkme, Is.InRange(current.AddYears(-10), current.AddYears(10)));
 }