Пример #1
0
        public void ShouldHaveModifiedEvent()
        {
            // Arrange
            Guid   expectedId     = Guid.NewGuid();
            string expectedName   = "ModifiedName";
            string expectedSymbol = "ModifiedSymbol";

            // Act
            SavingType actual = SavingType.Create(expectedId, Guid.NewGuid(), "Name",
                                                  "Symbol");

            actual.FlushUncommitedEvents();
            actual.Modify(expectedName, expectedSymbol, 1);

            // Assert
            Assert.IsTrue(actual.Events != null);
            Assert.IsTrue(actual.Events.Count == 1);
            var events = actual.FlushUncommitedEvents();

            Assert.IsTrue(events != null);
            Assert.IsTrue(events.Length == 1);
            Assert.IsTrue(events[0] is SavingTypeModifiedEvent);
            SavingTypeModifiedEvent @event = events[0] as SavingTypeModifiedEvent;

            Assert.IsTrue(@event.EntityId == expectedId);
            Assert.IsTrue(@event.Name == expectedName);
            Assert.IsTrue(@event.Symbol == expectedSymbol);
        }
Пример #2
0
        public void ShouldHaveDeletedEvent()
        {
            // Arrange
            Guid expectedId = Guid.NewGuid();

            // Act
            SavingType actual = SavingType.Create(expectedId, Guid.NewGuid(), "Name",
                                                  "Symbol");

            actual.FlushUncommitedEvents();
            actual.Delete();

            // Assert
            Assert.IsTrue(actual.Events != null);
            Assert.IsTrue(actual.Events.Count == 1);
            var events = actual.FlushUncommitedEvents();

            Assert.IsTrue(events != null);
            Assert.IsTrue(events.Length == 1);
            Assert.IsTrue(events[0] is SavingTypeDeletedEvent);
            SavingTypeDeletedEvent @event = events[0] as SavingTypeDeletedEvent;

            Assert.IsTrue(@event.EntityId == expectedId);
        }