SEBWIN-296: Implemented unit tests for client initialization operation.

This commit is contained in:
dbuechel 2019-02-14 15:01:08 +01:00
parent be3fbf12c6
commit 413bfda1c4
2 changed files with 52 additions and 0 deletions

View file

@ -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<ILogger> logger;
private InitializationOperation sut;
[TestInitialize]
public void Initialize()
{
logger = new Mock<ILogger>();
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);
}
}
}

View file

@ -85,6 +85,7 @@
<Compile Include="Operations\ClipboardOperationTests.cs" />
<Compile Include="Operations\ConfigurationOperationTests.cs" />
<Compile Include="Operations\DisplayMonitorOperationTests.cs" />
<Compile Include="Operations\InitializationOperationTests.cs" />
<Compile Include="Operations\KeyboardInterceptorOperationTests.cs" />
<Compile Include="Operations\MouseInterceptorOperationTests.cs" />
<Compile Include="Operations\ProcessMonitorOperationTests.cs" />