Esempio n. 1
0
        public void ShouldRefuseToCreateLevelWithNonUniqueName()
        {
            var          structureId = new StructureId();
            const string levelName   = "New Level";

            var structure      = new Structure(structureId);
            var existingLevels = new[] { structure.CreateLevel(levelName, Enumerable.Empty <ILevel>()) };

            LevelCreatedEvent result = null;

            DomainEvents.Register((LevelCreatedEvent evt) =>
            {
                result = evt;
            });

            structure.Invoking(it => it.CreateLevel(levelName, existingLevels)).ShouldThrow <Exception>("level names must be unique");
            result.Should().BeNull("domain event should not be raised if validation fails");
        }
Esempio n. 2
0
        public void ShouldCreateNewLevel()
        {
            var          levelId     = new LevelId();
            var          structureId = new StructureId();
            const string levelName   = "New Level";

            LevelCreatedEvent result = null;

            DomainEvents.Register((LevelCreatedEvent evt) =>
            {
                result = evt;
            });

            var level = new Level(levelId, structureId, levelName);

            level.Id.Should().Be(levelId);
            level.Name.Should().Be(levelName);

            result.Should().NotBeNull("domain method should raise event");
        }
Esempio n. 3
0
 private void Apply(LevelCreatedEvent evt)
 {
     this.id   = evt.EntityId;
     this.name = evt.LevelName;
 }