public void GetValue_SettingWithValidation_Throws() { var configuration = Mock.Create <IConfiguration>(); Mock .Arrange(() => configuration.GetValue( Arg.IsAny <SoftString>(), Arg.IsAny <Type>(), Arg.IsAny <SoftString>()) ) .Returns((object)null) .OccursOnce(); var testClass3 = new TestClass3(); var validationException = Assert.ThrowsException <ValidationException>(() => configuration.GetValueFor(() => testClass3.Foo)); }
public void GetValue_SettingWithValidation_Valid() { var configuration = Mock.Create <IConfiguration>(); Mock .Arrange(() => configuration.GetValue( Arg.IsAny <SoftString>(), Arg.IsAny <Type>(), Arg.IsAny <SoftString>()) ) .Returns("foo") .OccursOnce(); var testClass3 = new TestClass3(); var value = configuration.GetValueFor(() => testClass3.Foo); configuration.Assert(); Assert.AreEqual("foo", value); }