2017-07-05 17:21:52 +02:00
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2017 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;
|
2017-07-06 18:18:39 +02:00
|
|
|
|
using System.Collections.Generic;
|
2017-07-05 17:21:52 +02:00
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
2017-07-06 18:18:39 +02:00
|
|
|
|
using Moq;
|
|
|
|
|
using SafeExamBrowser.Contracts.I18n;
|
2017-07-05 17:21:52 +02:00
|
|
|
|
using SafeExamBrowser.Core.I18n;
|
|
|
|
|
|
2017-07-06 18:18:39 +02:00
|
|
|
|
namespace SafeExamBrowser.Core.UnitTests.I18n
|
2017-07-05 17:21:52 +02:00
|
|
|
|
{
|
|
|
|
|
[TestClass]
|
2017-07-06 10:56:03 +02:00
|
|
|
|
public class TextTests
|
2017-07-05 17:21:52 +02:00
|
|
|
|
{
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void MustNeverReturnNull()
|
|
|
|
|
{
|
2017-07-06 18:18:39 +02:00
|
|
|
|
var resource = new Mock<ITextResource>();
|
|
|
|
|
var sut = new Text(resource.Object);
|
2017-07-05 17:21:52 +02:00
|
|
|
|
|
2017-08-03 15:35:22 +02:00
|
|
|
|
resource.Setup(r => r.LoadText()).Returns<IDictionary<TextKey, string>>(null);
|
2017-07-05 17:21:52 +02:00
|
|
|
|
|
2017-08-03 15:35:22 +02:00
|
|
|
|
var text = sut.Get((TextKey)(-1));
|
2017-07-06 18:18:39 +02:00
|
|
|
|
|
|
|
|
|
Assert.IsNotNull(text);
|
2017-07-06 10:56:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-05 17:21:52 +02:00
|
|
|
|
[TestMethod]
|
|
|
|
|
[ExpectedException(typeof(ArgumentNullException))]
|
|
|
|
|
public void MustNotAllowNullResource()
|
|
|
|
|
{
|
2017-07-06 10:56:03 +02:00
|
|
|
|
new Text(null);
|
2017-07-05 17:21:52 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|