public void ToWorkModelExtensionsClass_ToToWorkMethod_ThrowsArgumentNullException_IfParameterIsNull() { ToWorkModel testObject = null; _ = testObject.ToToWork(); Assert.Fail(); }
public void ToWorkModelExtensionsClass_ToToWorkMethod_ReturnsObjectWithCorrectTextProperty_IfTextPropertyOfParameterIsNotNull() { ToWorkModel testParam = GetModel(); ToWork testOutput = testParam.ToToWork(); Assert.AreEqual(testParam.Text, testOutput.Text); }
public void ToWorkModelExtensionsClass_ToToWorkMethod_ThrowsNullReferenceException_IfParameterIsNull() { ToWorkModel testParam = null; _ = testParam.ToToWork(); Assert.Fail(); }
public void ToWorkModelExtensionsClass_ToToWorkMethod_ReturnsObjectWithAtTimePropertyEqualToNull_IfAtPropertyOfParameterIsNull() { ToWorkModel testParam = GetModel(); testParam.At = null; ToWork testOutput = testParam.ToToWork(); Assert.IsNull(testOutput.AtTime); }
public void ToWorkModelExtensionsClass_ToToWorkMethod_ReturnsObjectWithNullTextProperty_IfTextPropertyOfParameterIsNull() { ToWorkModel testParam = GetModel(); testParam.Text = null; ToWork testOutput = testParam.ToToWork(); Assert.IsNull(testOutput.Text); }
public void ToWorkModelExtensionsClass_ToToWorkMethod_ThrowsFormatException_IfParameterHasAtPropertyWithTimePropertyThatIsEmptyString() { ToWorkModel testParam = GetModel(); testParam.At = new TimeOfDayModel { Time = "" }; _ = testParam.ToToWork(); Assert.Fail(); }
public void ToWorkModelExtensionsClass_ToToWorkMethod_ThrowsFormatException_IfParameterHasAtPropertyWithTimePropertyThatIsSolelyWhitespace() { ToWorkModel testParam = GetModel(); testParam.At = new TimeOfDayModel { Time = _rnd.NextString(" \t\f\n", _rnd.Next(1, 10)) }; _ = testParam.ToToWork(); Assert.Fail(); }
public void ToWorkModelExtensionsClass_ToToWorkMethod_ThrowsFormatException_IfParameterHasAtPropertyWithTimePropertyThatConsistsOfNonNumericString() { string notATime = _rnd.NextString("abcdefghijklmnopqrstuvwxzy:", _rnd.Next(1, 50)); ToWorkModel testParam = GetModel(); testParam.At = new TimeOfDayModel { Time = notATime }; _ = testParam.ToToWork(); Assert.Fail(); }
public void ToWorkModelExtensionsClass_ToToWorkMethod_ThrowsArgumentNullExceptionWithCorrectParamNameProperty_IfParameterIsNull() { ToWorkModel testObject = null; try { _ = testObject.ToToWork(); Assert.Fail(); } catch (ArgumentNullException ex) { Assert.AreEqual("model", ex.ParamName); } }
public void ToWorkModelExtensionsClass_ToToWorkMethod_ReturnsObjectWithCorrectAtTimeProperty_IfParameterHasAtPropertyWithTimePropertyThatConsistsOfNumberInRangeWithNoColons() { int hoursValue = _rnd.Next(24); ToWorkModel testParam = GetModel(); testParam.At = new TimeOfDayModel { Time = hoursValue.ToString(CultureInfo.InvariantCulture) }; ToWork testOutput = testParam.ToToWork(); Assert.AreEqual(hoursValue * 3600, testOutput.AtTime.AbsoluteSeconds); Assert.AreEqual(hoursValue, testOutput.AtTime.Hours24); Assert.AreEqual(0, testOutput.AtTime.Minutes); Assert.AreEqual(0, testOutput.AtTime.Seconds); }
public void ToWorkModelExtensionsClass_ToToWorkMethod_ReturnsObjectWithCorrectAtTimeProperty_IfParameterHasAtPropertyWithTimePropertyThatConsistsOfTwoNumbersInRangeSeparatedByColon() { int hoursValue = _rnd.Next(24); int minutesValue = _rnd.Next(60); int expectedSeconds = hoursValue * 3600 + minutesValue * 60; ToWorkModel testParam = GetModel(); testParam.At = new TimeOfDayModel { Time = hoursValue.ToString(CultureInfo.InvariantCulture) + ":" + minutesValue.ToString(CultureInfo.InvariantCulture) }; ToWork testOutput = testParam.ToToWork(); Assert.AreEqual(expectedSeconds, testOutput.AtTime.AbsoluteSeconds); Assert.AreEqual(hoursValue % 24, testOutput.AtTime.Hours24); Assert.AreEqual(minutesValue % 60, testOutput.AtTime.Minutes); Assert.AreEqual(0, testOutput.AtTime.Seconds); }