public void CreateWithNullContextThrowsArgumentNullException() { // Fixture setup var sut = new RandomDateTimeSequenceGenerator(); // Exercise system and verify outcome Assert.Throws<ArgumentNullException>( () => sut.Create(typeof(DateTime), null)); // Teardown }
public void SutIsSpecimenBuilder() { // Fixture setup // Exercise system var sut = new RandomDateTimeSequenceGenerator(); // Verify outcome Assert.IsAssignableFrom<ISpecimenBuilder>(sut); // Teardown }
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 }
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 }
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 }
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 }
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 }