public void IsOfType_WhenIsCorrectType_It_should_not_throw() => ShouldNotThrow( () => Ensure.Type.IsOfType(BogusType, BogusType, ParamName), () => Ensure.Type.IsOfType(new Bogus(), BogusType, ParamName), () => EnsureArg.IsOfType(BogusType, BogusType, ParamName), () => EnsureArg.IsOfType(new Bogus(), BogusType, ParamName), () => Ensure.ThatType(typeof(Bogus), ParamName).IsOfType(BogusType), () => Ensure.ThatTypeFor(new Bogus(), ParamName).IsOfType(BogusType));
public void IsOfType_WhenNotTypeOf_ThrowsArgumentException() => AssertIsOfTypeScenario( NonBogusType, BogusType, () => Ensure.Type.IsOfType(typeof(Bogus), NonBogusType, ParamName), () => Ensure.Type.IsOfType(new Bogus(), NonBogusType, ParamName), () => EnsureArg.IsOfType(typeof(Bogus), NonBogusType, ParamName), () => EnsureArg.IsOfType(new Bogus(), NonBogusType, ParamName), () => Ensure.ThatType(typeof(Bogus), ParamName).IsOfType(NonBogusType), () => Ensure.ThatTypeFor(new Bogus(), ParamName).IsOfType(NonBogusType));
public virtual IEnumerable <Measurement> GetMeasurements(JToken token) { EnsureArg.IsNotNull(token, nameof(token)); EnsureArg.IsOfType(token, typeof(JObject), nameof(token)); foreach (var typeToken in MatchTypeTokens(token as JObject)) { yield return(CreateMeasurementFromToken(typeToken)); } }
/// <summary> /// Converts the FHIR element to a list of <see cref="ISearchValue"/>. /// </summary> /// <param name="value">The value to convert.</param> /// <returns>A list of <see cref="ISearchValue"/>.</returns> public IEnumerable <ISearchValue> ConvertTo(object value) { if (value == null) { return(Enumerable.Empty <ISearchValue>()); } EnsureArg.IsOfType(value, typeof(TFhirElement), nameof(value)); return((IEnumerable <ISearchValue>)ConvertTo((TFhirElement)value)); }
protected override void AddChild(Node child) { EnsureArg.IsNotNull(child, nameof(child)); EnsureArg.IsOfType( param: child, expectedType: typeof(ClassNode), paramName: nameof(child), optsFn: options => options.WithException(new NotSupportedException("Only class is to be added to a namespace")) ); Children.Add(child); }
public void IsOfType_WhenIsCorrectType_It_should_not_throw() { var returnedValue = Ensure.ThatTypeFor(new Bogus(), ParamName).IsOfType(BogusType); AssertReturnedAsExpected(returnedValue, BogusType); Action a = () => EnsureArg.IsOfType(BogusType, BogusType, ParamName); a.ShouldNotThrow(); Action b = () => EnsureArg.IsOfType(new Bogus(), BogusType, ParamName); b.ShouldNotThrow(); }