Beispiel #1
0
        public void GetBarsGoogle_GetBarsAroundAsync_NullData(string latitude, string longitude, string radius)
        {
            var emptyFetcher = new Mock <IHttpFetcher>();

            emptyFetcher.Setup(p => p.GetHttpStream(It.IsAny <string>())).Throws(new Exception("This should not have been thrown"));
            // Arrange
            var getBars = new GetBarListGoogle(emptyFetcher.Object);
            // Act && Assert
            var ex = Assert.ThrowsAsync <ArgumentNullException>
                         (async() => await getBars.GetBarsAroundAsync(latitude, longitude, radius));
        }
Beispiel #2
0
        public void GetBarsGoogle_GetBarsAroundAsync_InvalidData(string latitude, string longitude, string radius, string exceptionMessage)
        {
            var emptyFetcher = new Mock <IHttpFetcher>();

            emptyFetcher.Setup(p => p.GetHttpStream(It.IsAny <string>())).Throws(new Exception("This should not have been thrown"));
            // Arrange
            var getBars = new GetBarListGoogle(emptyFetcher.Object);
            // Act
            var ex = Assert.ThrowsAsync <ArgumentsForProvidersException>
                         (async() => await getBars.GetBarsAroundAsync(latitude, longitude, radius));

            // now we can test the exception itself
            Assert.That(ex.InvalidArguments == exceptionMessage);
        }
Beispiel #3
0
        public void GetBarsFourSquare_GetBarsAroundAsync_ValidData(string latitude, string longitude, string radius)
        {
            // Arrange
            var validFetcher = new Mock <IHttpFetcher>();

            validFetcher.Setup(p => p.GetHttpStreamAsync(It.IsAny <string>())).Returns(Task.Run(() => BarProviderTestData.GoogleValidDataResponse));
            var getBars = new GetBarListGoogle(validFetcher.Object);
            // Act
            var barList = getBars.GetBarsAroundAsync(latitude, longitude, radius).Result;

            // Assert
            Assert.NotNull(barList);
            foreach (var bar in barList)
            {
                Assert.NotNull(bar);
                Assert.NotNull(bar.Ratings);
                Assert.NotNull(bar.Title);
            }
        }