public void IHTest_WrongUrl_ReturnsFalse()
        {
            _downloader.Setup(d => d.Download(It.IsAny <string>(), It.IsAny <string>())).Throws <WebException>();
            var result = _helper.DownloadInstaller("customer", "helper");

            Assert.That(result, Is.False);
        }
        public void DownloadInstaller_DownloadFails_ReturnFalse()
        {
            _fileDownloader.Setup(fd => fd.DownloadFile(It.IsAny <string>(), It.IsAny <string>())).Throws <WebException>();
            var result = _installerHelper.DownloadInstaller("customer", "installer");

            Assert.That(result, Is.False);
        }
Esempio n. 3
0
        public void DownloadInstaller_whenPassedURL_ReturnsTrue()
        {
            //since it is not expecting a value to be returned, we dont need to setup
            var result = _installerHelper.DownloadInstaller("customer", "installer");

            Assert.That(result, Is.EqualTo(true));
        }
        public void DownloadInstaller_FileFoundAndSaved_ReturnTrue()
        {
            _fileDownloader
            .Setup(fd => fd.DownloadFile(It.IsAny <string>(), It.IsAny <string>()));
            var res = _installerHelper.DownloadInstaller("customer", "installer");

            Assert.That(res, Is.True);
        }
        public void DownloadInstaller_WhenDownloadFails_ReturnFalse()
        {
            _fileDownloader.Setup(fd => fd.DownloadFile(It.IsAny <string>(), It.IsAny <string>())).Throws <WebException>();

            var result = _installerHelper.DownloadInstaller("", "");

            Assert.That(result, Is.EqualTo(false));
        }
        public void DownloadInstaller_DownloadFails_ShouldReturnFalse()
        {
            _fileDownloader.Setup(f => f.DownloadFile(It.IsAny <string>(), It.IsAny <string>())).Throws <WebException>();

            var result = _helper.DownloadInstaller("customer", "installer", null);

            Assert.That(result, Is.EqualTo(false));
        }
Esempio n. 7
0
        public void DownloadInstaller_DownloadCompletes_ReturnTrue()
        {
            //Act
            var result = _installHelper.DownloadInstaller("customer", "installer");

            //Assert
            Assert.That(result, Is.True);
        }
Esempio n. 8
0
        public void DownloadInstaller_DownloadFails_ReturnFalse()
        {
            _fileDownloader.Setup(fd => fd.DownloadFile("http://example.com/customer/installer", null)).Throws <WebException>();

            var result = _installerHelper.DownloadInstaller("customer", "installer");

            Assert.That(result, Is.False);
        }
Esempio n. 9
0
        public void DownloadInstaller_DownloadFails_ReturnsFalse()
        {
            _installerWebConnection.Setup(wc => wc.DownloadFile(It.IsAny <string>(), It.IsAny <string>())).Throws <WebException>();

            var result = _installerHelper.DownloadInstaller("customer", "installer");

            Assert.That(result, Is.False);
        }
        public void DownloadInstaller_SuccessfulDownload_ReturnsTrue(string customerName, string installerName, bool expectedOutput)
        {
            _fileDownloader.Setup(fd => fd.DownloadFile(It.IsAny <string>(), null));

            var result = _installerHelper.DownloadInstaller(customerName, installerName);

            Assert.That(result, Is.EqualTo(expectedOutput));
        }
        public void DownloadInstaller_EmptyParameters_ReturnFalse()
        {
            _fakeFileDownloader.Setup(fl => fl.Download(It.IsAny <string>(), It.IsAny <string>())).Throws <WebException>();

            var result = _installer.DownloadInstaller("", "");

            Assert.That(result, Is.False);
        }
Esempio n. 12
0
        public void WhenDownLoadFails_ReturnsFalse()
        {
            _downloadHelper.Setup(dh => dh.DownLoadFile("http://example.com/customer/installer", null)).Throws(new WebException());

            var result = _installHelper.DownloadInstaller("customer", "installer");

            Assert.IsFalse(result);
        }
