public string ThenCorrectlyReturnType(string name) { KarassDependencies dependencies = new KarassDependencies(); TestClass testClass = new TestClass(name); dependencies.Register <ITestInterface>(() => testClass); ITestInterface t = dependencies.Get <ITestInterface>(); return(t.Test()); }
private bool Testing(TestEnum testEnum) { // Variable bool result = true; stringBuilder.Clear(); ITestInterface test = testsDictionary[testEnum].Item1; stringBuilder = test.Test(); // :( - Don't know why it is necessary if (consolePrint) { stringBuilder.AppendLine(); } if (consolePrint) { string template = testsDictionary[testEnum].Item2; string testString = stringBuilder.ToString(); // Because Windows and Unix template = template.Replace("\r\n", "\n"); testString = testString.Replace("\r\n", "\n"); if (template.Equals(testString)) { Console.WriteLine("OK " + testEnum.ToString()); result = true; } else { Console.WriteLine("NOK " + testEnum.ToString()); result = false; } } else { Directory.CreateDirectory(Path.GetDirectoryName(test.GetPath())); testPath = test.GetPath(); StreamWriter streamWriter = new StreamWriter(testPath); streamWriter.WriteLine(stringBuilder.ToString()); streamWriter.Flush(); } ReaderWriter.ReaderWriter.DeleteTestFile(); return(result); }
void exec(TestData testData, TestLogger.TestLogger log, bool summary = true)//load dll file, and let the dll file run the test, write the log { changename(testData); try { Assembly assem = Assembly.LoadFrom(testData.repo + testData.testDriver); Type[] type = assem.GetExportedTypes(); foreach (Type t in type) { if (t.IsClass && typeof(ITestInterface).IsAssignableFrom(t)) { ITestInterface tdr = (ITestInterface)Activator.CreateInstance(t); // create instance of test driver foreach (string lib in testData.testCode) { log.writeLine("test library is " + lib); Console.WriteLine(tdr.getLog()); Console.WriteLine("--------this is for requirement 5-------\r\n Calling ITestInterface Test()");//this is just for demo if (tdr.Test() == true) { log.writeLine("Test result : pass"); Console.WriteLine(" test() return true"); } else { log.writeLine("Test result : fail"); Console.WriteLine(" test() return false"); summary = false; } } } } if (summary == true) { log.writeLine("Summary : pass\r\n\r\n\r\n"); } else { log.writeLine("Summary : fail\r\n\r\n\r\n"); } } catch (Exception ex) { Console.WriteLine(" catch error");//this is just for demo use log.writeLine("error: " + ex.Message); log.writeLine("time: " + DateTime.Now); log.writeLine("Summary : not execuatable\r\n\r\n\r\n"); } }
public void ConfigureServices(IServiceCollection services) { services.AddSuperSocketBase <StringPackageInfo>(Configuration) .AddSuperSocket <TextPackageInfo, LinePipelineFilter>() .ConfigurePackageHandler <TextPackageInfo>((a, p) => { ITestInterface i = (a.Server as IServer).ServiceProvider.GetService <ITestInterface>(); Assert.NotNull(i); Assert.Equal(5, i.Test()); return(Task.CompletedTask); }); services.AddSingleton <ITestInterface, TestInterface>(); }
public void MyTestMethod() { instance.Test(1, "2", new MyUnitTestClass(1, "2")); logger.Verify(x => x.Log(LogLevel.Information, It.IsAny <EventId>(), It.Is <It.IsAnyType>((v, t) => true), It.IsAny <Exception>(), It.Is <Func <It.IsAnyType, Exception, string> >((v, t) => true)), Times.Exactly(2)); }