public void CreateWithDateTimeRequestsTwiceWithinMillisecondsReturnsDatesExactlyOneDayApart() { // Arrange var nowResolution = TimeSpan.FromMilliseconds(10); // see http://msdn.microsoft.com/en-us/library/system.datetime.now.aspx var request = typeof(DateTime); var seed = DateTime.Now; var sut = new StrictlyMonotonicallyIncreasingDateTimeGenerator(seed); // Act var dummyContainer = new DelegatingSpecimenContext(); var firstResult = (DateTime)sut.Create(request, dummyContainer); Thread.Sleep(nowResolution + nowResolution); var secondResult = (DateTime)sut.Create(request, dummyContainer); // Assert Assert.Equal(firstResult.AddDays(1), secondResult); }
public void CreateWithNullRequestReturnsNoSpecimen() { // Arrange var seed = DateTime.Now; var sut = new StrictlyMonotonicallyIncreasingDateTimeGenerator(seed); // Act var dummyContainer = new DelegatingSpecimenContext(); var result = sut.Create(null, dummyContainer); // Assert Assert.Equal(new NoSpecimen(), result); }
public void CreateWithNullRequestReturnsNoSpecimen() { // Fixture setup var seed = DateTime.Now; var sut = new StrictlyMonotonicallyIncreasingDateTimeGenerator(seed); // Exercise system var dummyContainer = new DelegatingSpecimenContext(); var result = sut.Create(null, dummyContainer); // Verify outcome Assert.Equal(new NoSpecimen(), result); // Teardown }
public void CreateWithDateTimeRequestReturnsDifferentDay() { // Arrange var request = typeof(DateTime); var seed = DateTime.Now; var sut = new StrictlyMonotonicallyIncreasingDateTimeGenerator(seed); // Act var dummyContainer = new DelegatingSpecimenContext(); var result = (DateTime)sut.Create(request, dummyContainer); // Assert Assert.NotEqual(DateTime.Today, result.Date); }
public void CreateWithDateTimeRequestReturnsDateTimeValue() { // Arrange var request = typeof(DateTime); var seed = DateTime.Now; var sut = new StrictlyMonotonicallyIncreasingDateTimeGenerator(seed); // Act var dummyContainer = new DelegatingSpecimenContext(); var result = sut.Create(request, dummyContainer); // Assert Assert.IsAssignableFrom <DateTime>(result); }
public void CreateWithNonDateTimeTypeRequestReturnsNoSpecimen(Type request) { // Arrange var seed = DateTime.Now; var sut = new StrictlyMonotonicallyIncreasingDateTimeGenerator(seed); // Act var dummyContainer = new DelegatingSpecimenContext(); var result = sut.Create(request, dummyContainer); // Assert var expectedResult = new NoSpecimen(); Assert.Equal(expectedResult, result); }
public void CreateWithDateTimeRequestAndSeedValueReturnsSeedValuePlusOneDay() { // Arrange var request = typeof(DateTime); var seed = DateTime.Now.AddDays(3); var sut = new StrictlyMonotonicallyIncreasingDateTimeGenerator(seed); // Act var dummyContainer = new DelegatingSpecimenContext(); var result = (DateTime)sut.Create(request, dummyContainer); // Assert Assert.Equal(seed.AddDays(1), result); }
public void CreateWithDateTimeRequestReturnsDifferentDay() { // Fixture setup var request = typeof(DateTime); var seed = DateTime.Now; var sut = new StrictlyMonotonicallyIncreasingDateTimeGenerator(seed); // Exercise system var dummyContainer = new DelegatingSpecimenContext(); var result = (DateTime)sut.Create(request, dummyContainer); // Verify outcome Assert.NotEqual(DateTime.Today, result.Date); // Teardown }
public void CreateWithDateTimeRequestReturnsDateTimeValue() { // Fixture setup var request = typeof(DateTime); var seed = DateTime.Now; var sut = new StrictlyMonotonicallyIncreasingDateTimeGenerator(seed); // Exercise system var dummyContainer = new DelegatingSpecimenContext(); var result = sut.Create(request, dummyContainer); // Verify outcome Assert.IsAssignableFrom <DateTime>(result); // Teardown }
public void CreateWithNonTypeRequestReturnsNoSpecimen(object request) { // Fixture setup var seed = DateTime.Now; var sut = new StrictlyMonotonicallyIncreasingDateTimeGenerator(seed); // Exercise system var dummyContainer = new DelegatingSpecimenContext(); var result = sut.Create(request, dummyContainer); // Verify outcome var expectedResult = new NoSpecimen(request); Assert.Equal(expectedResult, result); // Teardown }
public void CreateWithDateTimeRequestAndSeedValueReturnsSeedValuePlusOneDay() { // Fixture setup var request = typeof(DateTime); var seed = DateTime.Now.AddDays(3); var sut = new StrictlyMonotonicallyIncreasingDateTimeGenerator(seed); // Exercise system var dummyContainer = new DelegatingSpecimenContext(); var result = (DateTime)sut.Create(request, dummyContainer); // Verify outcome Assert.Equal(seed.AddDays(1), result); // Teardown }
public void CreateWithMultipleDateTimeRequestsReturnsSequenceOfDates() { // Arrange var sequence = Enumerable.Range(1, 7); var expectedDates = sequence.Select(i => DateTime.Today.AddDays(i)); var request = typeof(DateTime); var seed = DateTime.Now; var sut = new StrictlyMonotonicallyIncreasingDateTimeGenerator(seed); // Act var dummyContainer = new DelegatingSpecimenContext(); var results = sequence.Select(i => (DateTime)sut.Create(request, dummyContainer)).ToArray(); // Assert Assert.True(expectedDates.SequenceEqual(results.Select(i => i.Date))); }