private void ExecuteNotificationUrlTest(
            string expectedJsonFileName,
            Type classTypeExpected,
            string referencedObjectPropertyName,
            string subClassObjectPropertyName = null,
            Type subClassTypeExpected         = null)
        {
            var jsonString      = ReadJsonFromFile(expectedJsonFileName);
            var notificationUrl = NotificationUrl.CreateFromJsonString(jsonString);

            Assert.NotNull(notificationUrl);
            Assert.NotNull(notificationUrl.Object);

            var model = notificationUrl.Object.GetType()
                        .GetProperty(referencedObjectPropertyName)
                        .GetValue(notificationUrl.Object);
            var referencedModel = notificationUrl.Object.GetReferencedObject();

            Assert.NotNull(model);
            Assert.NotNull(referencedModel);
            Assert.IsType(classTypeExpected, referencedModel);

            if (subClassObjectPropertyName == null || subClassTypeExpected == null)
            {
                return;
            }
            var subClass = referencedModel.GetType()
                           .GetProperty(subClassObjectPropertyName)
                           .GetValue(referencedModel);

            Assert.NotNull(subClass);
            Assert.IsType(subClassTypeExpected, subClass);
        }
Exemple #2
0
        public void NotificationUrl_ParseOrderId_EmptyOrderIdQueryParam()
        {
            // Arrange
            var url = "https://www.samplestore.com/notifications?transactionid=&timestamp=1434014648";

            // Act
            var orderId = NotificationUrl.ParseOrderId(url);

            // Assert
            Assert.IsNull(orderId);
        }
Exemple #3
0
        public void NotificationUrl_ParseOrderId_HasOrderIdQueryParam()
        {
            // Arrange
            var url = "https://www.samplestore.com/notifications?transactionid=1434046577&timestamp=1434014648";

            // Act
            var orderId = NotificationUrl.ParseOrderId(url);

            // Assert
            Assert.AreEqual("1434046577", orderId);
        }
Exemple #4
0
        public void NotificationUrl_ParseOrderId_MissingOrderIdQueryParam()
        {
            // Arrange
            var url = "https://www.samplestore.com/notifications";

            // Act
            var orderId = NotificationUrl.ParseOrderId(url);

            // Assert
            Assert.IsNull(orderId);
        }
 public SubscriptionsController(ISubscriptionRepository subscriptionRepository, HttpClient graphClient, NotificationUrl notificationUrl)
 {
     if (subscriptionRepository == null)
     {
         throw new ArgumentNullException(nameof(subscriptionRepository));
     }
     if (graphClient == null)
     {
         throw new ArgumentNullException(nameof(graphClient));
     }
     if (notificationUrl == null)
     {
         throw new ArgumentNullException(nameof(notificationUrl));
     }
     _subscriptionRepository = subscriptionRepository;
     _graphClient            = graphClient;
     _notificationUrl        = notificationUrl;
 }