Exemple #1
0
        public void SetUp()
        {
            var _versionHandler = new RuntimeConfiguredVersionHandler();

            _versionHandler.AddConfiguration <UserChangedPassword>(e => e.Version, (e, v) => e.ParentVersion = v);
            _versionHandler.AddConfiguration <UserRegistered>(e => e.Version, (e, v) => e.ParentVersion      = v);

            var _nullLogger = new NullLogger();

            Resolver.SetResolvers(
                type =>
            {
                if (type == typeof(IVersionHandler))
                {
                    return(_versionHandler);
                }

                if (type == typeof(ILogger))
                {
                    return(_nullLogger);
                }

                throw new NotSupportedException(string.Format("TestFixtureBase::SetUp - Nothing registered for {0}", type));
            },
                type => null);
        }
Exemple #2
0
        public void SetUp()
        {
            var _versionHandler = new RuntimeConfiguredVersionHandler();
            _versionHandler.AddConfiguration<UserChangedPassword>(e => e.Version, (e, v) => e.ParentVersion = v);
            _versionHandler.AddConfiguration<UserRegistered>(e => e.Version, (e, v) => e.ParentVersion = v);

            var _nullLogger = new NullLogger();

            Resolver.SetResolvers(
                type =>
                {
                    if (type == typeof(IVersionHandler))
                    {
                        return _versionHandler;
                    }

                    if (type == typeof(ILogger))
                    {
                        return _nullLogger;
                    }

                    throw new NotSupportedException(string.Format("TestFixtureBase::SetUp - Nothing registered for {0}", type));
                },
                type => null);
        }
        public void GivenAnyEvent_WhenQueryingVersion_ThenShouldReturnCorrectVersion()
        {
            // Arrange
            var versionHandler = new RuntimeConfiguredVersionHandler();
            versionHandler.AddConfiguration<UserRegistered>(e => e.Version, null);
            var evt = new UserRegistered(Guid.NewGuid());

            // Act
            Guid version = versionHandler.GetVersion(evt);

            // Assert
            Assert.AreEqual(evt.Version, version);
        }
Exemple #4
0
        public void GivenAnyEvent_WhenQueryingVersion_ThenShouldReturnCorrectVersion()
        {
            // Arrange
            var versionHandler = new RuntimeConfiguredVersionHandler();

            versionHandler.AddConfiguration <UserRegistered>(e => e.Version, null);
            var evt = new UserRegistered(Guid.NewGuid());

            // Act
            Guid version = versionHandler.GetVersion(evt);

            // Assert
            Assert.AreEqual(evt.Version, version);
        }
        public void GivenNewEvent_WhenSettingParentVersion_ThenShouldSetParentVersion()
        {
            // Arrange
            var userId = Guid.Parse("00000000-0000-0000-0000-000000000001");
            var userRegisteredEvent = new UserRegistered(userId);
            var userChangedPasswordEvent = new UserChangedPassword("newpassword");

            var versionHandler = new RuntimeConfiguredVersionHandler();
            versionHandler.AddConfiguration<UserChangedPassword>(null, (e, v) => e.ParentVersion = v);

            // Act
            versionHandler.SetParentVersion(userChangedPasswordEvent, userRegisteredEvent.Version);

            // Assert
            Assert.AreEqual(userRegisteredEvent.Version, userChangedPasswordEvent.ParentVersion);
        }
        public void SetUp()
        {
            var versionHandler = new RuntimeConfiguredVersionHandler();
            versionHandler.AddConfiguration<UserChangedPassword>(e => e.Version, (e, v) => e.ParentVersion = v);
            versionHandler.AddConfiguration<UserRegistered>(e => e.Version, (e, v) => e.ParentVersion = v);

            Resolver.SetResolver(
                t =>
                {
                    if (t == typeof(IVersionHandler))
                    {
                        return versionHandler;
                    }

                    throw new NotSupportedException(string.Format("Nothing registered in SetUp for {0}", t));
                });
        }
Exemple #7
0
        public void GivenNewEvent_WhenSettingParentVersion_ThenShouldSetParentVersion()
        {
            // Arrange
            var userId = Guid.Parse("00000000-0000-0000-0000-000000000001");
            var userRegisteredEvent      = new UserRegistered(userId);
            var userChangedPasswordEvent = new UserChangedPassword("newpassword");

            var versionHandler = new RuntimeConfiguredVersionHandler();

            versionHandler.AddConfiguration <UserChangedPassword>(null, (e, v) => e.ParentVersion = v);

            // Act
            versionHandler.SetParentVersion(userChangedPasswordEvent, userRegisteredEvent.Version);

            // Assert
            Assert.AreEqual(userRegisteredEvent.Version, userChangedPasswordEvent.ParentVersion);
        }
Exemple #8
0
        public void SetUp()
        {
            var versionHandler = new RuntimeConfiguredVersionHandler();

            versionHandler.AddConfiguration <UserChangedPassword>(e => e.Version, (e, v) => e.ParentVersion = v);
            versionHandler.AddConfiguration <UserRegistered>(e => e.Version, (e, v) => e.ParentVersion      = v);

            Resolver.SetResolver(
                t =>
            {
                if (t == typeof(IVersionHandler))
                {
                    return(versionHandler);
                }

                throw new NotSupportedException(string.Format("Nothing registered in SetUp for {0}", t));
            });
        }