Exemple #1
0
        public void ShouldHaveModifiedEvent()
        {
            // Arrange
            Guid   expectedId     = Guid.NewGuid();
            string expectedName   = "ModifiedName";
            string expectedSymbol = "ModifiedSymbol";

            ExpenseType actual = ExpenseType.Create(expectedId, Guid.NewGuid(), "Name",
                                                    "Symbol");

            actual.FlushUncommitedEvents();

            // Act
            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 ExpenseTypeModifiedEvent);
            ExpenseTypeModifiedEvent @event = events[0] as ExpenseTypeModifiedEvent;

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

            ExpenseType actual = ExpenseType.Create(expectedId, Guid.NewGuid(), "Name",
                                                    "Symbol");

            actual.FlushUncommitedEvents();

            // Act
            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 ExpenseTypeDeletedEvent);
            ExpenseTypeDeletedEvent @event = events[0] as ExpenseTypeDeletedEvent;

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