static void Main(string[] args) { //Console.WriteLine("Hello World!"); var tests = new UnitTests(); tests.CalculateCarValue(); }
public override void Check() { // попробуем загрузить основные сущности var component = Components.Take(1).FirstOrDefault(); var unitTest = UnitTests.Take(1).FirstOrDefault(); var statusData = Bulbs.Take(1).FirstOrDefault(); }
private void Form1_Load(object sender, EventArgs e) { UnitTests.printMsg += (e) => { richTextBox1.AppendText(e + "\n"); }; UnitTests unitTests = new UnitTests(); unitTests.CalculateCarValue(); }
static void Main(string[] args) { var ut = new UnitTests(); //ut.TestLogLogisticWFeatures(); ut.TestLogLogLogisticFeaturedLL(); }
void Start() { // UnitTest uses Wait, it can't run on MainThreadScheduler. Scheduler.DefaultSchedulers.SetDotNetCompatible(); MainThreadDispatcher.Initialize(); UnitTests.SetButtons(buttonPrefab, buttonVertical, resultPrefab, resultVertical); }
public UnitTest AddUnitTest(string className, string name, string storage) { var unitTest = new UnitTest(className, name, TestList.Id, storage); UnitTests.Add(unitTest); return(unitTest); }
public void TestMemoryVsDatabaseRepository_CatalogueConstructor() { var memoryRepository = new MemoryCatalogueRepository(CatalogueRepository.GetServerDefaults()); Catalogue memCatalogue = new Catalogue(memoryRepository, "My New Catalogue"); Catalogue dbCatalogue = new Catalogue(CatalogueRepository, "My New Catalogue"); UnitTests.AssertAreEqual(memCatalogue, dbCatalogue); }
public Status fn03_UnitTests(UnitTests ut, System.ComponentModel.BackgroundWorker bgw) { MainWindow.InvokeLog("Start unit tests command..."); Status s = WriteCommand(0x03); if (s != Status.Success) { return(s); } byte[] read; if (ReadCommand(out read) != Status.Success) { return(Status.Error); } int count = 0; count += read [0]; count += (read [1] << 8); count += (read [2] << 16); count += (read [3] << 24); for (int i = 0; i < count; i++) { if (bgw.CancellationPending) { Cancel(); break; } bgw.ReportProgress((100 * i) / count); UnitTestDataItem item = new UnitTestDataItem(); if (ReadCommand(out read) != Status.Success) { continue; } item.Source = System.Text.Encoding.ASCII.GetString(read); if (ReadCommand(out read) != Status.Success) { continue; } item.Name = System.Text.Encoding.ASCII.GetString(read); if (ReadCommand(out read) != Status.Success) { continue; } item.Result = (read [0] != 0); ut.Add(item); } return(Status.Success); }
private void Main(string argument, UpdateType updateSource) { UnitTests unit_tests = new UnitTests(this); unit_tests.Add(TestArgumentStrings, nameof(TestArgumentStrings)); unit_tests.Add(TestStorageDataSerializer, nameof(TestStorageDataSerializer)); unit_tests.Add(TestCommands, nameof(TestCommands)); unit_tests.Add(TestFileSystem, nameof(TestFileSystem)); unit_tests.Test(); }
public void TestImportingATable(DatabaseType dbType) { DataTable dt = new DataTable(); dt.Columns.Add("Do"); dt.Columns.Add("Ray"); dt.Columns.Add("Me"); dt.Columns.Add("Fa"); dt.Columns.Add("So"); var db = GetCleanedServer(dbType); var tbl = db.CreateTable("OmgTables", dt); var memoryRepository = new MemoryCatalogueRepository(CatalogueRepository.GetServerDefaults()); var importer1 = new TableInfoImporter(memoryRepository, tbl, DataAccessContext.Any); TableInfo memTableInfo; ColumnInfo[] memColumnInfos; Catalogue memCatalogue; CatalogueItem[] memCatalogueItems; ExtractionInformation[] memExtractionInformations; importer1.DoImport(out memTableInfo, out memColumnInfos); var forwardEngineer1 = new ForwardEngineerCatalogue(memTableInfo, memColumnInfos); forwardEngineer1.ExecuteForwardEngineering(out memCatalogue, out memCatalogueItems, out memExtractionInformations); TableInfo dbTableInfo; ColumnInfo[] dbColumnInfos; Catalogue dbCatalogue; CatalogueItem[] dbCatalogueItems; ExtractionInformation[] dbExtractionInformations; var importerdb = new TableInfoImporter(CatalogueRepository, tbl, DataAccessContext.Any); importerdb.DoImport(out dbTableInfo, out dbColumnInfos); var forwardEngineer2 = new ForwardEngineerCatalogue(dbTableInfo, dbColumnInfos); forwardEngineer2.ExecuteForwardEngineering(out dbCatalogue, out dbCatalogueItems, out dbExtractionInformations); UnitTests.AssertAreEqual(memCatalogue, dbCatalogue); UnitTests.AssertAreEqual(memTableInfo, dbTableInfo); UnitTests.AssertAreEqual(memCatalogue.CatalogueItems, dbCatalogue.CatalogueItems); UnitTests.AssertAreEqual(memCatalogue.GetAllExtractionInformation(ExtractionCategory.Any), dbCatalogue.GetAllExtractionInformation(ExtractionCategory.Any)); UnitTests.AssertAreEqual(memCatalogue.CatalogueItems.Select(ci => ci.ColumnInfo), dbCatalogue.CatalogueItems.Select(ci => ci.ColumnInfo)); }
static void Main(string[] args) { UnitTests u = new UnitTests(); u.RunTests(); if (u.TestsFailed > 0) { System.Environment.Exit(1); } }
public void TestMemoryRepository_AggregateConfigurationConstructor() { var memoryRepository = new MemoryCatalogueRepository(CatalogueRepository.GetServerDefaults()); Catalogue memCatalogue = new Catalogue(memoryRepository, "My New Catalogue"); Catalogue dbCatalogue = new Catalogue(CatalogueRepository, "My New Catalogue"); var memAggregate = new AggregateConfiguration(memoryRepository, memCatalogue, "My New Aggregate"); var dbAggregate = new AggregateConfiguration(CatalogueRepository, dbCatalogue, "My New Aggregate"); UnitTests.AssertAreEqual(memAggregate, dbAggregate); }
private void TestManager_Load(object sender, EventArgs e) { _unitTest = UnitTests.VisualListViewAdvanced; Array _tests = typeof(UnitTests).GetEnumValues(); foreach (object test in _tests) { listBoxTests.Items.Add(test); } listBoxTests.SelectedIndex = 0; }
protected override void AddInitialUI() { base.AddInitialUI(); OutputLog = AddScreenUIObject(new ListControl(ScreenDimensions, ScreenCentre)); foreach (TypeInfo typeInfo in Assembly.GetEntryAssembly().DefinedTypes) { if (typeInfo.IsSubclassOf(typeof(UnitTest))) { UnitTests.Add((UnitTest)Activator.CreateInstance(typeInfo)); } } }
private void TestManager_Load(object sender, EventArgs e) { _unitTest = UnitTests.VisualListViewExtended; Array _tests = typeof(UnitTests).GetEnumValues(); visualLabelTestsCount.Text = $@"Tests Count: {_tests.Length}"; foreach (object test in _tests) { visualListBoxTests.Items.Add(test); } visualListBoxTests.SelectedIndex = 0; }
private void TestManager_Load(object sender, EventArgs e) { _unitTest = UnitTests.VisualListView; Array _tests = typeof(UnitTests).GetEnumValues(); visualLabelTestsStats.Text = GenerateTestStatistics(); foreach (object test in _tests) { visualListBoxTests.Items.Add(test); } visualListBoxTests.SelectedIndex = 0; }
static void Main() { UnitTests ut = new UnitTests(); try { ut.TestGoodAddIntegers(); ut.TestBadAddIntegers(); } catch (AssertFailedException ex) { Console.WriteLine(ex.Message); Console.WriteLine("\nHere is the stack trace:\n"); Console.WriteLine(ex.StackTrace); } }
public XElement Serialize() { return(Elem("TestRun", Attr("id", Id), Attr("name", Name), Attr("runUser", RunUser), Times, // TestSettings ElemList("Results", UnitTests.SelectMany(x => x.Results)), ElemList("TestDefinitions", UnitTests), ElemList("TestEntries", UnitTests.Select(x => new TestEntry(x.Id, x.ExecutionId, x.TestListId))), Elem("TestLists", TestList ), new ResultSummary(UnitTests, Output) )); }
public void TestMemoryVsDatabaseRepository_ProcessTaskConstructor() { var memoryRepository = new MemoryCatalogueRepository(CatalogueRepository.GetServerDefaults()); var memLmd = new LoadMetadata(memoryRepository, "My New Load"); var dbLmd = new LoadMetadata(CatalogueRepository, "My New Load"); UnitTests.AssertAreEqual(memLmd, dbLmd); var memPt = new ProcessTask(memoryRepository, memLmd, LoadStage.AdjustRaw) { Name = "MyPt" }; var dbPt = new ProcessTask(CatalogueRepository, dbLmd, LoadStage.AdjustRaw) { Name = "MyPt" }; UnitTests.AssertAreEqual(memPt, dbPt); }
public async Task TestPollyManualIncorrectUri() { var tries = 0; var policy = HttpPolicyExtensions .HandleTransientHttpError() .OrResult(response => response.StatusCode == HttpStatusCode.NotFound) .RetryAsync(3); var client = new Client( new ProtobufSerializationAdapter(), null, new Uri(UnitTests.LocalBaseUriString), logger: null, createHttpClient: UnitTests.GetTestClientFactory().CreateClient, sendHttpRequestFunc: (httpClient, httpRequestMessageFunc, logger, cancellationToken) => { return(policy.ExecuteAsync(() => { var httpRequestMessage = httpRequestMessageFunc.Invoke(); //On the third try change the Url to a the correct one if (tries == 2) { httpRequestMessage.RequestUri = new Uri("Person", UriKind.Relative); } tries++; return httpClient.SendAsync(httpRequestMessage, cancellationToken); })); }); var person = new Person { FirstName = "Bob", Surname = "Smith" }; //Note the Uri here is deliberately incorrect. It will cause a 404 Not found response. This is to make sure that polly is working person = await client.PostAsync <Person, Person>(person, new Uri("person2", UriKind.Relative)); Assert.AreEqual("Bob", person.FirstName); Assert.AreEqual(3, tries); }
public bool Run(string name, int user, string config) { UnitTest ut = null; if (mTimer != null) { mTimer.Dispose(); } if (UnitTests.TryGetValue(name, out ut)) { mCurrentTest = ut; ut.Users = user; ut.Config = config; ut.Execute(); Loger.Process(LogType.INFO, "{0} unitTest runing", name); mTimer = new System.Threading.Timer(OnTime, null, 1000, 1000); return(true); } else { Loger.Process(LogType.INFO, "{0} not found!", name); } return(false); }
/*----------------------------------------- * createTests() * ----------------------------------------*/ private void createTests() { _tests = new UnitTests(); AddChild(_tests); }
private void Add(string javascript, string expectedResult) { UnitTests.Add(new UnitTest(javascript, expectedResult)); }
private void ListBoxTests_SelectedIndexChanged(object sender, EventArgs e) { _unitTest = (UnitTests)visualListBoxTests.SelectedIndex; visualLabelTestsStats.Text = GenerateTestStatistics(); }
/// <summary> /// The main entry point. /// </summary> /// <param name="args">The command line arguments.</param> public static int Main(string[] args) { var path = default(string); for (var i = 0; i < args.Length; i++) { var arg = args[i]; if (path == null) { if (arg.StartsWith("--")) { switch (arg) { case "--debug": Console.Clear(); Interpreter.Inspector = Inspect; break; case "--help": PrintUsage(); return(0); case "--test": UnitTests.Run(); return(0); default: Console.WriteLine($"Invalid option: {arg}"); return(1); } } else { path = arg; } } else { Console.WriteLine($"Invalid argument: {arg}"); return(1); } } if (path == null) { PrintUsage(); return(1); } Console.CancelKeyPress += (s, e) => { if (Interpreter.Inspector != null) { running = false; e.Cancel = true; } }; try { Module.Load(path); return(0); } catch (ParseError error) { Console.WriteLine(error); } catch (Exception error) { Console.WriteLine($"ERROR: {error.Message}"); if (error.GetStackTrace() is string stackTrace) { Console.WriteLine(stackTrace); } } return(1); }
private void ListBoxTests_SelectedIndexChanged(object sender, EventArgs e) { _unitTest = (UnitTests)visualListBoxTests.SelectedIndex; }
static void Main(string[] args) { string folder = @"C:\Elevator"; if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } int failedTests = 0; //if (!UnitTests.GetElevator_LiftABelowLiftBAbove_LiftBOptimal_ReturnsB()) //{ // failedTests++; //} //if (!UnitTests.GetElevator_LiftABelowLiftBAbove_LiftAOptimal_ReturnsA()) //{ // failedTests++; //} //if (!UnitTests.GetElevator_LiftBBelowLiftAAbove_LiftAOptimal_ReturnsB()) //{ // failedTests++; //} //if (!UnitTests.GetElevator_LiftBBelowLiftAAbove_LiftBOptimal_ReturnsA()) //{ // failedTests++; //} //if (!UnitTests.GetElevator_LiftAAndLiftBInTheSameFloorAndLifecycleLiftBMorethanAAboveMe_LiftBOptimal_ReturnsA()) //{ // failedTests++; //} //if (!UnitTests.GetElevator_LiftAAndLiftBInTheSameFloorAndLifecycleLiftAMorethanBAboveMe_LiftBOptimal_ReturnsB()) //{ // failedTests++; //} //if (!UnitTests.GetElevator_LiftAAndLiftBInTheSameFloorAndLifecycleLiftBMorethanABelowMe_LiftBOptimal_ReturnsA()) //{ // failedTests++; //} //if (!UnitTests.GetElevator_LiftAAndLiftBInTheSameFloorAndLifecycleLiftAMorethanBBelowMe_LiftBOptimal_ReturnsB()) //{ // failedTests++; //} if (!UnitTests.UnitTestMethod(0, 0, "GetElevator_LiftABelowLiftBAbove_LiftBOptimal_ReturnsB", "Elevator B", 1, 9, 8)) { failedTests++; } if (!UnitTests.UnitTestMethod(0, 0, "GetElevator_LiftABelowLiftBAbove_LiftAOptimal_ReturnsA", "Elevator A", 1, 9, 2)) { failedTests++; } if (!UnitTests.UnitTestMethod(0, 0, "GetElevator_LiftBBelowLiftAAbove_LiftAOptimal_ReturnsB", "Elevator B", 9, 1, 2)) { failedTests++; } if (!UnitTests.UnitTestMethod(0, 0, "GetElevator_LiftBBelowLiftAAbove_LiftBOptimal_ReturnsA", "Elevator A", 9, 1, 8)) { failedTests++; } if (!UnitTests.UnitTestMethod(0, 5, "GetElevator_LiftAAndLiftBInTheSameFloorAndLifecycleLiftBMorethanAAboveMe_LiftBOptimal_ReturnsA", "Elevator A", 9, 9, 5)) { failedTests++; } if (!UnitTests.UnitTestMethod(5, 0, "GetElevator_LiftAAndLiftBInTheSameFloorAndLifecycleLiftAMorethanBAboveMe_LiftBOptimal_ReturnsB", "Elevator B", 9, 9, 5)) { failedTests++; } if (!UnitTests.UnitTestMethod(0, 5, "GetElevator_LiftAAndLiftBInTheSameFloorAndLifecycleLiftBMorethanABelowMe_LiftBOptimal_ReturnsA", "Elevator A", 1, 1, 5)) { failedTests++; } if (!UnitTests.UnitTestMethod(5, 0, "GetElevator_LiftAAndLiftBInTheSameFloorAndLifecycleLiftAMorethanBBelowMe_LiftBOptimal_ReturnsB", "Elevator B", 1, 1, 5)) { failedTests++; } if (failedTests == 0) { Console.WriteLine("Test completed succesfully!!"); } //while (true) //{ // Console.WriteLine("stage of elevator A (0-10)"); // int firstLift = Int32.Parse(Console.ReadLine()); // Console.WriteLine("stage of elevator B (0-10)"); // int secondLift = Int32.Parse(Console.ReadLine()); // Console.WriteLine("input your current stage(0-10)"); // int current = Int32.Parse(Console.ReadLine()); // string s = GetElevator(firstLift, secondLift, current); // Console.WriteLine(s); //} Console.ReadKey(); }
public static void Main(string[] arg) { // *** Parse arguments. if (arg.Length == 0) { PrintUsage(); return; } bool optRunTests = false; bool optInteractiveMode = false; bool optVerbose = false; bool optPause = false; bool optDump = false; List <string> optFiles = new List <string>(); List <string> passThroughArgs = null; for (int iArg = 0; iArg < arg.Length; ++iArg) { string ar = arg[iArg]; if (ar[0] == '-' || ar[0] == '/') { if (ar[1] == 't') { optRunTests = true; } else if (ar[1] == 'i') { optInteractiveMode = true; } else if (ar[1] == 'v') { Console.WriteLine("verbose enabled."); optVerbose = true; } else if (ar[1] == 'p') { optPause = true; } else if (ar[1] == 'd') { optDump = true; } else if (ar[1] == 'a') { if (iArg == arg.Length - 1) { Console.WriteLine("Argument expected after -a option."); PrintUsage(); return; } else { passThroughArgs = passThroughArgs ?? new List <string>(); passThroughArgs.Add(arg[++iArg]); } } else { Console.WriteLine("Unrecognized option '" + ar[1] + "'."); PrintUsage(); return; } } else { optFiles.Add(ar); } } // *** Initialize engine. // Create engine. Engine engine = new Engine(); engine.LogError = (msg) => { ConsoleColor sav = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(msg); Console.ForegroundColor = sav; }; // Register optional libraries. DebugLib.Register(engine); FileLib.Register(engine); DateTimeLib.Register(engine); ConsoleLib.Register(engine); List <ParseErrorInst> errors = new List <ParseErrorInst>(); // Create pass-through args. if (null != passThroughArgs) { string initScript = "global List<string> CLIargs = new { "; foreach (string pta in passThroughArgs) { initScript += "Add(\"" + pta + "\"); "; } initScript += "};"; ScriptResult result = engine.RunScript(initScript, false); if (!result.success) { Console.WriteLine("INTERNAL ERROR creating passthrough arguments array."); return; } errors.Clear(); } // *** Do tasks. // Tests... if (optRunTests) { UnitTests.RunTests(engine, optVerbose); } // Files... foreach (string filename in optFiles) { string fileContents; try { fileContents = File.ReadAllText(filename); } catch (Exception e) { Console.WriteLine("Error attempting to open '" + filename + "': " + e.Message); break; } errors.Clear(); ScriptResult result = engine.RunScript(fileContents, optVerbose, filename); if (result.success) { Console.WriteLine("Returned: " + CoreLib.ValueToString(engine.defaultContext, result.value, true)); } else { // At time of writing, errors get printed (in red) when they are created, so don't need to do it again here. //Console.WriteLine(result); Console.WriteLine(" " + filename + " failed to compile or execute."); } } // Interactive mode... if (optInteractiveMode) { Console.WriteLine("Pebble Interpreter (C) 2021 Patrick Cyr"); Console.WriteLine("Interactive mode. Enter 'exit' to exit, 'help' for help:"); // Lines in interactive mode don't use their own scope. Instead, they // use one shared scope that is created here. engine.defaultContext.stack.PushTerminalScope("<interactive mode>", null); while (true) { Console.Write("> "); string line = Console.ReadLine(); line = line.Trim(); if (line.Equals("exit", StringComparison.OrdinalIgnoreCase)) { break; } if (line.Equals("help", StringComparison.OrdinalIgnoreCase)) { line = "Debug::DumpClass(\"Debug\");"; Console.WriteLine(line); } ScriptResult result = engine.RunInteractiveScript(line, optVerbose); if (result.success) { if (null == result.value) { Console.WriteLine("<null>"); } else { Console.WriteLine(CoreLib.ValueToString(engine.defaultContext, result.value, true)); } } } } // Dump memory... if (optDump) { Console.WriteLine(); Console.WriteLine(engine.defaultContext); } // Pause before exiting... if (optPause) { Console.WriteLine("Press any key to exit."); Console.ReadKey(); } }
static void RunDebug() { UnitTests.TestHSV(); }
public IQueryable <UnitTest> GetUnitTests() { return(UnitTests.Where(t => t.IsDeleted == false).AsQueryable()); }