public void CannotAddDataBeforeOrAfterBoundary() { var container = new DayData <int>(int.MinValue); ((Action)(() => container.AddDay(DATA_TYPE, DayDataConstants.MIN_DAY.AddDays(-1), _randomizer.Next()))) .Should().Throw <ArgumentException>(); ((Action)(() => container.AddDay(DATA_TYPE, DayDataConstants.MAX_DAY.AddDays(1), _randomizer.Next()))) .Should().Throw <ArgumentException>(); }
public void WhenGettingDataFromBeyondLastDay_DefaultReturned() { var container = new DayData <int>(int.MinValue); container.AddDay(nameof(this.WhenGettingDataFromBeyondLastDay_DefaultReturned), DateTime.Today.AddDays(-5), 1); container.GetData(nameof(this.WhenGettingDataFromBeyondLastDay_DefaultReturned), DateTime.Today) .Should() .Be(int.MinValue); }
public void AddDay(string dataType, DateTime day, int data) { if (short.MinValue < data && data < short.MaxValue) { _shortData.AddDay(dataType, day, (short)data); } else { _intData.AddDay(dataType, day, data); } }
public void CanTestIfDataPresent() { var data = _randomizer.Next(); var date = DateTime.Now.AddDays(-1 * _randomizer.Next(2, 30)); var container = new DayData <int>(int.MinValue); container.AddDay(DATA_TYPE, date, data); container.ContainsDataForDate(DATA_TYPE, date).Should().BeTrue(); container.ContainsDataForDate(DATA_TYPE, date.AddDays(1)).Should().BeFalse(); container.ContainsDataForDate(nameof(this.CanTestIfDataPresent), date).Should().BeFalse(); container.ContainsDataForDate(nameof(this.CanTestIfDataPresent), date.AddDays(1)).Should().BeFalse(); }
public void CanAddAndReceiveData() { var data = _randomizer.Next(); var date = DateTime.Now.AddDays(-1 * _randomizer.Next(1, 30)); var container = new DayData <int>(int.MinValue); container.AddDay(DATA_TYPE, date, data); container.GetData(DATA_TYPE, date).Should().Be(data); container.GetData(nameof(this.CanAddAndReceiveData), date).Should().Be(int.MinValue); var missingDate = DateTime.Now.AddDays(-1 * _randomizer.Next(31, 60)); container.GetData(DATA_TYPE, missingDate).Should().Be(int.MinValue); }