public void GetXElement_SetName_ReturnCorrectXml() { Schedule sc = new Schedule(); sc.Name = "Schedule1"; var element = sc.GetXElement(); Assert.IsNotNull(element.Attribute(Schedule.CN_NAME)); Assert.IsTrue(element.Attribute(Schedule.CN_NAME).Value == sc.Name); }
public void GetXElement_SetDescription_ReturnCorrectXml() { Schedule sc = new Schedule(); sc.Name = "Schedule1"; sc.Description = "Description"; var element = sc.GetXElement(); Assert.IsNotNull(element.Attribute(Schedule.CN_DESCRIPTION)); Assert.IsTrue(element.Attribute(Schedule.CN_DESCRIPTION).Value == sc.Description); }
public void GetXElement_SetIsActiveTrue_ReturnCorrectXml() { Schedule sc = new Schedule(); sc.Name = "Schedule1"; sc.IsActive = true; var element = sc.GetXElement(); Assert.IsNotNull(element.Attribute(Schedule.CN_IS_ACTIVE)); Assert.IsTrue(bool.Parse(element.Attribute(Schedule.CN_IS_ACTIVE).Value)); }
public void ScheduleIsNotEqualToRandomObject() { var target = new Schedule(); Assert.IsFalse(target.Equals(new object())); }
public void ScheduleIsNotEqualToNull() { var target = new Schedule(); Assert.IsFalse(target.Equals(null)); }
public void ScheduleIsEqualToSelf() { var target = new Schedule(); Assert.IsTrue(target.Equals(target)); }
public void GetXElement_SetEndOnValue_ReturnCorrectXml() { Schedule sc = new Schedule(); sc.Name = "Schedule1"; sc.EndOn = DateTime.Now; var element = sc.GetXElement(); Assert.IsNotNull(element.Attribute(Schedule.CN_END_ON)); Assert.IsTrue(sc.EndOn == DateTime.Parse(element.Attribute(Schedule.CN_END_ON).Value)); }
public void WhenNewDateIsGreaterThanEndDate_GetNextTimeAfter_ReturnsNull() { // Arrange. var afterTime = new DateTime(2013, 1, 16, 10, 0, 0); var endDate = new DateTime(2013, 1, 16, 11, 0, 0); var dailyFrequency = Mock.Create<IScheduleDailyFrequency>(Behavior.CallOriginal); Mock.Arrange(() => dailyFrequency.GetNextTimeAfter(new TimeSpan(0, 10, 0, 0))).Returns(new TimeSpan(0, 12, 0, 0)); var pattern = Mock.Create<ISchedulePattern>(Behavior.CallOriginal); var target = new Schedule { DailyFrequency = dailyFrequency, Pattern = pattern, EndDate = endDate }; // Act. var result = target.GetNextTimeAfter(afterTime); // Assert. Assert.IsNull(result); }
public void SchedulesWithDifferentPatternAreNotEqual() { var pattern1 = Mock.Create<ISchedulePattern>(Behavior.CallOriginal); var pattern2 = Mock.Create<ISchedulePattern>(Behavior.CallOriginal); Mock.Arrange(() => pattern1.Equals(pattern2)).Returns(false); Mock.Arrange(() => pattern2.Equals(pattern1)).Returns(false); var target = new Schedule { Pattern = pattern1 }; var other = new Schedule { Pattern = pattern2 }; Assert.IsFalse(target.Equals(other)); }
public void SchedulesWithEqualValuesAreEqual() { // Arrange. var pattern1 = Mock.Create<ISchedulePattern>(Behavior.CallOriginal); var pattern2 = Mock.Create<ISchedulePattern>(Behavior.CallOriginal); Mock.Arrange(() => pattern1.Equals(pattern2)).Returns(true); Mock.Arrange(() => pattern2.Equals(pattern1)).Returns(true); var frequency1 = Mock.Create<IScheduleDailyFrequency>(Behavior.CallOriginal); var frequency2 = Mock.Create<IScheduleDailyFrequency>(Behavior.CallOriginal); Mock.Arrange(() => frequency1.Equals(frequency2)).Returns(true); Mock.Arrange(() => frequency2.Equals(frequency1)).Returns(true); var target = new Schedule { Guid = Guid.Parse("{FFBE399A-F417-487B-BC2B-1D1B2CBDF578}"), Name = "Schedule", Description = "Description", IsActive = true, StartDate = new DateTime(2013, 1, 16), EndDate = new DateTime(2013, 1, 17), Pattern = pattern1, DailyFrequency = frequency1 }; var other = new Schedule { Guid = Guid.Parse("{FFBE399A-F417-487B-BC2B-1D1B2CBDF578}"), Name = "Schedule", Description = "Description", IsActive = true, StartDate = new DateTime(2013, 1, 16), EndDate = new DateTime(2013, 1, 17), Pattern = pattern2, DailyFrequency = frequency2 }; // Assert. Assert.IsTrue(target.Equals(other)); }
public void SchedulesWithDifferentNameAreNotEqual() { var target = new Schedule { Name = "Schedule 1" }; var other = new Schedule { Name = "Schedule 2" }; Assert.IsFalse(target.Equals(other)); }
public void SchedulesWithDifferentIsActiveAreNotEqual() { var target = new Schedule { IsActive = false }; var other = new Schedule { IsActive = true }; Assert.IsFalse(target.Equals(other)); }
public void GetXElement_SetPatternDaily_ReturnsCorrectXml() { Schedule schedule = new Schedule(); schedule.Name = "name"; schedule.Pattern = new DailyPattern(); var element = schedule.GetXElement(); Assert.IsNotNull(element.Element(DailyPattern.CN_DAILY_PATTERN)); }
public void SchedulesWithDefaultValuesAreEqual() { var target = new Schedule(); var other = new Schedule(); Assert.IsTrue(target.Equals(other)); }
public void Schedule_Empty_HasDefaultDailyFrecuency() { Schedule sc = new Schedule(); Assert.IsNotNull(sc.DailyFrecuency); }
public void Schedule_Empty_HasDefaultSchedulePattern() { Schedule sc = new Schedule(); Assert.IsNotNull(sc.Pattern); }
public void ReadXElement_Empty_ThrowsSyncDocumentException() { Schedule sc = new Schedule(); XElement element = XElement.Parse("<NotSchedule />"); sc.ReadXElement(element); }
public void GetXElement_SetDailyFrecuencyOneTimePerDay_ReturnsCorrectXml() { Schedule schedule = new Schedule(); schedule.Name = "name"; schedule.DailyFrecuency = new DailyFrecuencyOneTimePerDay(); var element = schedule.GetXElement(); Assert.IsNotNull(element.Elements(DailyFrecuencyOneTimePerDay.CN_ONE_TIME_PER_DAY)); }
public void GetXElement_SetPatternWeekly_ReturnsCorrectXml() { Schedule schedule = new Schedule(); schedule.Name = "name"; schedule.Pattern = new WeeklyPattern(); var element = schedule.GetXElement(); Assert.IsNotNull(element.Elements(WeeklyPattern.cn_WeeklyPattern)); }
public void SchedulesWithDifferentGuidAreNotEqual() { var target = new Schedule { Guid = Guid.Parse("{0986C289-50E9-4FBC-AF11-C6BCBDE87276}") }; var other = new Schedule { Guid = Guid.Parse("{FF1E204E-9820-4B00-ABFD-52CAD2D3487B}") }; Assert.IsFalse(target.Equals(other)); }
public void GetXElement_SetStartOnNull_ReturnCorrectXml() { Schedule sc = new Schedule(); sc.Name = "Schedule1"; sc.StartOn = null; var element = sc.GetXElement(); Assert.IsNull(element.Attribute(Schedule.CN_START_ON)); }
public void SchedulesWithDifferentDescriptionAreNotEqual() { var target = new Schedule { Description = "Description 1" }; var other = new Schedule { Description = "Description 2" }; Assert.IsFalse(target.Equals(other)); }
public void WhenDailyFrequencyIsNull_GetNextTimeAfter_ThrowsException() { var pattern = Mock.Create<ISchedulePattern>(Behavior.CallOriginal); var target = new Schedule { Pattern = pattern, DailyFrequency = null }; target.GetNextTimeAfter(new DateTime(2013, 1, 16)); }
public void SchedulesWithDifferentEndDateAreNotEqual() { var target = new Schedule { EndDate = new DateTime(2013, 1, 16) }; var other = new Schedule { EndDate = new DateTime(2013, 1, 17) }; Assert.IsFalse(target.Equals(other)); }
public void GetNextTimeAfter_ReturnsNewTime_OnTheSameDate() { // Arrange. var afterTime = new DateTime(2013, 1, 16, 10, 0, 0); var nextDate = new DateTime(2013, 1, 16, 12, 0, 0); var dailyFrequency = Mock.Create<IScheduleDailyFrequency>(Behavior.CallOriginal); Mock.Arrange(() => dailyFrequency.GetNextTimeAfter(new TimeSpan(0, 10, 0, 0))).Returns(new TimeSpan(0, 12, 0, 0)); var pattern = Mock.Create<ISchedulePattern>(Behavior.CallOriginal); var target = new Schedule { DailyFrequency = dailyFrequency, Pattern = pattern }; // Act. var result = target.GetNextTimeAfter(afterTime); // Assert. Assert.IsNotNull(result); Assert.AreEqual(nextDate, result); }
public void SchedulesWithDifferentDailyFrequencyAreNotEqual() { var frequency1 = Mock.Create<IScheduleDailyFrequency>(Behavior.CallOriginal); var frequency2 = Mock.Create<IScheduleDailyFrequency>(Behavior.CallOriginal); Mock.Arrange(() => frequency1.Equals(frequency2)).Returns(false); Mock.Arrange(() => frequency2.Equals(frequency1)).Returns(false); var target = new Schedule { DailyFrequency = frequency1 }; var other = new Schedule { DailyFrequency = frequency2 }; Assert.IsFalse(target.Equals(other)); }
public void WhenPatternReturnsNull_GetNextTimeAfter_ReturnsNull() { // Arrange. var afterTime = new DateTime(2013, 1, 16, 10, 0, 0); var dailyFrequency = Mock.Create<IScheduleDailyFrequency>(Behavior.CallOriginal); // There is no new schedule time after 10:00. Mock.Arrange(() => dailyFrequency.GetNextTimeAfter(new TimeSpan(0, 10, 0, 0))).Returns(null as TimeSpan?); // Set start schedule time to 05:00. Mock.Arrange(() => dailyFrequency.GetNextTimeAfter(null)).Returns(new TimeSpan(0, 5, 0, 0)); var pattern = Mock.Create<ISchedulePattern>(Behavior.CallOriginal); // Set next schedule date. Mock.Arrange(() => pattern.GetNextDateAfter(Arg.IsAny<DateTime>())).Returns(null as DateTime?); var target = new Schedule { DailyFrequency = dailyFrequency, Pattern = pattern }; // Act. var result = target.GetNextTimeAfter(afterTime); // Assert. Assert.IsNull(result); }
public void GetHashCodeTest() { var guid = Guid.NewGuid(); const bool IsActive = true; var hash = guid.GetHashCode() ^ 0 ^ 0 ^ IsActive.GetHashCode() ^ 0 ^ 0 ^ 0 ^ 0; var instance = new Schedule { Guid = guid, IsActive = IsActive }; var res = instance.GetHashCode(); Assert.AreEqual(hash, res); }
public void ReadXElement_Empty_ThrowsArgumentNullException() { Schedule sc = new Schedule(); XElement element = null; sc.ReadXElement(element); }