public void ReturnNextImagesInOrder(SkinCalculator skinCalculator, Skin skin, DateTime start) { skin.StartOffset.Month = null; skin.StartOffset.Day = null; skin.StartOffset.Hour = null; var nextImages = skinCalculator.NextImage(skin, start); for (var i = 0; i < skin.Images.Count; i++) { Assert.Equal(skin.Images[i], nextImages.ElementAt(i)); } }
public void ReturnNextImageWhileAccomodatingTheHourOffset(int imageCount, int durationHours, int offsetHour, DateTime start, DateTime now, int imageIndex, [Frozen] Mock <IDateTimeProvider> dateTimeProviderMock, SkinCalculator skinCalculator) { var fixture = new Fixture(); dateTimeProviderMock.Setup(x => x.Now()).Returns(now); fixture.Register(() => TimeSpan.FromHours(durationHours)); fixture.Register((Func <IList <string> >)(() => { var images = new List <string>(); for (var i = 0; i < imageCount; i++) { images.Add(fixture.Create <string>()); } return(images); })); var skin = fixture.Create <Skin>(); skin.StartOffset.Month = null; skin.StartOffset.Day = null; skin.StartOffset.Hour = offsetHour; var nextImages = skinCalculator.NextImage(skin, start); Assert.Equal(skin.Images[imageIndex], nextImages.First()); }
public void CalculateNextDelayToAccomodateForTheHourOffset(int imageCount, int durationHours, int offsetHour, DateTime start, DateTime now, int expectedDelayMinutes, [Frozen] Mock <IDateTimeProvider> dateTimeProviderMock, SkinCalculator skinCalculator) { var fixture = new Fixture(); dateTimeProviderMock.Setup(x => x.Now()).Returns(now); fixture.Register(() => TimeSpan.FromHours(durationHours)); fixture.Register((Func <IList <string> >)(() => { var images = new List <string>(); for (var i = 0; i < imageCount; i++) { images.Add(fixture.Create <string>()); } return(images); })); var skin = fixture.Create <Skin>(); skin.StartOffset.Month = null; skin.StartOffset.Day = null; skin.StartOffset.Hour = offsetHour; var delay = skinCalculator.NextDelay(skin, start); Assert.Equal(TimeSpan.FromMinutes(expectedDelayMinutes), delay); }
public void PushStartBackWhenOffsetsPutStartInTheFuture(int imageCount, int durationHours, int?offsetMonth, int?offsetDay, int?offsetHour, DateTime now, int expectedIndex, [Frozen] Mock <IDateTimeProvider> dateTimeProviderMock, SkinCalculator skinCalculator) { var fixture = new Fixture(); dateTimeProviderMock.Setup(x => x.Now()).Returns(now); fixture.Register(() => TimeSpan.FromHours(durationHours)); fixture.Register(() => (IList <string>)fixture.CreateMany <string>(imageCount).ToList()); var skin = fixture.Create <Skin>(); skin.StartOffset.Month = offsetMonth; skin.StartOffset.Day = offsetDay; skin.StartOffset.Hour = offsetHour; var nextImages = skinCalculator.NextImage(skin, now); Assert.Equal(skin.Images[expectedIndex], nextImages.First()); }
public void ReturnNoImageWhenDurationWasExceeded(int imageCount, int durationDays, int offsetMonth, int offsetDay, DateTime start, DateTime now, [Frozen] Mock <IDateTimeProvider> dateTimeProviderMock, SkinCalculator skinCalculator) { var fixture = new Fixture(); dateTimeProviderMock.Setup(x => x.Now()).Returns(now); fixture.Register(() => TimeSpan.FromDays(durationDays)); fixture.Register((Func <IList <string> >)(() => { var images = new List <string>(); for (var i = 0; i < imageCount; i++) { images.Add(fixture.Create <string>()); } return(images); })); var skin = fixture.Create <Skin>(); skin.StartOffset.Month = offsetMonth; skin.StartOffset.Day = offsetDay; skin.StartOffset.Hour = null; var nextImages = skinCalculator.NextImage(skin, start); Assert.Empty(nextImages); }
public void ReturnNextImagesInOrderWhileAccomodatingTheDayOffset(int imageCount, int durationDays, int offsetMonth, int offsetDay, DateTime start, DateTime now, int imageIndex, [Frozen] Mock <IDateTimeProvider> dateTimeProviderMock, SkinCalculator skinCalculator) { var fixture = new Fixture(); dateTimeProviderMock.Setup(x => x.Now()).Returns(now); fixture.Register(() => TimeSpan.FromDays(durationDays)); fixture.Register((Func <IList <string> >)(() => { var images = new List <string>(); for (var i = 0; i < imageCount; i++) { images.Add(fixture.Create <string>()); } return(images); })); var skin = fixture.Create <Skin>(); skin.StartOffset.Month = offsetMonth; skin.StartOffset.Day = offsetDay; skin.StartOffset.Hour = null; var nextImages = new List <string>(); var day = 0; foreach (var nextImage in skinCalculator.NextImage(skin, start)) { nextImages.Add(nextImage); day++; dateTimeProviderMock.Setup(x => x.Now()).Returns(now.AddDays(day)); } Assert.Equal(skin.Images, nextImages); }
public void CalculateDelayToSpreadImagesAcrossTheDuration(int imageCount, int durationMilliseconds, int expectedDelayMillisecods, SkinCalculator skinCalculator, DateTime start) { var fixture = new Fixture(); fixture.Register(() => TimeSpan.FromMilliseconds(durationMilliseconds)); fixture.Register((Func <IList <string> >)(() => { var images = new List <string>(); for (var i = 0; i < imageCount; i++) { images.Add(fixture.Create <string>()); } return(images); })); var skin = fixture.Create <Skin>(); skin.StartOffset.Month = null; skin.StartOffset.Day = null; skin.StartOffset.Hour = null; var delay = skinCalculator.NextDelay(skin, start); Assert.Equal(TimeSpan.FromMilliseconds(expectedDelayMillisecods), delay); }