//----------------------------------------------------------------------- // // Copyright (c) Andrew Arnott. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOpenAuth.Test.OpenId.RelyingParty { using System; using System.Collections.Generic; using System.Linq; using System.Text; using DotNetOpenAuth.OpenId.RelyingParty; using Microsoft.VisualStudio.TestTools.UnitTesting; [TestClass] public class RelyingPartySecuritySettingsTests : OpenIdTestBase { private RelyingPartySecuritySettings settings; [TestInitialize] public override void SetUp() { base.SetUp(); this.settings = new RelyingPartySecuritySettings(); } /// /// Verifies that the property /// getter/setter are implemented correctly. /// [TestMethod] public void RequireSsl() { Assert.IsFalse(this.settings.RequireSsl, "Default should be to not require SSL."); this.settings.RequireSsl = true; Assert.IsTrue(this.settings.RequireSsl); this.settings.RequireSsl = false; Assert.IsFalse(this.settings.RequireSsl); } /// /// Verifies that changing the property /// fires the event. /// [TestMethod] public void RequireSslFiresEvent() { bool requireSslChanged = false; this.settings.RequireSslChanged += (sender, e) => { requireSslChanged = true; }; // Setting the property to its current value should not fire event. this.settings.RequireSsl = this.settings.RequireSsl; Assert.IsFalse(requireSslChanged); // Changing the property's value should fire the event. this.settings.RequireSsl = !this.settings.RequireSsl; Assert.IsTrue(requireSslChanged); } } }