public void TryValidateModelReturnsArgumentNullException()
        {
            //Arrange
            var service = new WebhooksService(fakeLogger, fakeMapper, fakeCmsApiService, fakeConfigurationSetDocumentService);
            StaticContentItemModel model = null;

            // Act & Assert
            Assert.Throws <ArgumentNullException>(() => service.TryValidateModel(model));
        }
        public void WebhooksServiceDetermineMessageContentTypeReturnsExpected(string?apiEndpoint, MessageContentType expectedResponse)
        {
            // Arrange

            // Act
            var result = WebhooksService.DetermineMessageContentType(apiEndpoint);

            // Assert
            Assert.Equal(expectedResponse, result);
        }
        public void TryValidateModelForValidAndInvalid(StaticContentItemModel model, bool expectedResult)
        {
            //Arrange
            var service = new WebhooksService(fakeLogger, fakeMapper, fakeCmsApiService, fakeConfigurationSetDocumentService);

            //Act
            var result = service.TryValidateModel(model);

            //Assert
            Assert.Equal(expectedResult, result);
        }
 /// <summary>
 /// Creates a new instance of the NewTwitchAPIServices class with the specified connection.
 /// </summary>
 /// <param name="connection">The Twitch connection</param>
 public NewTwitchAPIServices(TwitchConnection connection)
 {
     this.Ads           = new AdsService(connection);
     this.Bits          = new BitsService(connection);
     this.Channels      = new ChannelsService(connection);
     this.Chat          = new ChatService(connection);
     this.Clips         = new ClipsService(connection);
     this.Games         = new GamesService(connection);
     this.Streams       = new StreamsService(connection);
     this.Subscriptions = new SubscriptionsService(connection);
     this.Tags          = new TagsService(connection);
     this.Users         = new UsersService(connection);
     this.Webhooks      = new WebhooksService(connection);
 }
        public async Task ProcessMessageAsyncCreateOrUpdateThrowsInvalidDataException()
        {
            //Arrange
            var service = new WebhooksService(fakeLogger, fakeMapper, fakeCmsApiService, fakeConfigurationSetDocumentService);

            //Act
            await Assert.ThrowsAsync <InvalidDataException>(async() => await service.ProcessMessageAsync(WebhookCacheOperation.CreateOrUpdate, Guid.NewGuid(), Guid.NewGuid(), "http//somewhere.com").ConfigureAwait(false)).ConfigureAwait(false);

            //Assert
            A.CallTo(() => fakeCmsApiService.GetItemAsync <StaticContentItemApiDataModel>(A <Uri> .Ignored)).MustNotHaveHappened();
            A.CallTo(() => fakeMapper.Map <StaticContentItemModel>(A <StaticContentItemApiDataModel> .Ignored)).MustNotHaveHappened();
            A.CallTo(() => fakeConfigurationSetDocumentService.UpsertAsync(A <StaticContentItemModel> .Ignored)).MustNotHaveHappened();
            A.CallTo(() => fakeConfigurationSetDocumentService.DeleteAsync(A <Guid> .Ignored)).MustNotHaveHappened();
        }
        public async Task DeleteContentItemAsyncReturnsSuccess(bool deletionResult, HttpStatusCode expectedResult)
        {
            //Arrange
            var service = new WebhooksService(fakeLogger, fakeMapper, fakeCmsApiService, fakeConfigurationSetDocumentService);

            A.CallTo(() => fakeConfigurationSetDocumentService.DeleteAsync(A <Guid> .Ignored)).Returns(deletionResult);

            //Act
            var result = await service.DeleteContentItemAsync(Guid.NewGuid()).ConfigureAwait(false);

            //Assert
            A.CallTo(() => fakeConfigurationSetDocumentService.DeleteAsync(A <Guid> .Ignored)).MustHaveHappenedOnceExactly();

            Assert.Equal(expectedResult, result);
        }