Esempio n. 13
0
        public void DownloadInstaller_SuccessfulDownload_ReturnsTrue()
        {
            //Act
            var result = installerHelper.DownloadInstaller("customerName", "installerName");

            //Assert
            Assert.That(result, Is.EqualTo(true));
        }
        public void DownloadInstaller_DownloadFails_ReturnsFalse()
        {
            _mockFileDownloader.Setup(fd => fd.DownloadFile(It.IsAny <string>(), It.IsAny <string>())).Throws <WebException>();

            var result = _installerHelper.DownloadInstaller("", null);

            Assert.IsFalse(result);
        }
        public void DownloadInstaller_DownloadFails_ReturnFalse()
        {
            _fileDownloader.Setup(fd => fd.DownloadFile(It.IsAny <string>(), It.IsAny <string>())).Throws <WebException>();

            var result = _installerHelper.DownloadInstaller("cutomerName", "installerName");

            Assert.Equal(false, result);
        }
        public void DownloadInstaller_DownloadFails_ReturnsFalse()
        {
            //this behaviour occours when only the method is called with exact params
            _fileDownloader.Setup(fr => fr.DownloadFile(It.IsAny <string>(), It.IsAny <string>())).Throws <WebException>();

            var result = _installerHelper.DownloadInstaller("customer", "installer");

            Assert.That(result, Is.False);
        }
Esempio n. 17
0
        public void DownloadInstaller_DownloadFails_ReturnsFalse()
        {
            _mockFileDownloader.Setup(mfd =>
                                      mfd.DownloadFile(It.IsAny <string>(), It.IsAny <string>()))
            .Throws(new WebException());
            var result = _installerHelper.DownloadInstaller(customerName: "x", installerName: "y");

            Assert.That(result, Is.False);
        }
Esempio n. 18
0
        //[Ignore("To save time")]
        public void DownloadInstaller_WhenThrowException_ReturnFalse()
        {
            // Arrange
            _client.Setup(c => c.DownloadFile(It.IsAny <string>(), It.IsAny <string>())).Throws(new WebException());
            // Act
            var result = _helper.DownloadInstaller("customer", "installer");

            // Assert
            Assert.That(result, Is.False);
        }
Esempio n. 19
0
        public void DownloadInstaller_DownloadSuccess_ReturnTrue()
        {
            //Arrange

            //Act
            var result = _installerHelper.DownloadInstaller("a", "b");

            //Assert
            Assert.That(result, Is.EqualTo(true));
        }
Esempio n. 20
0
        public void DownloadInstaller_DownloadFails_ReturnFalse()
        {
            //Arrange
            _fileDownloader.Setup(fd => fd.DownloadFile(It.IsAny <string>(), It.IsAny <string>())).Throws <WebException>(); //inicializacia mocku
            //Act
            var result = _installerHelper.DownloadInstaller("customer", "installer");

            //Assert
            Assert.That(result, Is.False);
        }
Esempio n. 21
0
        public void DownloadInstaller_DownloadFails_ReturnFalse()
        {
            _fileDownloader.Setup(fd => fd.DownloadFile(It.IsAny <string>(),
                                                        It.IsAny <string>())).Throws <WebException>();
            // to program it in a more generic way for any string... ('It' is used)
            // dont write different tests for different exception. Write those wrt to the scenario.

            var result = _installerHelper.DownloadInstaller("customer", "installer");

            Assert.That(result, Is.False);
        }
Esempio n. 22
0
        public void DownloadInstaller_OnError_ReturnsFalse()
        {
            //act
            _fileDownloaderMock.Setup(f => f.DownloadFile(It.IsAny <string>(),
                                                          It.IsAny <string>()))
            .Throws <WebException>();
            var result = _installerHelper.DownloadInstaller("customer", "installer");

            //assert
            Assert.That(result, Is.False);
        }
        public void DownloadInstaller_IfDownloadFileExists_ReturnTrue()
        {
            //Arrange
            _filedownloader.Setup(r => r.DownloadFile("", ""));

            //Act
            var result = _installHelper.DownloadInstaller("", "");

            //Assert
            Assert.That(result == true);
        }
        public void DownloadInstaller_DownloadFails_ReturnFalse()
        {
            // The commented code was used before been refactored on line 26 to 28 (for a mock more generic);
            //_fileDownloader.Setup(fd => fd.DownloadFile("http://example.com/customer/installer", null)).Throws<WebException>();
            _fileDownloader.Setup(fd =>
                                  fd.DownloadFile(It.IsAny <string>(), It.IsAny <string>()))
            .Throws <WebException>();

            var result = _installerHelper.DownloadInstaller("customer", "installer");

            Assert.That(result, Is.False);
        }
