Пример #1
0
        public void GetBarsFacebook_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 GetBarListFacebook(emptyFetcher.Object);
            // Act && Assert
            var ex = Assert.ThrowsAsync <ArgumentNullException>
                         (async() => await getBars.GetBarsAroundAsync(latitude, longitude, radius));
        }
        public void GetBarsFacebook_GetBarsAroundAsync_InvalidData(double latitude, double longitude, double 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 GetBarListFacebook(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);
        }
        public void GetBarsFacebook_GetBarsAroundAsync_ValidData(double latitude, double longitude, double radius)
        {
            // Arrange
            var validFetcher = new Mock <IHttpFetcher>();

            validFetcher.Setup(p => p.GetHttpStreamAsync(It.IsAny <string>())).Returns(Task.Run(() => BarProviderTestData.FacebookValidDataResponse));
            var getBars = new GetBarListFacebook(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.Title);
            }
        }