Beispiel #1
0
        public void DomainNotificationFactory_should_find_LoginAttemptStartedNotification()
        {
            var domainNotificationFactory = new DomainNotificationFactory(
                NullLoggerFactory.Instance.CreateLogger <DomainNotificationFactory>(),
                typeof(Startup));

            Assert.AreEqual(typeof(LoginAttemptStartedNotification),
                            domainNotificationFactory.GetTypeByFullName(typeof(LoginAttemptStartedNotification).FullName));
        }
Beispiel #2
0
        public void DomainNotificationFactory_should_create_LoginAttemptStartedNotification_from_LoginAttemptCreatedEvent()
        {
            var loginAttemptId            = Guid.NewGuid();
            var userId                    = Guid.NewGuid();
            var domainEvent               = new LoginAttemptCreatedEvent(loginAttemptId, userId, "test");
            var domainNotificationFactory = new DomainNotificationFactory(
                NullLoggerFactory.Instance.CreateLogger <DomainNotificationFactory>(),
                typeof(Startup));
            var notification = domainNotificationFactory.CreateNotification(domainEvent);

            Assert.IsNotNull(notification);
            Assert.IsInstanceOfType(notification, typeof(LoginAttemptStartedNotification));
            Assert.AreEqual(domainEvent, notification.DomainEvent);

            var loginAttemptStartedNotification = (LoginAttemptStartedNotification)notification;

            Assert.AreEqual(loginAttemptId, loginAttemptStartedNotification.LoginAttemptId);
            Assert.AreEqual(userId, loginAttemptStartedNotification.UserId);
            Assert.AreEqual("test", loginAttemptStartedNotification.Secret);
        }
Beispiel #3
0
        public void DomainNotificationFactory_should_not_create_Notifications_for_Events_without_Notification()
        {
            var userId                    = Guid.NewGuid();
            var loginAttemptId            = Guid.NewGuid();
            var domainEvent               = new LoginAttemptCreatedEvent(loginAttemptId, userId, "test");
            var domainEvent2              = new LoginAttemptApprovedEvent(userId);
            var domainNotificationFactory = new DomainNotificationFactory(
                NullLoggerFactory.Instance.CreateLogger <DomainNotificationFactory>(),
                typeof(Startup));

            var domainEvents = new List <IDomainEvent>
            {
                domainEvent, domainEvent2
            };
            var domainEventNotifications = domainEvents
                                           .Select(domainNotificationFactory.CreateNotification)
                                           .Where(notification => notification != null)
                                           .ToList();

            Assert.AreEqual(1, domainEventNotifications.Count);
        }