public void TestLlReleaseUrl() { TestHelpers.InMethod(); m_lslApi.llRequestURL(); string returnedUri = m_engine.PostedEvents[m_scriptItem.ItemID][0].Params[2].ToString(); { // Check that the initial number of URLs is correct Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls - 1)); } { // Check releasing a non-url m_lslApi.llReleaseURL("GARBAGE"); Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls - 1)); } { // Check releasing a non-existing url m_lslApi.llReleaseURL("http://example.com"); Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls - 1)); } { // Check URL release m_lslApi.llReleaseURL(returnedUri); Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls)); HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(returnedUri); bool gotExpectedException = false; try { using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse()) {} } catch (WebException) { // using (HttpWebResponse response = (HttpWebResponse)e.Response) // gotExpectedException = response.StatusCode == HttpStatusCode.NotFound; gotExpectedException = true; } Assert.That(gotExpectedException, Is.True); } { // Check releasing the same URL again m_lslApi.llReleaseURL(returnedUri); Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls)); } }