public void TestNotify_ApplicationNotRegistered_ReturnsErrorLogsFailure()
 {
     var service = new FoghornService();
     var notificationDto = new NotificationDto
         {
             NotificationMessage = "This is the message of the test notification.",
             NotificationTypeName = NotificationName + "1",
             NotificationTitle = "Notification Title"
         };
     Assert.Throws<ArgumentException>(delegate { service.Notify(notificationDto, "IncorrectApplication"); });
 }
 public void TestNotify_SetUpConfigurationAndCallNotify_NotificationSentAndLogged()
 {
     TestRegisterSubscription_ApplicationExists_SubscriberRegistered();
     var service = new FoghornService();
     var notificationDto = new NotificationDto
         {
             NotificationMessage = "This is the message of the test notification.",
             NotificationTypeName = NotificationName + "1",
             NotificationTitle = "Notification Title",
             Sticky = true,
             Priority = 2
         };
     var notificationDtoReturned = service.Notify(notificationDto, ApplicationTestName);
     var notificationId = notificationDtoReturned.NotificationId;
     var dataContext = new FoghornEntities();
     var checkNotification = dataContext.Notifications.FirstOrDefault(x => x.NotificationId == notificationId);
     Assert.NotNull(checkNotification);
 }
        public void TestRegisterSendingApplication_3NotificationTypes_ApplicationAndNotificationsInDatabase()
        {
            var dataContext = new FoghornEntities();

            DeleteTestApplications(dataContext);
            var service = new FoghornService();
            RegisterTestApplication(service);

            Assert.True(_testApplicationId > 0);

            var application =
                dataContext.SendingApplications.FirstOrDefault(x => x.SendingApplicationName == ApplicationTestName);
            Assert.NotNull(application);
            Assert.Equal(NumNotificationTypes, application.NotificationTypes.Count);
            Assert.True(application.NotificationTypes.First().NotificationTypeName.StartsWith(NotificationName));
            Assert.Equal(_testApplicationId, application.SendingApplicationId);
        }
 public void TestRegisterSubscription_ApplicationExists_SubscriberRegistered()
 {
     var service = new FoghornService();
     if (_testApplicationId <= 0)
     {
         RegisterTestApplication(service);
     }
     var subscriberDto = new SubscriberDto
         {
             HostName = "localhost",
             Password = "******",
             SubscriberName = ApplicationTestName + "TestSubscriber",
         };
     var subscriberId = service.RegisterSubscription(subscriberDto, ApplicationTestName);
     var dataContext = new FoghornEntities();
     var subscriber = dataContext.Subscribers.FirstOrDefault(x => x.SubscriberId == subscriberId);
     Assert.NotNull(subscriber);
 }