public void MethodExecution_ShouldExecuteMethod() { var filePath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); try { // Arrange testEngine.LoadAssembly(@"TestSuite.TestEngine.Test.dll"); testEngine.SetClass(@"TestSuite.TestEngine.Test.MockClass, TestSuite.TestEngine.Test"); var method = new Method("WriteToFile"); method.Parameters["file"] = filePath; method.Parameters["contents"] = "FileWritten"; // Act testEngine.MethodExecution.Execute(method); // Assert var readFile = File.ReadAllText(filePath); readFile.ShouldEqual("FileWritten"); } finally { File.Delete(filePath); } }
public void LoadAssembly_ShouldNotLoadAssemblyInAppDomain() { // Act testEngine.LoadAssembly(@"Assemblies\TestSuite.TestEngine.OutOfDomainMock.dll"); // Assert var assemblies = AppDomain.CurrentDomain.GetAssemblies(); var mockAssembly = assemblies.FirstOrDefault(a => a.GetName().Name == "TestSuite.TestEngine.OutOfDomainMock"); mockAssembly.ShouldBeNull(); }
public void SetClass_ShouldCreateMethodExecutionInstance() { // Arrange testEngine.LoadAssembly(@"Assemblies\TestSuite.TestEngine.Mock.dll"); // Act testEngine.SetClass(@"TestSuite.TestEngine.Mock.Class1, TestSuite.TestEngine.Mock"); // Assert var methodExecution = testEngine.MethodExecution as MethodExecution; methodExecution.ShouldNotBeNull(); }
public void Visit(LoadAssemblyStep loadAssemblyStep) { try { loadAssemblyStep.Status = ExecutionStatus.InProgress; var assemblyPath = Path.Combine(assembliesPath, loadAssemblyStep.AssemblyPath); testEngine.LoadAssembly(assemblyPath); loadAssemblyStep.Status = ExecutionStatus.Passed; loadAssemblyStep.Error = null; } catch (Exception ex) { loadAssemblyStep.Status = ExecutionStatus.Failed; loadAssemblyStep.Error = ex.Message; hasError = true; } }