Esempio n. 7
0
 /// <summary>
 /// Initializes all the services offered by the current version of
 /// this API.
 /// </summary>
 /// <see cref="IdentityService"/>
 /// <see cref="HttpService"/>
 /// <see cref="OAuth2Service"/>
 private void InitializeServices()
 {
     Http              = new HttpService(RestClientWrapper.RestClient, new RequestBuilder());
     Accounts          = new AccountsService(this);
     Certificates      = new CertificatesService(this);
     Contacts          = new ContactsService(this);
     Domains           = new DomainsService(this);
     Identity          = new IdentityService(this);
     OAuth             = new OAuth2Service(Http);
     Registrar         = new RegistrarService(this);
     Services          = new ServicesService(this);
     Tlds              = new TldsService(this);
     Templates         = new TemplatesService(this);
     VanityNameServers = new VanityNameServersService(this);
     Webhooks          = new WebhooksService(this);
     Zones             = new ZonesService(this);
 }
        public async Task ProcessMessageAsyncNoneReturnsBadRequest()
        {
            //Arrange
            const HttpStatusCode expectedResult = HttpStatusCode.BadRequest;
            var service = new WebhooksService(fakeLogger, fakeMapper, fakeCmsApiService, fakeConfigurationSetDocumentService);

            //Act
            var result = await service.ProcessMessageAsync(WebhookCacheOperation.None, Guid.NewGuid(), Guid.NewGuid(), "https://somewhere.com").ConfigureAwait(false);

            //Assert
            A.CallTo(() => fakeCmsApiService.GetItemAsync <StaticContentItemApiDataModel>(A <Uri> .Ignored)).MustNotHaveHappened();
            A.CallTo(() => fakeMapper.Map <StaticContentItemModel>(A <StaticContentItemApiDataModel> .Ignored)).MustNotHaveHappened();
            A.CallTo(() => fakeConfigurationSetDocumentService.UpsertAsync(A <StaticContentItemModel> .Ignored)).MustNotHaveHappened();
            A.CallTo(() => fakeConfigurationSetDocumentService.DeleteAsync(A <Guid> .Ignored)).MustNotHaveHappened();

            Assert.Equal(expectedResult, result);
        }
 /// <summary>
 /// Creates a new instance of the NewTwitchAPIServices class with the specified connection.
 /// </summary>
 /// <param name="connection">The Twitch connection</param>
 public NewTwitchAPIServices(TwitchConnection connection)
 {
     this.Ads           = new AdsService(connection);
     this.Bits          = new BitsService(connection);
     this.ChannelPoints = new ChannelPointsService(connection);
     this.Channels      = new ChannelsService(connection);
     this.Chat          = new ChatService(connection);
     this.Clips         = new ClipsService(connection);
     this.EventSub      = new EventSubService(connection);
     this.Games         = new GamesService(connection);
     this.Polls         = new PollsService(connection);
     this.Predictions   = new PredictionsService(connection);
     this.Schedule      = new ScheduleService(connection);
     this.Streams       = new StreamsService(connection);
     this.Subscriptions = new SubscriptionsService(connection);
     this.Tags          = new TagsService(connection);
     this.Teams         = new TeamsService(connection);
     this.Users         = new UsersService(connection);
     this.Webhooks      = new WebhooksService(connection);
 }