Esempio n. 25
0
        public void DownloadInstaller_WebClientDownloadsTheFile_ReturnTrue()
        {
            // Arrange


            // Act
            var result = _installerHelper.DownloadInstaller(It.IsAny <string>(), It.IsAny <string>());

            // Assert

            _fileDownloader.Verify(fd => fd.DownloadFile(It.IsAny <string>(), It.IsAny <string>()));

            Assert.That(result, Is.True);
        }
Esempio n. 26
0
        public void DownloadInstaller_DownloadFileSuccess_CallDownload(string customerName, string installerName)
        {
            // Arrange


            // Act
            installerHelper.DownloadInstaller(customerName, installerName);

            // Assert
            fileDownloader.Verify(r => r.DownloadFile(
                                      string.Format("http://example.com/{0}/{1}",
                                                    customerName,
                                                    installerName), destination));
        }
Esempio n. 27
0
        public void DownloadInstaller_DownloadFails_ReturnFalse()
        {
            //It doesn't throw an exception
            //_fileDownloader.Setup(fd => fd.DownloadFile("", "")).Throws<WebException>();

            //_fileDownloader.Setup(fd => fd.DownloadFile("http://example.com/customer/installer", null)).Throws<WebException>();
            //It - class defined in Moq
            _fileDownloader.Setup(fd =>
                                  fd.DownloadFile(It.IsAny <string>(), It.IsAny <string>()))
            .Throws <WebException>();

            var result = _instalerHelper.DownloadInstaller("customer", "installer");

            Assert.That(result, Is.False);
        }
Esempio n. 28
0
        public void DownloadInstaller_DownloadFails_ReturnFalse()
        {
            // la setup in situatii de aruncat exceptii, parametrii trebuie sa fie perfect potriviti cu parametrii cu care se apeleaza metoda
            // daca nu se intampla asta, nu se va executa nimic
            // exemplu care nu va executa nimic
            // _fileDownloader.Setup(downloader => downloader.DownloadFile($"http://example.com/customer/installer", null)).Throws<WebException>();

            _fileDownloader.Setup(downloader =>
                                  downloader.DownloadFile(It.IsAny <string>(), It.IsAny <string>()))
            .Throws <WebException>();

            bool result = _installerHelper.DownloadInstaller("customer", "installer");

            Assert.That(result, Is.EqualTo(false));
        }
Esempio n. 29
0
        public void DownloadInstaller_DownloadFails_ReturnFalse()
        {
            // This will not throw an exception and return true because when we Setup mock objects and want to throw exception, we need to pass the exact same arguments
            // _fileDownloader.Setup(fd => fd.DownloadFile("", "")).Throws<WebException>();
            // Hence we should do:
            // _fileDownloader.Setup(fd => fd.DownloadFile("http://example.com/customer/installer", null)).Throws<WebException>();
            // But as the above line is a bit noisy, and sometimes we may not have access to those arguments, so a more generic way to do will be:
            _fileDownloader.Setup(fd =>
                                  fd.DownloadFile(It.IsAny <string>(), It.IsAny <string>())).
            Throws <WebException>();
            // So any string passed as parameter will throw WebException

            var result = _installerHelper.DownloadInstaller("customer", "installer");

            Assert.That(result, Is.False);
        }
Esempio n. 30
0
        public void DownloadInstaller_FileIsSucessfullyDownloaded_ReturnTrue()
        {
            var fileDownloader  = new Mock <IFileDownloader>();
            var installerHelper = new InstallerHelper();
            var result          = installerHelper.DownloadInstaller("", "", fileDownloader.Object);

            Assert.That(result, Is.EqualTo(true));
        }