コード例 #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;
        }
コード例 #2
0
 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);
 }
コード例 #3
0
 protected Repository(IEventStore store, IKnownSerializers serializers)
 {
     _store             = store;
     _eventSerializer   = serializers.Events.Serializer;
     _eventDeserializer = serializers.Events.Deserializer;
 }
コード例 #4
0
 public UserRepository(IEventStore store,
                       IKnownSerializers serializers) : base(store, serializers)
 {
 }