Пример #1
0
        public async Task Returns_A_Recording()
        {
            var clientFactory = ClientBuilder.XenoCantoClientFactory(XenoCantoResponses.OkResponse);
            var sut           = new XenoCantoService(clientFactory);

            var result = await sut.GetSpeciesRecordings("Branta canadensis");

            Assert.IsType <List <RecordingViewModel> >(result);
        }
Пример #2
0
        public async Task Returns_XenoCantoException_On_XenoCantoInternalError()
        {
            var clientFactory = ClientBuilder.XenoCantoClientFactory(XenoCantoResponses.InternalErrorResponse,
                                                                     HttpStatusCode.InternalServerError);
            var sut = new XenoCantoService(clientFactory);

            var result = await Assert.ThrowsAsync <XenoCantoException>(() => sut.GetSpeciesRecordings("Branta canadensis"));

            Assert.Equal(500, (int)result.StatusCode);
        }
Пример #3
0
        public async Task Returns_XenoCantoException_When_Called_With_Bad_Argument()
        {
            var clientFactory = ClientBuilder.XenoCantoClientFactory(XenoCantoResponses.NotFoundResponse,
                                                                     HttpStatusCode.NotFound);
            var sut = new XenoCantoService(clientFactory);

            var result = await Assert.ThrowsAsync <XenoCantoException>(() => sut.GetSpeciesRecordings("dnifihurvbfvije"));

            Assert.Equal(404, (int)result.StatusCode);
        }
Пример #4
0
        public async Task Returns_Expected_Values_From_the_Api()
        {
            var clientFactory = ClientBuilder.XenoCantoClientFactory(XenoCantoResponses.OkResponse);
            var sut           = new XenoCantoService(clientFactory);

            var result = await sut.GetSpeciesRecordings("Branta canadensis");

            Assert.Equal("//a/b/c/d/testFileName.mp3", result[0].Url);
            Assert.Equal(0, result[0].Id);
        }