Ejemplo n.º 1
0
        public UserUseCases()
        {
            _token          = Guid.NewGuid().ToString("N");
            _passwordHasher = s => Convert.ToBase64String(MD5.Create().ComputeHash(Encoding.ASCII.GetBytes(s)));
            _keyStore       = new ReallyInsecureAndVeryTemporaryKeyStore();
            _keyStore.CreateKeyIfNotExists("test");
            SerializationRegistry serializationRegistry = new SerializationRegistry();

            UserBoundedContext.RegisterSerializers(serializationRegistry, _keyStore);
            IKnownSerializers serialization = serializationRegistry.Build();

            _eventStore = new TestEventStore(serialization);
            CommandRegistry commandRegistry = new CommandRegistry();

            _lockoutPolicy = () => Clock.Now + TimeSpan.FromMinutes(5);
            UserBoundedContext.RegisterCommands(
                commandRegistry,
                new UserRepository(_eventStore, serialization),
                tokenSource: () => _token,
                passwordHasher: _passwordHasher,
                maxLoginAttempts: 3,
                lockoutPolicy: _lockoutPolicy);
            _handler         = commandRegistry.Build();
            _now             = DateTimeOffset.UtcNow;
            Clock.UtcNowFunc = () => _now;
        }
 public TestEventStore(IKnownSerializers serializers)
 {
     _eventSerializer   = serializers.Events.Serializer;
     _eventDeserializer = serializers.Events.Deserializer;
     _streams           = new Dictionary <string, IReadOnlyList <SerializedEvent> >();
     _streamPositions   = new Dictionary <string, int>();
     ExpectedVersion    = new ExpectedVersion(-1, -2, -3);
 }
Ejemplo n.º 3
0
 protected Repository(IEventStore store, IKnownSerializers serializers)
 {
     _store             = store;
     _eventSerializer   = serializers.Events.Serializer;
     _eventDeserializer = serializers.Events.Deserializer;
 }
 public UserRepository(IEventStore store,
                       IKnownSerializers serializers) : base(store, serializers)
 {
 }