Skip to content

Commit

Permalink
Dispose instances created during tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bdukes committed Oct 15, 2024
1 parent 45deded commit 3ff293b
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public void TearDown()
{
Globals.DependencyProvider = null;
MockComponentProvider.ResetContainer();
this._hostSettingsTable?.Dispose();
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,13 @@ public void TearDown()
{
Globals.DependencyProvider = null;
ComponentFactory.Container = null;
PortalController.ClearInstance();
PortalController.ClearInstance();
this._dtMessages?.Dispose();
this._dtMessageAttachment?.Dispose();
this._dtMessageRecipients?.Dispose();
this._dtPortalSettings?.Dispose();
this._dtMessageConversationView?.Dispose();
this._dtMessageThreadsView?.Dispose();
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ public void TearDown()
MessagingController.ClearInstance();
PortalController.ClearInstance();
InternalMessagingController.ClearInstance();
this._dtNotificationTypes?.Dispose();
this._dtNotificationTypeActions?.Dispose();
this._dtNotificationActions?.Dispose();
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ public void TearDown()
ComponentFactory.Container = null;
PortalController.ClearInstance();
UserController.ClearInstance();
this.dtRelationshipTypes?.Dispose();
this.dtRelationships?.Dispose();
this.dtUserRelationships?.Dispose();
this.dtUserRelationshipPreferences?.Dispose();
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public void SetUp()
public void TearDown()
{
Globals.DependencyProvider = null;
this.dtProfiles?.Dispose();
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,50 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information

namespace DotNetNuke.Tests.Integration.Tests.DotNetNukeWeb
{
using System;
using System.Configuration;
using System.Net;
using System.Net.Http;
using System.Web;

using DNN.Integration.Test.Framework;
using NUnit.Framework;

[TestFixture]
public class DotNetNukeWebTests : IntegrationTestBase
{
private const string GetMonikerQuery = "/API/web/mobilehelper/monikers?moduleList=";
private const string GetModuleDetailsQuery = "/API/web/mobilehelper/moduledetails?moduleList=";

private readonly HttpClient _httpClient;

private readonly TimeSpan _timeout = TimeSpan.FromSeconds(30);

public DotNetNukeWebTests()
{
var url = ConfigurationManager.AppSettings["siteUrl"];
var siteUri = new Uri(url);
this._httpClient = new HttpClient { BaseAddress = siteUri, Timeout = this._timeout };
}

[Test]
[TestCase(GetMonikerQuery)]
[TestCase(GetModuleDetailsQuery)]
public void CallingHelperForAnonymousUserShouldReturnSuccess(string query)
{
var result = this._httpClient.GetAsync(query + HttpUtility.UrlEncode("ViewProfile")).Result;
var content = result.Content.ReadAsStringAsync().Result;
LogText(@"content => " + content);
Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.OK));
}
}
}
namespace DotNetNuke.Tests.Integration.Tests.DotNetNukeWeb
{
using System;
using System.Configuration;
using System.Net;
using System.Net.Http;
using System.Web;

using DNN.Integration.Test.Framework;
using NUnit.Framework;

[TestFixture]
public class DotNetNukeWebTests : IntegrationTestBase
{
private const string GetMonikerQuery = "/API/web/mobilehelper/monikers?moduleList=";
private const string GetModuleDetailsQuery = "/API/web/mobilehelper/moduledetails?moduleList=";

private readonly HttpClient _httpClient;

private readonly TimeSpan _timeout = TimeSpan.FromSeconds(30);

public DotNetNukeWebTests()
{
var url = ConfigurationManager.AppSettings["siteUrl"];
var siteUri = new Uri(url);
this._httpClient = new HttpClient { BaseAddress = siteUri, Timeout = this._timeout };
}

[OneTimeTearDown]
public override void TestFixtureTearDown()
{
base.TestFixtureTearDown();
this._httpClient?.Dispose();
}

[Test]
[TestCase(GetMonikerQuery)]
[TestCase(GetModuleDetailsQuery)]
public void CallingHelperForAnonymousUserShouldReturnSuccess(string query)
{
var result = this._httpClient.GetAsync(query + HttpUtility.UrlEncode("ViewProfile")).Result;
var content = result.Content.ReadAsStringAsync().Result;
LogText(@"content => " + content);
Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.OK));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ public override void TestFixtureSetUp()
}
}

[OneTimeTearDown]
public override void TestFixtureTearDown()
{
base.TestFixtureTearDown();
this._httpClient?.Dispose();
}

[Test]
public void InvalidUserLoginShouldFail()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ public void SetUp()
this.SetupSynchronizationContext();
}

[TearDown]
public void TearDown()
{
this._testInstance?.Dispose();
}

[Test]
[SetCulture("tr-TR")]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public void TearDown()
{
Globals.DependencyProvider = null;
this.luceneController.Dispose();
this.searchServiceController?.Dispose();
this.DeleteIndexFolder();
CBO.ClearInstance();
TabController.ClearInstance();
Expand Down

0 comments on commit 3ff293b

Please sign in to comment.