Exemple #1
0
        public void invoke_lambda_source_without_specifying_a_filter_should_throw_exception()
        {
            theSource = new LambdaFieldValidationSource(new RequiredFieldRule());

            Exception <FubuValidationException> .ShouldBeThrownBy(() => TypeExtensions.As <IFieldValidationSource>(theSource).Validate())
            .Message.ShouldEqual("Missing filter on validation convention");
        }
Exemple #2
0
        private IEnumerable <IFieldValidationRule> rulesFor(Expression <Func <ValidationRegistryTarget, object> > expression)
        {
            var registry = new FieldRulesRegistry(TypeExtensions.As <IValidationRegistration>(theRegistry).FieldSources(), new TypeDescriptorCache());

            TypeExtensions.As <IValidationRegistration>(theRegistry).RegisterFieldRules(registry);

            return(registry.RulesFor <ValidationRegistryTarget>(expression));
        }
        public async Task <IEvent> ResolveAsync(DbDataReader reader, IIdentityMap map, QueryStatistics stats, CancellationToken token)
        {
            var id = await reader.GetFieldValueAsync <Guid>(0, token).ConfigureAwait(false);

            var eventTypeName = await reader.GetFieldValueAsync <string>(1, token).ConfigureAwait(false);

            var version = await reader.GetFieldValueAsync <int>(2, token).ConfigureAwait(false);

            var dataJson = reader.GetTextReader(3);
            //var dataJson = await reader.GetFieldValueAsync<string>(3, token).ConfigureAwait(false);

            var mapping = Events.EventMappingFor(eventTypeName);

            if (mapping == null)
            {
                var dotnetTypeName = await reader.GetFieldValueAsync <string>(8, token).ConfigureAwait(false);

                if (dotnetTypeName.IsEmpty())
                {
                    throw new UnknownEventTypeException(eventTypeName);
                }

                var type = Events.TypeForDotNetName(dotnetTypeName);
                mapping = Events.EventMappingFor(type);
            }

            var data = TypeExtensions.As <object>(_serializer.FromJson(mapping.DocumentType, dataJson));

            var sequence = await reader.GetFieldValueAsync <long>(4, token).ConfigureAwait(false);

            var stream = await reader.GetFieldValueAsync <string>(5, token).ConfigureAwait(false);

            var timestamp = await reader.GetFieldValueAsync <DateTimeOffset>(6, token).ConfigureAwait(false);

            var tenantId = await reader.GetFieldValueAsync <string>(7, token).ConfigureAwait(false);

            var @event = EventStream.ToEvent(data);

            @event.Version   = version;
            @event.Id        = id;
            @event.Sequence  = sequence;
            @event.StreamKey = stream;
            @event.Timestamp = timestamp;
            @event.TenantId  = tenantId;

            return(@event);
        }
Exemple #4
0
 public void register_an_explicit_source()
 {
     theRegistry.FieldSource <StubFieldSource>();
     TypeExtensions.As <IValidationRegistration>(theRegistry).FieldSources().Single().ShouldBeOfType <StubFieldSource>();
 }
Exemple #5
0
 public ConjoinedTenancy(IConnectionFactory factory, StoreOptions options) : base(options)
 {
     Default = new Tenant(options.Storage, options, factory, Tenancy.DefaultTenantId);
     Cleaner = new DocumentCleaner(options, Default);
     Schema  = new TenantSchema(options, TypeExtensions.As <Tenant>(Default));
 }