SEBWIN-482: Fixed unit tests.
This commit is contained in:
		
							parent
							
								
									a155c56198
								
							
						
					
					
						commit
						fcbc641127
					
				
					 2 changed files with 20 additions and 25 deletions
				
			
		| 
						 | 
				
			
			@ -13,6 +13,7 @@ using Moq;
 | 
			
		|||
using SafeExamBrowser.Configuration.Contracts;
 | 
			
		||||
using SafeExamBrowser.Configuration.Contracts.Cryptography;
 | 
			
		||||
using SafeExamBrowser.Core.Contracts.OperationModel;
 | 
			
		||||
using SafeExamBrowser.Core.Contracts.OperationModel.Events;
 | 
			
		||||
using SafeExamBrowser.Logging.Contracts;
 | 
			
		||||
using SafeExamBrowser.Runtime.Operations;
 | 
			
		||||
using SafeExamBrowser.Runtime.Operations.Events;
 | 
			
		||||
| 
						 | 
				
			
			@ -271,7 +272,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
 | 
			
		|||
			server.Setup(s => s.Connect()).Returns(new ServerResponse(true));
 | 
			
		||||
			server.Setup(s => s.Initialize(It.IsAny<ServerSettings>()));
 | 
			
		||||
			server.Setup(s => s.GetConnectionInfo()).Returns(connection);
 | 
			
		||||
			server.Setup(s => s.GetAvailableExams(It.IsAny<string>())).Returns(new ServerResponse<IEnumerable<Exam>>(true, new [] { exam }));
 | 
			
		||||
			server.Setup(s => s.GetAvailableExams(It.IsAny<string>())).Returns(new ServerResponse<IEnumerable<Exam>>(true, new[] { exam }));
 | 
			
		||||
			server.Setup(s => s.GetConfigurationFor(It.IsAny<Exam>())).Returns(new ServerResponse<Uri>(true, new Uri("file:///configuration.seb")));
 | 
			
		||||
			sut.ActionRequired += (args) => Assert.Fail();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -540,8 +541,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
 | 
			
		|||
		}
 | 
			
		||||
 | 
			
		||||
		[TestMethod]
 | 
			
		||||
		public void Repeat_MustKeepExistingServerSession()
 | 
			
		||||
		public void Repeat_MustNotAllowToReconfigureServerSession()
 | 
			
		||||
		{
 | 
			
		||||
			var args = default(ActionRequiredEventArgs);
 | 
			
		||||
 | 
			
		||||
			context.Current.AppConfig.ServerApi = "api";
 | 
			
		||||
			context.Current.AppConfig.ServerConnectionToken = "token";
 | 
			
		||||
			context.Current.AppConfig.ServerExamId = "id";
 | 
			
		||||
| 
						 | 
				
			
			@ -549,19 +552,22 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
 | 
			
		|||
			context.Current.Settings.SessionMode = SessionMode.Server;
 | 
			
		||||
			context.Next.Settings.SessionMode = SessionMode.Server;
 | 
			
		||||
 | 
			
		||||
			sut.ActionRequired += (a) =>
 | 
			
		||||
			{
 | 
			
		||||
				args = a;
 | 
			
		||||
			};
 | 
			
		||||
 | 
			
		||||
			var result = sut.Repeat();
 | 
			
		||||
 | 
			
		||||
			configuration.VerifyNoOtherCalls();
 | 
			
		||||
			fileSystem.VerifyNoOtherCalls();
 | 
			
		||||
			server.VerifyNoOtherCalls();
 | 
			
		||||
 | 
			
		||||
			Assert.AreEqual(context.Current.AppConfig.ServerApi, context.Next.AppConfig.ServerApi);
 | 
			
		||||
			Assert.AreEqual(context.Current.AppConfig.ServerConnectionToken, context.Next.AppConfig.ServerConnectionToken);
 | 
			
		||||
			Assert.AreEqual(context.Current.AppConfig.ServerExamId, context.Next.AppConfig.ServerExamId);
 | 
			
		||||
			Assert.AreEqual(context.Current.AppConfig.ServerOauth2Token, context.Next.AppConfig.ServerOauth2Token);
 | 
			
		||||
			Assert.AreSame(context.Current.Settings.Server, context.Next.Settings.Server);
 | 
			
		||||
			Assert.AreEqual(OperationResult.Success, result);
 | 
			
		||||
			Assert.AreEqual(SessionMode.Server, context.Next.Settings.SessionMode);
 | 
			
		||||
			Assert.IsNull(context.Next.AppConfig.ServerApi);
 | 
			
		||||
			Assert.IsNull(context.Next.AppConfig.ServerConnectionToken);
 | 
			
		||||
			Assert.IsNull(context.Next.AppConfig.ServerOauth2Token);
 | 
			
		||||
			Assert.IsInstanceOfType(args, typeof(MessageEventArgs));
 | 
			
		||||
			Assert.AreEqual(OperationResult.Aborted, result);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[TestMethod]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -102,6 +102,7 @@ namespace SafeExamBrowser.Runtime.Operations
 | 
			
		|||
				if (Context.Next.Settings.SessionMode == SessionMode.Server)
 | 
			
		||||
				{
 | 
			
		||||
					ShowReconfigurationError();
 | 
			
		||||
 | 
			
		||||
					return OperationResult.Aborted;
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
| 
						 | 
				
			
			@ -116,6 +117,7 @@ namespace SafeExamBrowser.Runtime.Operations
 | 
			
		|||
 | 
			
		||||
			return OperationResult.Success;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public override OperationResult Revert()
 | 
			
		||||
		{
 | 
			
		||||
			var result = OperationResult.Success;
 | 
			
		||||
| 
						 | 
				
			
			@ -145,19 +147,6 @@ namespace SafeExamBrowser.Runtime.Operations
 | 
			
		|||
			ActionRequired?.Invoke(args);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		private void InitializeNextSession()
 | 
			
		||||
		{
 | 
			
		||||
			logger.Info("Initializing server configuration for next session...");
 | 
			
		||||
 | 
			
		||||
			Context.Next.AppConfig.ServerApi = Context.Current.AppConfig.ServerApi;
 | 
			
		||||
			Context.Next.AppConfig.ServerConnectionToken = Context.Current.AppConfig.ServerConnectionToken;
 | 
			
		||||
			Context.Next.AppConfig.ServerExamId = Context.Current.AppConfig.ServerExamId;
 | 
			
		||||
			Context.Next.AppConfig.ServerOauth2Token = Context.Current.AppConfig.ServerOauth2Token;
 | 
			
		||||
 | 
			
		||||
			Context.Next.Settings = Context.Current.Settings;
 | 
			
		||||
			Context.Next.Settings.SessionMode = SessionMode.Server;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		private OperationResult TryLoadServerSettings(Exam exam, Uri uri)
 | 
			
		||||
		{
 | 
			
		||||
			var info = server.GetConnectionInfo();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue