示例#1
0
        public void TestGetLatestDarkRiftVersionWhenDownloadFails()
        {
            // GIVEN the web client cannot get the latest version
            mockIWebClientUtility.Setup(w => w.DownloadString("/DarkRift2/Releases/")).Throws(new WebException("mock-exception"));

            // WHEN I get the latest version
            RemoteRepository classUnderTest = new RemoteRepository(null, mockIContext.Object, mockIWebClientUtility.Object, null);
            string           result         = classUnderTest.GetLatestDarkRiftVersion();

            // THEN the result is null
            Assert.IsNull(result);

            // AND the context was not
            mockIContext.VerifyNoOtherCalls();
        }
示例#2
0
        public void TestGetLatestDarkRiftVersion()
        {
            // GIVEN the web client can get the latest version
            mockIWebClientUtility.Setup(w => w.DownloadString("/DarkRift2/Releases/")).Returns("{\"latest\": \"my-version\"}");

            // WHEN I get the latest version
            RemoteRepository classUnderTest = new RemoteRepository(null, mockIContext.Object, mockIWebClientUtility.Object, null);
            string           result         = classUnderTest.GetLatestDarkRiftVersion();

            // THEN the result is the correct value
            Assert.AreEqual("my-version", result);

            // AND the context was set
            Assert.AreEqual("my-version", mockIContext.Object.Profile.LatestKnownDarkRiftVersion);
            mockIContext.Verify(c => c.Save());
        }