Esempio n. 10
0
        public MockDnsimpleClient(string fixture)
        {
            Fixture   = fixture;
            UserAgent = "Testing user agent";

            Accounts          = new AccountsService(this);
            Certificates      = new CertificatesService(this);
            Contacts          = new ContactsService(this);
            Domains           = new DomainsService(this);
            Http              = new MockHttpService("v2", Fixture, BaseUrl);
            Identity          = new IdentityService(this);
            OAuth             = new OAuth2Service(Http);
            Registrar         = new RegistrarService(this);
            Services          = new ServicesService(this);
            Tlds              = new TldsService(this);
            Templates         = new TemplatesService(this);
            VanityNameServers = new VanityNameServersService(this);
            Webhooks          = new WebhooksService(this);
            Zones             = new ZonesService(this);
        }
        public async Task ProcessMessageAsyncDeleteReturnsSuccess()
        {
            //Arrange
            const HttpStatusCode expectedResult = HttpStatusCode.OK;
            var service = new WebhooksService(fakeLogger, fakeMapper, fakeCmsApiService, fakeConfigurationSetDocumentService);
            var dummyStaticContentItemApiDataModel = A.Dummy <StaticContentItemApiDataModel>();
            var validStaticContentItemModel        = BuildValidStaticContentItemModel();

            A.CallTo(() => fakeConfigurationSetDocumentService.DeleteAsync(A <Guid> .Ignored)).Returns(true);

            //Act
            var result = await service.ProcessMessageAsync(WebhookCacheOperation.Delete, Guid.NewGuid(), Guid.NewGuid(), "https://somewhere.com").ConfigureAwait(false);

            //Assert
            A.CallTo(() => fakeCmsApiService.GetItemAsync <StaticContentItemApiDataModel>(A <Uri> .Ignored)).MustNotHaveHappened();
            A.CallTo(() => fakeMapper.Map <StaticContentItemModel>(A <StaticContentItemApiDataModel> .Ignored)).MustNotHaveHappened();
            A.CallTo(() => fakeConfigurationSetDocumentService.UpsertAsync(A <StaticContentItemModel> .Ignored)).MustNotHaveHappened();
            A.CallTo(() => fakeConfigurationSetDocumentService.DeleteAsync(A <Guid> .Ignored)).MustHaveHappenedOnceExactly();

            Assert.Equal(expectedResult, result);
        }
        public async Task ProcessContentItemAsyncReturnsBadRequest()
        {
            //Arrange
            const HttpStatusCode expectedResult = HttpStatusCode.BadRequest;
            var service = new WebhooksService(fakeLogger, fakeMapper, fakeCmsApiService, fakeConfigurationSetDocumentService);
            var dummyStaticContentItemApiDataModel = A.Dummy <StaticContentItemApiDataModel>();
            var dummyStaticContentItemModel        = A.Dummy <StaticContentItemModel>();

            A.CallTo(() => fakeCmsApiService.GetItemAsync <StaticContentItemApiDataModel>(A <Uri> .Ignored)).Returns(dummyStaticContentItemApiDataModel);
            A.CallTo(() => fakeMapper.Map <StaticContentItemModel>(A <StaticContentItemApiDataModel> .Ignored)).Returns(dummyStaticContentItemModel);

            //Act
            var result = await service.ProcessContentItemAsync(new Uri("https://somewhere.com", UriKind.Absolute)).ConfigureAwait(false);

            //Assert
            A.CallTo(() => fakeCmsApiService.GetItemAsync <StaticContentItemApiDataModel>(A <Uri> .Ignored)).MustHaveHappenedOnceExactly();
            A.CallTo(() => fakeMapper.Map <StaticContentItemModel>(A <StaticContentItemApiDataModel> .Ignored)).MustHaveHappenedOnceExactly();
            A.CallTo(() => fakeConfigurationSetDocumentService.UpsertAsync(A <StaticContentItemModel> .Ignored)).MustNotHaveHappened();

            Assert.Equal(expectedResult, result);
        }
 public static void MyClassInitialize(TestContext testContext)
 {
     webhooksServiceTestCases = new WebhooksService();
 }
 public WebhooksServiceTests()
 {
     webhooksService = new WebhooksService(A.Fake <ILogger <WebhooksService> >(), fakeWebhooksContentService, fakeWebhooksDeleteService);
 }
Esempio n. 15
0
 public async Task DeleteWebhook_WithInvalidApiKeyThrowsException()
 {
     var webhookService = new WebhooksService(BaseUri, HttpClient);
     await webhookService.DeleteWebhookAsync("NotARealApiKey", 1);
 }
Esempio n. 16
0
 public async Task CreateWebhook_WithInvalidApiKeyThrowsException()
 {
     var webhookService = new WebhooksService(BaseUri, HttpClient);
     await webhookService.CreateWebhookAsync("NotARealApiKey", "source", "targetURL", null);
 }
Esempio n. 17
0
 public async Task GetWebhooks_WithInvalidApiKeyThrowsException()
 {
     var webhookService = new WebhooksService(BaseUri, HttpClient);
     await webhookService.GetWebhooksAsync("NotARealApiKey");
 }
Esempio n. 18
0
        protected WebhooksService BuildWebhooksService()
        {
            var service = new WebhooksService(Logger, FakeMapper, FakeCmsApiService, FakeConfigurationSetDocumentService);

            return(service);
        }
Esempio n. 19
0
        protected WebhooksService BuildWebhooksService()
        {
            var service = new WebhooksService(Logger, FakeContentCacheService, FakeWebhookContentProcessor, Config);

            return(service);
        }