コード例 #1
0
        public void WebsiteDownloader_ShouldFail_WhenHttpClientThrowsAnException()
        {
            //Arrange
            Mock <IResourceDownloader> mockResourceDownloader = new Mock <IResourceDownloader>();
            Tretton37 tretton37 = new Tretton37(mockResourceDownloader.Object);

            mockResourceDownloader.Setup(x => x.DownloadUsingWebClient(It.IsAny <string>())).Throws(new Exception());

            //Act and Assert
            Assert.Throws <Exception>(() => tretton37.WebsiteDownloader(new ConcurrentBag <string>(), 0));
        }
コード例 #2
0
        public void WebsiteDownloader_ShouldDownladSuccessfully_WhenAllDepedenciesAreSupplied()
        {
            //Arrange
            Mock <IResourceDownloader> mockResourceDownloader = new Mock <IResourceDownloader>();
            Tretton37 tretton37 = new Tretton37(mockResourceDownloader.Object);

            mockResourceDownloader.Setup(x => x.DownloadUsingWebClient(It.IsAny <string>())).Verifiable();

            //Act and Assert
            //No explicit assertions made, passing test will ensure the funtionality is working as expected.
            tretton37.WebsiteDownloader(new ConcurrentBag <string>(), 0);
        }