Here are the examples of the csharp api Moq.Mock.VerifyNoOtherCalls() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
71 Examples
19
Source : TableColumnProcessingServiceTests.cs
with MIT License
from Capgemini
with MIT License
from Capgemini
[Fact]
public void Log_AutonumberSeedAlreadySet_AutoNumberSeedRequestNotAdded()
{
// Arrage
this.crmServiceAdapterMock
.Setup(x => x.Execute(It.IsAny<GetAutoNumberSeedRequest>()))
.Returns(() =>
{
return new GetAutoNumberSeedResponse { Results = { { "AutoNumberSeedValue", 1000L } } };
});
List<TableConfig> tableConfigs = new List<TableConfig>();
ColumnConfig[] tableColumns = new ColumnConfig[]
{
GetAutonumberColumnConfig("test_autonumberone", 1000),
};
tableConfigs.Add(GetTableConfig("test_table", tableColumns));
// Act
this.tableColumnProcessingService.ProcessTables(tableConfigs);
// replacedert
this.loggerMock.VerifyLog(x => x.LogInformation("Auto-number seed test_autonumberone for test_table is already set to value: 1000"));
this.loggerMock.VerifyLog(x => x.LogInformation("No requests for Auto-number seeds were added."));
this.crmServiceAdapterMock.Verify(svc => svc.Execute(It.IsAny<GetAutoNumberSeedRequest>()));
this.crmServiceAdapterMock.VerifyNoOtherCalls();
}
19
Source : TableColumnProcessingServiceTests.cs
with MIT License
from Capgemini
with MIT License
from Capgemini
[Fact]
public void ExecuteMultiple_NoRequests_IsNotCalled()
{
List<TableConfig> tableConfigs = new List<TableConfig>();
ColumnConfig[] tableColumns = Array.Empty<ColumnConfig>();
tableConfigs.Add(GetTableConfig("test_table", tableColumns));
this.tableColumnProcessingService.ProcessTables(tableConfigs);
this.loggerMock.VerifyLog(x => x.LogInformation("No requests for table columns were added."));
this.crmServiceAdapterMock.VerifyNoOtherCalls();
}
19
Source : RestResponseWrapper.cs
with MIT License
from djmnz
with MIT License
from djmnz
[TestMethod]
public void ShouldWrap_AddRule()
{
// Arrange
var wrapper = CreateWrap();
// Act
wrapper.AddRule(new BlankResponsereplacedertionRule("error"));
// replacedert
_response.Verify(m => m.AddRule(It.IsAny<replacedertionRule>()), Times.Once);
_response.VerifyNoOtherCalls();
}
19
Source : RestResponseWrapper.cs
with MIT License
from djmnz
with MIT License
from djmnz
[TestMethod]
public void ShouldWrap_replacedertFailure()
{
// Arrange
var wrapper = CreateWrap();
// Act
wrapper.replacedertFailure();
// replacedert
_response.Verify(m => m.replacedertFailure(), Times.Once);
_response.VerifyNoOtherCalls();
}
19
Source : RestResponseWrapper.cs
with MIT License
from djmnz
with MIT License
from djmnz
[TestMethod]
public void ShouldWrap_Execute()
{
// Arrange
var wrapper = CreateWrap();
var expectedResult = new ExecutionResult();
_response.Setup(m => m.Execute()).Returns(expectedResult);
// Act
var result = wrapper.Execute();
// replacedert
_response.Verify(m => m.Execute(), Times.Once);
replacedert.AreSame(expectedResult, result);
_response.VerifyNoOtherCalls();
}
19
Source : RestResponseWrapper.cs
with MIT License
from djmnz
with MIT License
from djmnz
[TestMethod]
public void ShouldWrap_OnlyOneRuleOf()
{
// Arrange
var wrapper = CreateWrap();
// Act
wrapper.OnlyOneRuleOf(new BlankResponsereplacedertionRule("error"));
// replacedert
_response.Verify(m => m.OnlyOneRuleOf(It.IsAny<replacedertionRule>()), Times.Once);
_response.VerifyNoOtherCalls();
}
19
Source : RestResponseWrapper.cs
with MIT License
from djmnz
with MIT License
from djmnz
[TestMethod]
public void ShouldWrap_replacedert()
{
// Arrange
var wrapper = CreateWrap();
// Act
wrapper.replacedert();
// replacedert
_response.Verify(m => m.replacedert(), Times.Once);
_response.VerifyNoOtherCalls();
}
19
Source : ClientHostDisconnectionOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void MustWaitForDisconnectionIfConnectionIsActive()
{
var after = default(DateTime);
var before = default(DateTime);
var timeout_ms = 200;
sut = new ClientHostDisconnectionOperation(context, logger.Object, timeout_ms);
clientHost.SetupGet(h => h.IsConnected).Returns(true).Callback(() => Task.Delay(10).ContinueWith((_) =>
{
clientHost.Raise(h => h.RuntimeDisconnected += null);
}));
before = DateTime.Now;
sut.Revert();
after = DateTime.Now;
clientHost.VerifyGet(h => h.IsConnected);
clientHost.VerifyAdd(h => h.RuntimeDisconnected += It.IsAny<CommunicationEventHandler>());
clientHost.VerifyRemove(h => h.RuntimeDisconnected -= It.IsAny<CommunicationEventHandler>());
clientHost.VerifyNoOtherCalls();
replacedert.IsTrue(after - before < new TimeSpan(0, 0, 0, 0, timeout_ms));
}
19
Source : ClientHostDisconnectionOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void MustRespectTimeoutIfWaitingForDisconnection()
{
var after = default(DateTime);
var before = default(DateTime);
var timeout_ms = 200;
sut = new ClientHostDisconnectionOperation(context, logger.Object, timeout_ms);
clientHost.SetupGet(h => h.IsConnected).Returns(true);
before = DateTime.Now;
sut.Revert();
after = DateTime.Now;
clientHost.VerifyGet(h => h.IsConnected);
clientHost.VerifyAdd(h => h.RuntimeDisconnected += It.IsAny<CommunicationEventHandler>());
clientHost.VerifyRemove(h => h.RuntimeDisconnected -= It.IsAny<CommunicationEventHandler>());
clientHost.VerifyNoOtherCalls();
replacedert.IsTrue(after - before >= new TimeSpan(0, 0, 0, 0, timeout_ms));
}
19
Source : ClientHostDisconnectionOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void MustDoNothingIfNoConnectionIsActive()
{
clientHost.SetupGet(h => h.IsConnected).Returns(false);
sut.Revert();
clientHost.VerifyGet(h => h.IsConnected);
clientHost.VerifyNoOtherCalls();
}
19
Source : ClientHostDisconnectionOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void MustDoNothingOnPerform()
{
var result = sut.Perform();
clientHost.VerifyNoOtherCalls();
replacedert.AreEqual(OperationResult.Success, result);
}
19
Source : ConfigurationOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void MustDoNothingOnRevert()
{
var result = sut.Revert();
logger.VerifyNoOtherCalls();
runtime.VerifyNoOtherCalls();
replacedert.AreEqual(OperationResult.Success, result);
}
19
Source : DownloadHandlerTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void MustCorrectlyHandleDeniedConfigurationFileDownload()
{
var args = default(DownloadEventArgs);
var callback = new Mock<IBeforeDownloadCallback>();
var failed = false;
var fileName = default(string);
var item = new DownloadItem
{
SuggestedFileName = "File.seb",
Url = "https://somehost.org/some-path"
};
var sync = new AutoResetEvent(false);
var threadId = default(int);
settings.AllowDownloads = false;
settings.AllowConfigurationDownloads = true;
sut.ConfigurationDownloadRequested += (f, a) =>
{
args = a;
args.AllowDownload = false;
fileName = f;
threadId = Thread.CurrentThread.ManagedThreadId;
sync.Set();
};
sut.DownloadUpdated += (state) => failed = true;
sut.OnBeforeDownload(default(IWebBrowser), default(IBrowser), item, callback.Object);
sync.WaitOne();
callback.VerifyNoOtherCalls();
replacedert.IsFalse(failed);
replacedert.IsFalse(args.AllowDownload);
replacedert.AreEqual(item.SuggestedFileName, fileName);
replacedert.AreNotEqual(Thread.CurrentThread.ManagedThreadId, threadId);
}
19
Source : DownloadHandlerTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void MustDoNothingIfDownloadsNotAllowed()
{
var callback = new Mock<IBeforeDownloadCallback>();
var fail = false;
var item = new DownloadItem
{
SuggestedFileName = "File.txt",
Url = "https://somehost.org/somefile.abc"
};
settings.AllowDownloads = false;
settings.AllowConfigurationDownloads = false;
sut.ConfigurationDownloadRequested += (file, args) => fail = true;
sut.DownloadUpdated += (state) => fail = true;
sut.OnBeforeDownload(default(IWebBrowser), default(IBrowser), item, callback.Object);
callback.VerifyNoOtherCalls();
replacedert.IsFalse(fail);
}
19
Source : ApplicationOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void Perform_MustAbortIfUserDeniesAutoTermination()
{
var initialization = new InitializationResult();
var args = default(ActionRequiredEventArgs);
initialization.RunningApplications.Add(new RunningApplication(default(string)));
monitor.Setup(m => m.Initialize(It.IsAny<ApplicationSettings>())).Returns(initialization);
sut.ActionRequired += (a) =>
{
args = a;
if (a is ApplicationTerminationEventArgs t)
{
t.TerminateProcesses = false;
}
};
var result = sut.Perform();
monitor.Verify(m => m.Initialize(It.Is<ApplicationSettings>(s => s == context.Settings.Applications)), Times.Once);
monitor.VerifyNoOtherCalls();
replacedert.AreEqual(OperationResult.Aborted, result);
replacedert.IsInstanceOfType(args, typeof(ApplicationTerminationEventArgs));
}
19
Source : ApplicationOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void Perform_MustFailIfAutoTerminationFails()
{
var initialization = new InitializationResult();
var args = default(ActionRequiredEventArgs);
initialization.FailedAutoTerminations.Add(new RunningApplication(default(string)));
monitor.Setup(m => m.Initialize(It.IsAny<ApplicationSettings>())).Returns(initialization);
sut.ActionRequired += (a) => args = a;
var result = sut.Perform();
monitor.Verify(m => m.Initialize(It.Is<ApplicationSettings>(s => s == context.Settings.Applications)), Times.Once);
monitor.VerifyNoOtherCalls();
replacedert.AreEqual(OperationResult.Failed, result);
replacedert.IsInstanceOfType(args, typeof(ApplicationTerminationFailedEventArgs));
}
19
Source : ProctoringOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void Perform_MustInitializeProctoringCorrectly()
{
settings.Proctoring.Enabled = true;
settings.Proctoring.ShowTaskbarNotification = true;
replacedert.AreEqual(OperationResult.Success, sut.Perform());
actionCenter.Verify(a => a.AddNotificationControl(It.IsAny<INotificationControl>()), Times.Once);
controller.Verify(c => c.Initialize(It.Is<ProctoringSettings>(s => s == settings.Proctoring)));
notification.VerifyNoOtherCalls();
taskbar.Verify(t => t.AddNotificationControl(It.IsAny<INotificationControl>()), Times.Once);
uiFactory.Verify(u => u.CreateNotificationControl(It.Is<INotification>(n => n == notification.Object), Location.ActionCenter), Times.Once);
uiFactory.Verify(u => u.CreateNotificationControl(It.Is<INotification>(n => n == notification.Object), Location.Taskbar), Times.Once);
}
19
Source : ProctoringOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void Perform_MustDoNothingIfNotEnabled()
{
settings.Proctoring.Enabled = false;
replacedert.AreEqual(OperationResult.Success, sut.Perform());
actionCenter.VerifyNoOtherCalls();
controller.VerifyNoOtherCalls();
notification.VerifyNoOtherCalls();
taskbar.VerifyNoOtherCalls();
uiFactory.VerifyNoOtherCalls();
}
19
Source : ProctoringOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void Revert_MustFinalizeProctoringCorrectly()
{
settings.Proctoring.Enabled = true;
replacedert.AreEqual(OperationResult.Success, sut.Revert());
actionCenter.VerifyNoOtherCalls();
controller.Verify(c => c.Terminate(), Times.Once);
notification.Verify(n => n.Terminate(), Times.Once);
taskbar.VerifyNoOtherCalls();
uiFactory.VerifyNoOtherCalls();
}
19
Source : ProctoringOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void Revert_MustDoNothingIfNotEnabled()
{
settings.Proctoring.Enabled = false;
replacedert.AreEqual(OperationResult.Success, sut.Revert());
actionCenter.VerifyNoOtherCalls();
controller.VerifyNoOtherCalls();
notification.VerifyNoOtherCalls();
taskbar.VerifyNoOtherCalls();
uiFactory.VerifyNoOtherCalls();
}
19
Source : RuntimeConnectionOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void MustConnectOnPerform()
{
runtime.Setup(r => r.Connect(It.Is<Guid>(t => t == token), true)).Returns(true);
var result = sut.Perform();
runtime.Verify(r => r.Connect(It.Is<Guid>(t => t == token), true), Times.Once);
runtime.VerifyNoOtherCalls();
replacedert.AreEqual(OperationResult.Success, result);
}
19
Source : RuntimeConnectionOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void MustCorrectlyFailOnPerform()
{
runtime.Setup(r => r.Connect(It.Is<Guid>(t => t == token), true)).Returns(false);
var result = sut.Perform();
runtime.Verify(r => r.Connect(It.Is<Guid>(t => t == token), true), Times.Once);
runtime.VerifyNoOtherCalls();
replacedert.AreEqual(OperationResult.Failed, result);
}
19
Source : RuntimeConnectionOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void MustDisconnectOnRevert()
{
runtime.Setup(r => r.Connect(It.IsAny<Guid>(), It.IsAny<bool>())).Returns(true);
runtime.Setup(r => r.Disconnect()).Returns(true);
runtime.SetupGet(r => r.IsConnected).Returns(true);
sut.Perform();
var result = sut.Revert();
runtime.Verify(r => r.Connect(It.IsAny<Guid>(), It.IsAny<bool>()), Times.Once);
runtime.Verify(r => r.Disconnect(), Times.Once);
runtime.VerifyGet(r => r.IsConnected, Times.Once);
runtime.VerifyNoOtherCalls();
replacedert.AreEqual(OperationResult.Success, result);
}
19
Source : RuntimeConnectionOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void MustCorrectlyFailOnRevert()
{
runtime.Setup(r => r.Connect(It.IsAny<Guid>(), It.IsAny<bool>())).Returns(true);
runtime.Setup(r => r.Disconnect()).Returns(false);
runtime.SetupGet(r => r.IsConnected).Returns(true);
sut.Perform();
var result = sut.Revert();
runtime.Verify(r => r.Connect(It.IsAny<Guid>(), It.IsAny<bool>()), Times.Once);
runtime.Verify(r => r.Disconnect(), Times.Once);
runtime.VerifyGet(r => r.IsConnected, Times.Once);
runtime.VerifyNoOtherCalls();
replacedert.AreEqual(OperationResult.Failed, result);
}
19
Source : RuntimeConnectionOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void MustDoNothingOnRevertIfNotConnected()
{
var result = sut.Revert();
runtime.VerifyGet(r => r.IsConnected, Times.Once);
runtime.VerifyNoOtherCalls();
replacedert.AreEqual(OperationResult.Success, result);
}
19
Source : ServerOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void Perform_MustDoNothingIfNotActive()
{
settings.SessionMode = SessionMode.Normal;
replacedert.AreEqual(OperationResult.Success, sut.Perform());
server.VerifyNoOtherCalls();
}
19
Source : ServerOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void Revert_MustDoNothingIfNotActive()
{
settings.SessionMode = SessionMode.Normal;
replacedert.AreEqual(OperationResult.Success, sut.Revert());
server.VerifyNoOtherCalls();
}
19
Source : BinaryParserTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void MustCorrectlyParsePublicKeyBlock()
{
var data = new byte[123];
var certificate = default(X509Certificate2);
var decrypted = default(Stream);
var pswd = new MemoryStream(Encoding.UTF8.GetBytes(BinaryBlock.Preplacedword).Concat(data).ToArray()) as Stream;
var pkhs = new MemoryStream(Encoding.UTF8.GetBytes(BinaryBlock.PublicKey).Concat(data).ToArray());
preplacedwordEncryption.Setup(p => p.Decrypt(It.IsAny<Stream>(), It.IsAny<string>(), out decrypted)).Returns(LoadStatus.Success);
publicKeyEncryption.Setup(p => p.Decrypt(It.IsAny<Stream>(), out pswd, out certificate)).Returns(LoadStatus.Success);
var result = sut.TryParse(pkhs, new PreplacedwordParameters { Preplacedword = "blubb" });
publicKeyEncryption.Verify(p => p.Decrypt(It.IsAny<Stream>(), out decrypted, out certificate), Times.Once);
preplacedwordEncryption.Verify(p => p.Decrypt(It.IsAny<Stream>(), It.Is<string>(s => s == "blubb"), out decrypted), Times.Once);
symmetricEncryption.VerifyNoOtherCalls();
replacedert.AreEqual(LoadStatus.Success, result.Status);
}
19
Source : BinarySerializerTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void MustCorrectlySerializePublicKeyBlock()
{
var encrypted = new MemoryStream() as Stream;
var data = new Dictionary<string, object>();
var encryption = new PublicKeyParameters
{
InnerEncryption = new PreplacedwordParameters { Preplacedword = "test" },
SymmetricEncryption = false
};
preplacedwordEncryption.Setup(p => p.Encrypt(It.IsAny<Stream>(), It.IsAny<string>(), out encrypted)).Returns(SaveStatus.Success);
publicKeyEncryption.Setup(p => p.Encrypt(It.IsAny<Stream>(), It.IsAny<X509Certificate2>(), out encrypted)).Returns(SaveStatus.Success);
var result = sut.TrySerialize(data, encryption);
compressor.Verify(c => c.Compress(It.IsAny<Stream>()), Times.Exactly(2));
preplacedwordEncryption.Verify(p => p.Encrypt(It.IsAny<Stream>(), It.Is<string>(s => s == encryption.InnerEncryption.Preplacedword), out encrypted), Times.Once);
publicKeyEncryption.Verify(p => p.Encrypt(It.IsAny<Stream>(), It.IsAny<X509Certificate2>(), out encrypted), Times.Once);
xmlSerializer.Verify(x => x.TrySerialize(It.Is<IDictionary<string, object>>(d => d == data), It.Is<EncryptionParameters>(e => e == null)), Times.Once);
symmetricEncryption.VerifyNoOtherCalls();
replacedert.AreEqual(SaveStatus.Success, result.Status);
}
19
Source : BinarySerializerTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void MustCorrectlySerializePublicKeySymmetricBlock()
{
var encrypted = new MemoryStream() as Stream;
var data = new Dictionary<string, object>();
var encryption = new PublicKeyParameters
{
SymmetricEncryption = true
};
symmetricEncryption.Setup(p => p.Encrypt(It.IsAny<Stream>(), It.IsAny<X509Certificate2>(), out encrypted)).Returns(SaveStatus.Success);
var result = sut.TrySerialize(data, encryption);
compressor.Verify(c => c.Compress(It.IsAny<Stream>()), Times.Exactly(2));
symmetricEncryption.Verify(p => p.Encrypt(It.IsAny<Stream>(), It.IsAny<X509Certificate2>(), out encrypted), Times.Once);
xmlSerializer.Verify(x => x.TrySerialize(It.Is<IDictionary<string, object>>(d => d == data), It.Is<EncryptionParameters>(e => e == null)), Times.Once);
preplacedwordEncryption.VerifyNoOtherCalls();
publicKeyEncryption.VerifyNoOtherCalls();
replacedert.AreEqual(SaveStatus.Success, result.Status);
}
19
Source : I18nOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void MustDoNothingOnRevert()
{
sut.Revert();
text.VerifyNoOtherCalls();
}
19
Source : ShellOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void Perform_MustNotInitializeActionCenterIfNotEnabled()
{
var actionCenterActivator = new Mock<IActionCenterActivator>();
context.Activators.Add(actionCenterActivator.Object);
context.Settings.ActionCenter.EnableActionCenter = false;
sut.Perform();
actionCenter.VerifyNoOtherCalls();
actionCenterActivator.VerifyNoOtherCalls();
}
19
Source : ShellOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void Perform_MustNotInitializeTaskviewActivatorIfNotEnabled()
{
var taskviewActivator = new Mock<ITaskviewActivator>();
context.Activators.Add(taskviewActivator.Object);
context.Settings.Keyboard.AllowAltTab = false;
sut.Perform();
taskview.Verify(t => t.Register(It.IsAny<ITaskviewActivator>()), Times.Never);
taskviewActivator.VerifyNoOtherCalls();
}
19
Source : ShellOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void Perform_MustNotInitializeTaskbarIfNotEnabled()
{
context.Settings.Taskbar.EnableTaskbar = false;
sut.Perform();
taskbar.VerifyNoOtherCalls();
}
19
Source : SystemMonitorOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void Perform_MustStartMonitor()
{
sut.Perform();
systemMonitor.Verify(s => s.Start(), Times.Once);
systemMonitor.VerifyNoOtherCalls();
}
19
Source : SystemMonitorOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void Revert_MustStopMonitor()
{
sut.Revert();
systemMonitor.Verify(s => s.Stop(), Times.Once);
systemMonitor.VerifyNoOtherCalls();
}
19
Source : KioskModeOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void Repeat_MustCorrectlySwitchFromCreateNewDesktopToNone()
{
var newDesktop = new Mock<IDesktop>();
var originalDesktop = new Mock<IDesktop>();
var order = 0;
var activate = 0;
var close = 0;
var startupDesktop = 0;
desktopFactory.Setup(f => f.GetCurrent()).Returns(originalDesktop.Object);
desktopFactory.Setup(f => f.CreateNew(It.IsAny<string>())).Returns(newDesktop.Object);
nextSettings.Security.KioskMode = KioskMode.CreateNewDesktop;
sut.Perform();
desktopFactory.Reset();
explorerShell.Reset();
newDesktop.Reset();
newDesktop.Setup(d => d.Close()).Callback(() => close = ++order);
originalDesktop.Reset();
originalDesktop.Setup(d => d.Activate()).Callback(() => activate = ++order);
processFactory.Reset();
processFactory.SetupSet(f => f.StartupDesktop = It.Is<IDesktop>(d => d == originalDesktop.Object)).Callback(() => startupDesktop = ++order);
nextSettings.Security.KioskMode = KioskMode.None;
var result = sut.Repeat();
desktopFactory.VerifyNoOtherCalls();
explorerShell.VerifyNoOtherCalls();
newDesktop.Verify(d => d.Close(), Times.Once);
originalDesktop.Verify(d => d.Activate(), Times.Once);
processFactory.VerifySet(f => f.StartupDesktop = It.Is<IDesktop>(d => d == originalDesktop.Object), Times.Once);
replacedert.AreEqual(OperationResult.Success, result);
replacedert.AreEqual(1, activate);
replacedert.AreEqual(2, startupDesktop);
replacedert.AreEqual(3, close);
}
19
Source : KioskModeOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void Repeat_MustCorrectlySwitchFromNoneToDisableExplorerShell()
{
var order = 0;
var hide = 0;
var terminate = 0;
nextSettings.Security.KioskMode = KioskMode.None;
sut.Perform();
desktopFactory.Reset();
explorerShell.Reset();
explorerShell.Setup(s => s.HideAllWindows()).Callback(() => hide = ++order);
explorerShell.Setup(s => s.Terminate()).Callback(() => terminate = ++order);
processFactory.Reset();
nextSettings.Security.KioskMode = KioskMode.DisableExplorerShell;
var result = sut.Repeat();
desktopFactory.VerifyNoOtherCalls();
explorerShell.Verify(s => s.HideAllWindows(), Times.Once);
explorerShell.Verify(s => s.Terminate(), Times.Once);
processFactory.VerifySet(f => f.StartupDesktop = It.IsAny<IDesktop>(), Times.Never);
replacedert.AreEqual(OperationResult.Success, result);
replacedert.AreEqual(1, hide);
replacedert.AreEqual(2, terminate);
}
19
Source : KioskModeOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void Repeat_MustNotReinitializeCreateNewDesktopIfAlreadyActive()
{
var newDesktop = new Mock<IDesktop>();
var originalDesktop = new Mock<IDesktop>();
var success = true;
currentSettings.Security.KioskMode = KioskMode.CreateNewDesktop;
nextSettings.Security.KioskMode = KioskMode.CreateNewDesktop;
desktopFactory.Setup(f => f.GetCurrent()).Returns(originalDesktop.Object);
desktopFactory.Setup(f => f.CreateNew(It.IsAny<string>())).Returns(newDesktop.Object);
success &= sut.Perform() == OperationResult.Success;
success &= sut.Repeat() == OperationResult.Success;
success &= sut.Repeat() == OperationResult.Success;
success &= sut.Repeat() == OperationResult.Success;
success &= sut.Repeat() == OperationResult.Success;
success &= sut.Repeat() == OperationResult.Success;
replacedert.IsTrue(success);
desktopFactory.Verify(f => f.GetCurrent(), Times.Once);
desktopFactory.Verify(f => f.CreateNew(It.IsAny<string>()), Times.Once);
desktopMonitor.Verify(m => m.Start(It.IsAny<IDesktop>()), Times.Once);
desktopMonitor.Verify(m => m.Stop(), Times.Never);
explorerShell.VerifyNoOtherCalls();
newDesktop.Verify(d => d.Activate(), Times.Once);
newDesktop.Verify(d => d.Close(), Times.Never);
processFactory.VerifySet(f => f.StartupDesktop = newDesktop.Object, Times.Once);
}
19
Source : ServerOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void Perform_MustDoNothingIfNormalSession()
{
var initialSettings = context.Next.Settings;
context.Next.Settings.SessionMode = SessionMode.Normal;
sut.ActionRequired += (_) => replacedert.Fail();
var result = sut.Perform();
configuration.VerifyNoOtherCalls();
fileSystem.VerifyNoOtherCalls();
server.VerifyNoOtherCalls();
replacedert.AreSame(initialSettings, context.Next.Settings);
replacedert.AreEqual(SessionMode.Normal, context.Next.Settings.SessionMode);
replacedert.AreEqual(OperationResult.Success, result);
}
19
Source : BinarySerializerTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void MustCorrectlySerializePlainDataBlock()
{
var data = new Dictionary<string, object>();
var result = sut.TrySerialize(data);
compressor.Verify(c => c.Compress(It.IsAny<Stream>()), Times.Exactly(2));
xmlSerializer.Verify(x => x.TrySerialize(It.Is<IDictionary<string, object>>(d => d == data), It.Is<EncryptionParameters>(e => e == null)), Times.Once);
preplacedwordEncryption.VerifyNoOtherCalls();
publicKeyEncryption.VerifyNoOtherCalls();
symmetricEncryption.VerifyNoOtherCalls();
replacedert.AreEqual(SaveStatus.Success, result.Status);
}
19
Source : BinaryParserTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void MustCorrectlyParsePreplacedwordBlock()
{
var data = new byte[123];
var decrypted = default(Stream);
var pswd = new MemoryStream(Encoding.UTF8.GetBytes(BinaryBlock.Preplacedword).Concat(data).ToArray()) as Stream;
preplacedwordEncryption.Setup(p => p.Decrypt(It.IsAny<Stream>(), It.Is<string>(s => s == "wrong"), out decrypted)).Returns(LoadStatus.PreplacedwordNeeded);
preplacedwordEncryption.Setup(p => p.Decrypt(It.IsAny<Stream>(), It.Is<string>(s => s == "correct"), out decrypted)).Returns(LoadStatus.Success);
var result = sut.TryParse(pswd);
replacedert.AreEqual(LoadStatus.PreplacedwordNeeded, result.Status);
result = sut.TryParse(pswd, new PreplacedwordParameters { Preplacedword = "wrong" });
replacedert.AreEqual(LoadStatus.PreplacedwordNeeded, result.Status);
result = sut.TryParse(pswd, new PreplacedwordParameters { Preplacedword = "correct" });
preplacedwordEncryption.Verify(p => p.Decrypt(It.IsAny<Stream>(), It.IsAny<string>(), out decrypted), Times.AtLeastOnce);
xmlParser.Verify(p => p.TryParse(It.Is<Stream>(s => s == decrypted), It.IsAny<PreplacedwordParameters>()), Times.Once);
publicKeyEncryption.VerifyNoOtherCalls();
symmetricEncryption.VerifyNoOtherCalls();
}
19
Source : BinaryParserTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void MustCorrectlyParsePlainDataBlock()
{
var data = new byte[123];
var plnd = new MemoryStream(Encoding.UTF8.GetBytes(BinaryBlock.PlainData).Concat(data).ToArray());
compressor.Setup(c => c.Decompress(It.IsAny<Stream>())).Returns(plnd);
compressor.Setup(c => c.Peek(It.IsAny<Stream>(), It.IsAny<int>())).Returns(Encoding.UTF8.GetBytes(BinaryBlock.PlainData));
compressor.Setup(c => c.IsCompressed(It.IsAny<Stream>())).Returns(true);
var result = sut.TryParse(plnd);
compressor.Verify(c => c.IsCompressed(It.IsAny<Stream>()), Times.AtLeastOnce);
compressor.Verify(c => c.Decompress(It.IsAny<Stream>()), Times.AtLeastOnce);
xmlParser.Verify(x => x.TryParse(It.IsAny<Stream>(), It.IsAny<PreplacedwordParameters>()), Times.Once);
preplacedwordEncryption.VerifyNoOtherCalls();
publicKeyEncryption.VerifyNoOtherCalls();
symmetricEncryption.VerifyNoOtherCalls();
replacedert.AreEqual(LoadStatus.Success, result.Status);
}
19
Source : BinarySerializerTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void MustCorrectlySerializePreplacedwordBlock()
{
var encrypted = new MemoryStream() as Stream;
var data = new Dictionary<string, object>();
var encryption = new PreplacedwordParameters { Preplacedword = "blubb" };
preplacedwordEncryption.Setup(p => p.Encrypt(It.IsAny<Stream>(), It.IsAny<string>(), out encrypted)).Returns(SaveStatus.Success);
var result = sut.TrySerialize(data, encryption);
compressor.Verify(c => c.Compress(It.IsAny<Stream>()), Times.Exactly(2));
preplacedwordEncryption.Verify(p => p.Encrypt(It.IsAny<Stream>(), It.Is<string>(s => s == encryption.Preplacedword), out encrypted), Times.Once);
xmlSerializer.Verify(x => x.TrySerialize(It.Is<IDictionary<string, object>>(d => d == data), It.Is<EncryptionParameters>(e => e == null)), Times.Once);
publicKeyEncryption.VerifyNoOtherCalls();
symmetricEncryption.VerifyNoOtherCalls();
replacedert.AreEqual(SaveStatus.Success, result.Status);
}
19
Source : ClientTerminationOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void MustDoNothingOnRepeatIfNoClientRunning()
{
process.SetupGet(p => p.HasTerminated).Returns(true);
sessionContext.ClientProcess = process.Object;
var result = sut.Repeat();
process.VerifyGet(p => p.HasTerminated, Times.Once);
process.VerifyNoOtherCalls();
processFactory.VerifyNoOtherCalls();
proxy.VerifyNoOtherCalls();
proxyFactory.VerifyNoOtherCalls();
runtimeHost.VerifyNoOtherCalls();
replacedert.AreEqual(OperationResult.Success, result);
}
19
Source : ClientTerminationOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void MustDoNothingOnPerform()
{
var result = sut.Perform();
process.VerifyNoOtherCalls();
processFactory.VerifyNoOtherCalls();
proxy.VerifyNoOtherCalls();
proxyFactory.VerifyNoOtherCalls();
runtimeHost.VerifyNoOtherCalls();
replacedert.AreEqual(OperationResult.Success, result);
}
19
Source : ClientTerminationOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void MustDoNothingOnRevert()
{
var result = sut.Revert();
process.VerifyNoOtherCalls();
processFactory.VerifyNoOtherCalls();
proxy.VerifyNoOtherCalls();
proxyFactory.VerifyNoOtherCalls();
runtimeHost.VerifyNoOtherCalls();
replacedert.AreEqual(OperationResult.Success, result);
}
19
Source : ConfigurationOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void Revert_MustDoNothing()
{
var sut = new ConfigurationOperation(null, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
var result = sut.Revert();
fileSystem.VerifyNoOtherCalls();
hashAlgorithm.VerifyNoOtherCalls();
repository.VerifyNoOtherCalls();
replacedert.AreEqual(OperationResult.Success, result);
}
19
Source : KioskModeOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void Repeat_MustCorrectlySwitchFromCreateNewDesktopToDisableExplorerShell()
{
var newDesktop = new Mock<IDesktop>();
var originalDesktop = new Mock<IDesktop>();
var order = 0;
var activate = 0;
var close = 0;
var hide = 0;
var startupDesktop = 0;
var terminate = 0;
desktopFactory.Setup(f => f.GetCurrent()).Returns(originalDesktop.Object);
desktopFactory.Setup(f => f.CreateNew(It.IsAny<string>())).Returns(newDesktop.Object);
nextSettings.Security.KioskMode = KioskMode.CreateNewDesktop;
sut.Perform();
desktopFactory.Reset();
explorerShell.Reset();
explorerShell.Setup(s => s.HideAllWindows()).Callback(() => hide = ++order);
explorerShell.Setup(s => s.Terminate()).Callback(() => terminate = ++order);
newDesktop.Reset();
newDesktop.Setup(d => d.Close()).Callback(() => close = ++order);
originalDesktop.Reset();
originalDesktop.Setup(d => d.Activate()).Callback(() => activate = ++order);
processFactory.Reset();
processFactory.SetupSet(f => f.StartupDesktop = It.Is<IDesktop>(d => d == originalDesktop.Object)).Callback(() => startupDesktop = ++order);
nextSettings.Security.KioskMode = KioskMode.DisableExplorerShell;
var result = sut.Repeat();
desktopFactory.VerifyNoOtherCalls();
explorerShell.Verify(s => s.HideAllWindows(), Times.Once);
explorerShell.Verify(s => s.Terminate(), Times.Once);
explorerShell.VerifyNoOtherCalls();
newDesktop.Verify(d => d.Close(), Times.Once);
originalDesktop.Verify(d => d.Activate(), Times.Once);
processFactory.VerifySet(f => f.StartupDesktop = It.Is<IDesktop>(d => d == originalDesktop.Object), Times.Once);
replacedert.AreEqual(OperationResult.Success, result);
replacedert.AreEqual(1, activate);
replacedert.AreEqual(2, startupDesktop);
replacedert.AreEqual(3, close);
replacedert.AreEqual(4, hide);
replacedert.AreEqual(5, terminate);
}
19
Source : KioskModeOperationTests.cs
with Mozilla Public License 2.0
from SafeExamBrowser
with Mozilla Public License 2.0
from SafeExamBrowser
[TestMethod]
public void Repeat_MustCorrectlySwitchFromNoneToCreateNewDesktop()
{
var newDesktop = new Mock<IDesktop>();
var originalDesktop = new Mock<IDesktop>();
var order = 0;
var activate = 0;
var current = 0;
var startup = 0;
nextSettings.Security.KioskMode = KioskMode.None;
sut.Perform();
desktopFactory.Reset();
desktopFactory.Setup(f => f.GetCurrent()).Returns(originalDesktop.Object).Callback(() => current = ++order);
desktopFactory.Setup(f => f.CreateNew(It.IsAny<string>())).Returns(newDesktop.Object);
explorerShell.Reset();
newDesktop.Reset();
newDesktop.Setup(d => d.Activate()).Callback(() => activate = ++order);
originalDesktop.Reset();
processFactory.Reset();
processFactory.SetupSet(f => f.StartupDesktop = It.Is<IDesktop>(d => d == newDesktop.Object)).Callback(() => startup = ++order);
nextSettings.Security.KioskMode = KioskMode.CreateNewDesktop;
var result = sut.Repeat();
desktopFactory.Verify(f => f.GetCurrent(), Times.Once);
desktopFactory.Verify(f => f.CreateNew(It.IsAny<string>()), Times.Once);
explorerShell.VerifyNoOtherCalls();
newDesktop.Verify(d => d.Activate(), Times.Once);
originalDesktop.VerifyNoOtherCalls();
processFactory.VerifySet(f => f.StartupDesktop = It.Is<IDesktop>(d => d == newDesktop.Object), Times.Once);
replacedert.AreEqual(OperationResult.Success, result);
replacedert.AreEqual(1, current);
replacedert.AreEqual(2, activate);
replacedert.AreEqual(3, startup);
}
See More Examples