public void GetAllSubscriptionsFromParcel_IsOk() { string trackingId = "ABCD12345"; string url1 = "martö"; string url2 = "michl"; Mock <IWebhookRepository> webMock = new Mock <IWebhookRepository>(); Mock <IParcelRepository> parcelMock = new Mock <IParcelRepository>(); List <Data.Webhook> webhooks = new List <Data.Webhook> { new Data.Webhook() { Id = 1, Url = url1, TrackingId = trackingId }, new Data.Webhook() { Id = 2, Url = url2, TrackingId = trackingId } }; webMock.Setup(foo => foo.GetByTrackingId(trackingId)).Returns(webhooks); IWebhookLogic webhookLogic = new WebhookLogic(mapper, webMock.Object, parcelMock.Object, NullLogger <WebhookLogic> .Instance); List <Webhook> hooksInDB = webhookLogic.GetAllSubscriptionsFromParcel(trackingId); Assert.Equal(1, hooksInDB[0].Id); Assert.Equal(2, hooksInDB[1].Id); Assert.Equal(trackingId, hooksInDB[0].TrackingId); Assert.Equal(trackingId, hooksInDB[1].TrackingId); Assert.Equal(url1, hooksInDB[0].Url); Assert.Equal(url2, hooksInDB[1].Url); }
public void GetAllSubscriptionsFromParcel_NoWebhooksForTrackingID() { string trackingId = "ABCD12345"; Mock <IWebhookRepository> webMock = new Mock <IWebhookRepository>(); Mock <IParcelRepository> parcelMock = new Mock <IParcelRepository>(); webMock.Setup(foo => foo.GetByTrackingId(trackingId)).Throws(new WebhookNotFoundExpection()); IWebhookLogic webhookLogic = new WebhookLogic(mapper, webMock.Object, parcelMock.Object, NullLogger <WebhookLogic> .Instance); Assert.Throws <BusinessLayerException>(() => webhookLogic.GetAllSubscriptionsFromParcel(trackingId)); }