示例#1
0
        public void TestDownloadVersionToWhenDownloadFails()
        {
            // GIVEN the web client cannot download the file
            mockIWebClientUtility.Setup(w => w.DownloadFile("/DarkRift2/Releases/a-version/Free/Core/", "a-staging-path")).Throws(new WebException("mock-exception"));

            // WHEN I download a free server
            RemoteRepository classUnderTest = new RemoteRepository(null, null, mockIWebClientUtility.Object, mockIFileUtility.Object);
            bool             result         = classUnderTest.DownloadVersionTo("a-version", ServerTier.Free, ServerPlatform.Core, "a-download-path");

            // THEN the result is not success
            Assert.IsFalse(result);
        }
示例#2
0
        public void TestDownloadVersionToWhenProButNoInvoice()
        {
            // GIVEN the invoice manager does not return an invoice number
            mockIInvoiceManager.Setup(i => i.GetInvoiceNumber()).Returns((string)null);

            // WHEN I download a pro server
            RemoteRepository classUnderTest = new RemoteRepository(mockIInvoiceManager.Object, null, mockIWebClientUtility.Object, mockIFileUtility.Object);
            bool             result         = classUnderTest.DownloadVersionTo("a-version", ServerTier.Pro, ServerPlatform.Core, "a-download-path");

            // THEN the result is not success
            Assert.IsFalse(result);

            // AND the download was not attempted
            mockIWebClientUtility.VerifyNoOtherCalls();
        }
示例#3
0
        public void TestDownloadVersionToWhenFree()
        {
            // WHEN I download a free server
            RemoteRepository classUnderTest = new RemoteRepository(null, null, mockIWebClientUtility.Object, mockIFileUtility.Object);
            bool             result         = classUnderTest.DownloadVersionTo("a-version", ServerTier.Free, ServerPlatform.Core, "a-download-path");

            // THEN the result is success
            Assert.IsTrue(result);

            // AND the download was made
            mockIWebClientUtility.Verify(w => w.DownloadFile("/DarkRift2/Releases/a-version/Free/Core/", "a-staging-path"));

            // AND the download was extracted to the correct location
            mockIFileUtility.Verify(f => f.ExtractZipTo("a-staging-path", "a-download-path"));

            // AND the temporary file was deleted again
            mockIFileUtility.Verify(f => f.Delete("a-staging-path"));
        }
示例#4
0
        public void TestDownloadVersionToWhenPro()
        {
            // GIVEN the invoice manager returns an invoice number
            mockIInvoiceManager.Setup(i => i.GetInvoiceNumber()).Returns("an-invoice-number");

            // WHEN I download a pro server
            RemoteRepository classUnderTest = new RemoteRepository(mockIInvoiceManager.Object, null, mockIWebClientUtility.Object, mockIFileUtility.Object);
            bool             result         = classUnderTest.DownloadVersionTo("a-version", ServerTier.Pro, ServerPlatform.Core, "a-download-path");

            // THEN the result is success
            Assert.IsTrue(result);

            // AND the download was made
            mockIWebClientUtility.Verify(w => w.DownloadFile("/DarkRift2/Releases/a-version/Pro/Core/?invoice=an-invoice-number", "a-staging-path"));

            // AND the download was extracted to the correct location
            mockIFileUtility.Verify(f => f.ExtractZipTo("a-staging-path", "a-download-path"));

            // AND the temporary file was deleted again
            mockIFileUtility.Verify(f => f.Delete("a-staging-path"));
        }