From 413bfda1c48d6f89a3df16d9b0983fb06610d260 Mon Sep 17 00:00:00 2001 From: dbuechel Date: Thu, 14 Feb 2019 15:01:08 +0100 Subject: [PATCH] SEBWIN-296: Implemented unit tests for client initialization operation. --- .../InitializationOperationTests.cs | 51 +++++++++++++++++++ .../SafeExamBrowser.Client.UnitTests.csproj | 1 + 2 files changed, 52 insertions(+) create mode 100644 SafeExamBrowser.Client.UnitTests/Operations/InitializationOperationTests.cs diff --git a/SafeExamBrowser.Client.UnitTests/Operations/InitializationOperationTests.cs b/SafeExamBrowser.Client.UnitTests/Operations/InitializationOperationTests.cs new file mode 100644 index 00000000..2d827ce4 --- /dev/null +++ b/SafeExamBrowser.Client.UnitTests/Operations/InitializationOperationTests.cs @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET) + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +using System.Net; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Moq; +using SafeExamBrowser.Client.Operations; +using SafeExamBrowser.Contracts.Core.OperationModel; +using SafeExamBrowser.Contracts.Logging; + +namespace SafeExamBrowser.Client.UnitTests.Operations +{ + [TestClass] + public class InitializationOperationTests + { + private Mock logger; + private InitializationOperation sut; + + [TestInitialize] + public void Initialize() + { + logger = new Mock(); + sut = new InitializationOperation(logger.Object); + } + + [TestMethod] + public void MustPerformSuccessfully() + { + var result = sut.Perform(); + + Assert.AreEqual(OperationResult.Success, result); + Assert.IsTrue(ServicePointManager.SecurityProtocol.HasFlag(SecurityProtocolType.Tls)); + Assert.IsTrue(ServicePointManager.SecurityProtocol.HasFlag(SecurityProtocolType.Tls11)); + Assert.IsTrue(ServicePointManager.SecurityProtocol.HasFlag(SecurityProtocolType.Tls12)); + Assert.IsTrue(ServicePointManager.SecurityProtocol.HasFlag(SecurityProtocolType.Ssl3)); + } + + [TestMethod] + public void MustRevertSuccessfully() + { + var result = sut.Revert(); + + Assert.AreEqual(OperationResult.Success, result); + } + } +} diff --git a/SafeExamBrowser.Client.UnitTests/SafeExamBrowser.Client.UnitTests.csproj b/SafeExamBrowser.Client.UnitTests/SafeExamBrowser.Client.UnitTests.csproj index cc12cd71..24cb590b 100644 --- a/SafeExamBrowser.Client.UnitTests/SafeExamBrowser.Client.UnitTests.csproj +++ b/SafeExamBrowser.Client.UnitTests/SafeExamBrowser.Client.UnitTests.csproj @@ -85,6 +85,7 @@ +