Exemplo n.º 1
0
        static void Main(string[] args)
        {
            //Console.WriteLine("Hello World!");
            var tests = new UnitTests();

            tests.CalculateCarValue();
        }
Exemplo n.º 2
0
 public override void Check()
 {
     // попробуем загрузить основные сущности
     var component  = Components.Take(1).FirstOrDefault();
     var unitTest   = UnitTests.Take(1).FirstOrDefault();
     var statusData = Bulbs.Take(1).FirstOrDefault();
 }
Exemplo n.º 3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            UnitTests.printMsg += (e) => { richTextBox1.AppendText(e + "\n"); };
            UnitTests unitTests = new UnitTests();

            unitTests.CalculateCarValue();
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            var ut = new UnitTests();

            //ut.TestLogLogisticWFeatures();
            ut.TestLogLogLogisticFeaturedLL();
        }
Exemplo n.º 5
0
        void Start()
        {
            // UnitTest uses Wait, it can't run on MainThreadScheduler.
            Scheduler.DefaultSchedulers.SetDotNetCompatible();
            MainThreadDispatcher.Initialize();

            UnitTests.SetButtons(buttonPrefab, buttonVertical, resultPrefab, resultVertical);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 8
0
        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));
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 13
0
        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;
        }
Exemplo n.º 14
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));
                }
            }
        }
Exemplo n.º 15
0
        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;
        }
Exemplo n.º 16
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;
        }
Exemplo n.º 17
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);
        }
    }
Exemplo n.º 18
0
 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);
        }
Exemplo n.º 20
0
        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);
        }
Exemplo n.º 21
0
        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);
        }
Exemplo n.º 22
0
 /*-----------------------------------------
  *              createTests()
  * ----------------------------------------*/
 private void createTests()
 {
     _tests = new UnitTests();
     AddChild(_tests);
 }
Exemplo n.º 23
0
 private void Add(string javascript, string expectedResult)
 {
     UnitTests.Add(new UnitTest(javascript, expectedResult));
 }
Exemplo n.º 24
0
 private void ListBoxTests_SelectedIndexChanged(object sender, EventArgs e)
 {
     _unitTest = (UnitTests)visualListBoxTests.SelectedIndex;
     visualLabelTestsStats.Text = GenerateTestStatistics();
 }
Exemplo n.º 25
0
    /// <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);
    }
Exemplo n.º 26
0
 private void ListBoxTests_SelectedIndexChanged(object sender, EventArgs e)
 {
     _unitTest = (UnitTests)visualListBoxTests.SelectedIndex;
 }
Exemplo n.º 27
0
        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();
        }
Exemplo n.º 28
0
        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();
            }
        }
Exemplo n.º 29
0
 static void RunDebug()
 {
     UnitTests.TestHSV();
 }
Exemplo n.º 30
0
 public IQueryable <UnitTest> GetUnitTests()
 {
     return(UnitTests.Where(t => t.IsDeleted == false).AsQueryable());
 }