コード例 #1
0
 public void CreateWithNullContextThrowsArgumentNullException()
 {
     // Fixture setup
     var sut = new RandomDateTimeSequenceGenerator();
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(
         () => sut.Create(typeof(DateTime), null));
     // Teardown
 }
コード例 #2
0
 public void SutIsSpecimenBuilder()
 {
     // Fixture setup
     // Exercise system
     var sut = new RandomDateTimeSequenceGenerator();
     // Verify outcome
     Assert.IsAssignableFrom<ISpecimenBuilder>(sut);
     // Teardown
 }
コード例 #3
0
 public void CreateWithNonTypeRequestReturnsNoSpecimen(object request)
 {
     // Fixture setup
     var sut = new RandomDateTimeSequenceGenerator();
     // Exercise system
     var dummyContainer = new DelegatingSpecimenContext();
     var result = sut.Create(request, dummyContainer);
     // Verify outcome
     Assert.Equal(new NoSpecimen(request), result);
     // Teardown
 }
コード例 #4
0
 public void CreateWithDateTimeRequestAndDateRangeReturnsDateWithinThatRange()
 {
     // Fixture setup
     var minDate = DateTime.Now;
     var maxDate = minDate.AddDays(3);
     var sut = new RandomDateTimeSequenceGenerator(minDate, maxDate);
     // Exercise system
     var dummyContainer = new DelegatingSpecimenContext();
     var result = (DateTime)sut.Create(typeof(DateTime), dummyContainer);
     // Verify outcome
     Assert.InRange(result, minDate, maxDate);
     // Teardown
 }
コード例 #5
0
 public void CreateWithMultipleDateTimeRequestsReturnsDifferentDates()
 {
     // Fixture setup
     const int requestCount = 10;
     var times = Enumerable.Range(1, requestCount);
     var sut = new RandomDateTimeSequenceGenerator();
     // Exercise system
     var dummyContainer = new DelegatingSpecimenContext();
     var results = times
         .Select(t => sut.Create(typeof(DateTime), dummyContainer))
         .Cast<DateTime>();
     // Verify outcome
     Assert.Equal(requestCount, results.Distinct().Count());
     // Teardown
 }
コード例 #6
0
 public void CreateWithDateTimeRequestReturnsADateWithinARangeOfPlusMinusTwoYearsFromToday()
 {
     // Fixture setup
     var twoYearsAgo = DateTime.Today.AddYears(-2);
     var twoYearsForward = DateTime.Today.AddYears(2);
     var sut = new RandomDateTimeSequenceGenerator();
     // Exercise system
     var dummyContainer = new DelegatingSpecimenContext();
     var result = (DateTime)sut.Create(typeof(DateTime), dummyContainer);
     // Verify outcome
     Assert.InRange(result, twoYearsAgo, twoYearsForward);
     // Teardown
 }
コード例 #7
0
 public void CreateWithDateTimeRequestReturnsDateTimeValue()
 {
     // Fixture setup
     var sut = new RandomDateTimeSequenceGenerator();
     // Exercise system
     var dummyContainer = new DelegatingSpecimenContext();
     var result = sut.Create(typeof(DateTime), dummyContainer);
     // Verify outcome
     Assert.IsAssignableFrom<DateTime>(result);
     // Teardown
 }