public void Subscribe_ShouldSuccessfullySubscribe() { var subscriptionRequest = new SubscriptionRequest("callbackUri", "topic", "12345", _oneDayTimeSpan, "secret", "verifyToken"); var actualRequestBody = ""; _mockHttpClient.Setup(x => x.Post(It.IsAny<string>())) .Callback(delegate(string requestData) { actualRequestBody = requestData; }); var subscriberClient = new SubscriberClient(_mockHttpClient.Object, _mockSubscriptionRepository.Object); subscriberClient.MakeRequest(subscriptionRequest); Assert.AreEqual(subscriptionRequest.BuildRequestParameterString(), actualRequestBody); }
public void Subscribe_ShouldPersistSubsciptionRequest() { var addedCount = 0; var subscriptionRequest = new SubscriptionRequest("callbackUri", "topic", "12345", _oneDayTimeSpan, "secret", "verifyToken"); _mockSubscriptionRepository.Setup(x => x.Add(It.IsAny<SubscriptionRequestBase>())) .Callback(delegate(SubscriptionRequestBase subscriptionRequestBase) { addedCount += 1; } ); var subscriberClient = new SubscriberClient(_mockHttpClient.Object, _mockSubscriptionRepository.Object); subscriberClient.MakeRequest(subscriptionRequest); Assert.AreEqual(1, addedCount); }