public void Setup() { Mappings = new[] { MappingOf(new Iri("http://schema.org/name"), "eventName"), MappingOf(new Iri("http://schema.org/description"), "eventDescription"), }; Builder = new MappingsBuilder(Mappings); Strategy = new BodyResourceBoundIriTemplateExpansionStrategy(); var mappingsRepository = new Mock <IMappingsRepository>(MockBehavior.Strict); mappingsRepository.Setup(_ => _.FindPropertyMappingFor(It.IsAny <IEntity>(), It.IsAny <Iri>(), It.IsAny <Iri>())) .Returns <IEntity, Iri, Iri>((entity, iri, graph) => { var propertyInfo = ( from property in typeof(IEvent).GetProperties(BindingFlags.Instance | BindingFlags.Public) from propertyMapping in property.GetCustomAttributes <PropertyAttribute>() where propertyMapping.Iri == iri select property).First(); var result = new Mock <IPropertyMapping>(MockBehavior.Strict); result.SetupGet(_ => _.PropertyInfo).Returns(propertyInfo); return(result.Object); }); var context = new Mock <IEntityContext>(MockBehavior.Strict); context.SetupGet(_ => _.Mappings).Returns(mappingsRepository.Object); Body = new MulticastObject().ActLike <IEvent>(); Body.Description = "Some description"; Body.Unwrap().SetProperty(typeof(IEntity).GetProperty(nameof(IEntity.Context)), context.Object); Parameters = new MulticastObject().ActLike <IEvent>(); Parameters.Name = "the-name"; Parameters.Unwrap().SetProperty(typeof(IEntity).GetProperty(nameof(IEntity.Context)), context.Object); ScenarioSetup(); TheTest(); }
public void Setup() { Mappings = new[] { TemplateMappingOf(new Iri("http://schema.org/name"), "eventName"), TemplateMappingOf(new Iri("http://schema.org/description"), "eventDescription") }; Builder = new MappingsBuilder(Mappings); TheTest(); }
private void WithResourceVariables(MappingsBuilder builder, IResource body, IResource auxResource) { var variableMappings = builder.VariableMappings; foreach (var variable in variableMappings) { var literal = GetValue(body, variable.Value) ?? GetValue(auxResource, variable.Value); builder.WithVariable(variable.Key).HavingValueOf(literal); } }