public void MaybeDeep_nullFirstStep_returnsNull() { var instance = new MaybeTestHelper() {NestedInstance = null}; var actual = instance.MaybeDeep(x => x.NestedInstance.DeepProperty); Assert.IsNull( actual); }
public void MaybeDeep_NestedValue_returnsValue() { var expected = "expected"; var instance = new MaybeTestHelper() {NestedInstance = new MaybeTestHelper() {DeepProperty =expected }}; var actual = instance.MaybeDeep(x => x.NestedInstance.DeepProperty); Assert.AreEqual(expected, actual); }
public void MaybeShallowNullable_value_returnsValue() { //arrange var instance = new MaybeTestHelper(); var expected = MaybeTestHelper.HasValueConstant; var actual = instance.MaybeShallowNullable(x => x.InstanceNullableIntFieldWithValue); Assert.AreEqual(expected, actual.Value); }
public void MaybeDeep_PrimitiveValue_ThrowsArgumentException() { var instance = new MaybeTestHelper(); try { var action = instance.MaybeDeep(x => x.InstanceIntField); Assert.Fail("Did not throw exception"); } catch (Exception ex) { Assert.IsInstanceOfType(ex, typeof(ArgumentException)); } }
public void Maybe_NullableValueWithNull_ReturnsNull() { var instance = new MaybeTestHelper(); var actual = instance.MaybeDeep(x => x.InstanceNullableIntField); Assert.IsNull(actual); }
public void MaybeDeep_nullSecondStep_returnsNull() { var instance = new MaybeTestHelper() {NestedInstance = new MaybeTestHelper() {NestedInstance = null}}; var actual = instance.MaybeDeep(i => i.NestedInstance.NestedInstance.DeepProperty); }
public void Maybe_NullableValueWithValue_ReturnsValue() { var instance = new MaybeTestHelper(); int? expected = MaybeTestHelper.HasValueConstant; var actual = instance.MaybeDeep(x => x.InstanceNullableIntFieldWithValue); Assert.AreEqual(expected, actual); }