Пример #1
0
        public void SetUp()
        {
            var library = FixtureLibrary.For(x => x.AddFixture <RecordingFixture>());

            system = new RecordingSystem();


            var fixtureContainerSource = new FixtureContainerSource(new Container(x =>
            {
                x.For <IFixture>().Add <RecordingFixture>().Named("Recording");
            }));

            fixtureContainerSource.RegisterFixture("Recording", typeof(RecordingFixture));

            lifecycle = new SystemLifecycle(system);
            runner    = new TestRunner(lifecycle, library, fixtureContainerSource);
            lifecycle.StartApplication();

            lifecycle.RecycleEnvironment();

            var test = new Test("something");

            test.Add(new Section("Recording").WithStep("Execute"));

            runner.RunTest(new TestExecutionRequest()
            {
                Test             = test,
                TimeoutInSeconds = 1200
            });

            system.Messages.Each(x => Debug.WriteLine(x));
        }
Пример #2
0
        public void SetUp()
        {
            var library = FixtureLibrary.For(x => x.AddFixture <RecordingFixture>());

            system = new RecordingSystem();
            var fixtureContainerSource = new FixtureContainerSource(new Container(x =>
            {
                x.For <IFixture>().Add <RecordingFixture>().Named("Recording");
            }));

            fixtureContainerSource.RegisterFixture("Recording", typeof(RecordingFixture));

            runner = new TestRunner(system, library, fixtureContainerSource);

            var test = new Test("something");

            test.Add(new Section("Recording").WithStep("Execute"));

            runner.RunTest(new TestExecutionRequest()
            {
                Test             = test,
                TimeoutInSeconds = 1200
            });

            runner.RunTest(new TestExecutionRequest()
            {
                Test             = test,
                TimeoutInSeconds = 1200
            });
        }
Пример #3
0
 /// <summary>
 /// Ctor of the action configuration model.
 /// </summary>
 public OpcActionConfigurationModel(TestActionModel action, string endpointUrl = null, bool useSecurity = true)
 {
     Init();
     EndpointUrl = new Uri(endpointUrl ?? DefaultEndpointUrl);
     UseSecurity = useSecurity;
     Test.Add(new TestActionModel(action));
 }
Пример #4
0
        public void create_example_test()
        {
            var test = new Test("some test");

            test.Section("a");
            test.Section("b");
            test.Section("c");
            Section section = new Section("Math").WithStep("MultiplyBy").WithStep("step1").WithStep("step2");

            test.Add(section);


            var structure = new StubGrammarStructure
            {
                Name   = "MultiplyBy",
                Parent = new FixtureGraph("Math")
            };

            structure.ModifyExampleTest(test);

            test.Parts.Count.ShouldEqual(1);
            var theSection = test.Parts[0].ShouldBeOfType <Section>();

            theSection.Parts.Count.ShouldEqual(1);
            theSection.Parts[0].ShouldBeOfType <IStep>().GrammarKey.ShouldEqual("MultiplyBy");
        }
        public JavaScriptTestFile SelectorTester()
        {
            var mathTest = new Test("math");

            mathTest.Add(new Section("Math"));

            return(new JavaScriptTestFile("Selector Tester")
                   .TestFile("SelectorTester.js")
                   .AddTest("math", mathTest)
                   .Html(x =>
            {
                FixtureLibrary library =
                    FixtureLibrary.For(o => o.AddFixturesFromAssemblyContaining <SentenceFixture>());
                x.Add("div").Append(new TestEditorTag(library));

                x.Add("Div").AddClass(GrammarConstants.EMBEDDED).Id("section1").Add("div").AddClass(
                    GrammarConstants.STEP_HOLDER).AddClass(GrammarConstants.SECTION);
                x.Add("Div").AddClass(GrammarConstants.EMBEDDED).Id("section2").Add("div").AddClass(
                    GrammarConstants.STEP_HOLDER).AddClass(GrammarConstants.SECTION);
                x.Add("Div").AddClass(GrammarConstants.EMBEDDED).Id("section3").Add("div").AddClass(
                    GrammarConstants.STEP_HOLDER).AddClass(GrammarConstants.SECTION);
                x.Add("Div").AddClass(GrammarConstants.EMBEDDED).Id("section4").Add("div").AddClass(
                    GrammarConstants.STEP_HOLDER).AddClass(GrammarConstants.SECTION);
                x.Add("Div").AddClass(GrammarConstants.EMBEDDED).Id("section5").Add("div").AddClass(
                    GrammarConstants.STEP_HOLDER).AddClass(GrammarConstants.SECTION);
                x.Add("Div").AddClass(GrammarConstants.EMBEDDED).Id("section6").Add("div").AddClass(
                    GrammarConstants.STEP_HOLDER).AddClass(GrammarConstants.SECTION);
                x.Add("Div").AddClass(GrammarConstants.EMBEDDED).Id("section7").Add("div").AddClass(
                    GrammarConstants.STEP_HOLDER).AddClass(GrammarConstants.SECTION);
                x.Add("Div").AddClass(GrammarConstants.EMBEDDED).Id("section8").Add("div").AddClass(
                    GrammarConstants.STEP_HOLDER).AddClass(GrammarConstants.SECTION);
            })
                   .Fixtures(x => x.AddFixturesFromAssemblyContaining <SentenceFixture>()));
        }
        private void runTest(string key, string stepValues)
        {
            StateFixture.RunningTotal = 0;
            var test = new Test("something");
            test.Add(new Section("Imports").WithStep(key, stepValues));

            TestUtility.RunTest(test);
        }
Пример #7
0
    public static void Main(string[] args)
    {
        Test t = new Test();

        while (true)
        {
            t.Add(new object());
        }
    }
Пример #8
0
        private void runTest(string key, string stepValues)
        {
            StateFixture.RunningTotal = 0;
            var test = new Test("something");

            test.Add(new Section("Imports").WithStep(key, stepValues));

            TestUtility.RunTest(test);
        }
Пример #9
0
        static void Main(string[] args)
        {
            Test test = new Test();

            Console.WriteLine(test.Power(10));
            Console.WriteLine(test.Power(20));
            Console.WriteLine(test.Add(3, 5));
            Console.WriteLine(test.Sub(7, 3));
            Console.WriteLine(test.DivideA(2.0f, 4.0f));
        }
Пример #10
0
        public void run_simple_test()
        {
            var test = new Test("Try it");

            test.Add(Section.For <NameScreenFixture>().WithStep("GoTo", "name:Jeremy"));

            var testResult = theRunner.RunTest(test);

            testResult.Counts.ShouldEqual(0, 0, 0, 0);
        }
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,Address,Age,Email")] Student student)
        {
            if (ModelState.IsValid)
            {
                _context.Add(student);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(student));
        }
Пример #12
0
        public void run_simple_test()
        {
            var test = new Test("Try it");

            test.Add(Section.For <NameScreenFixture>().WithStep("GoTo", "name:Jeremy"));

            var testResult = theRunner.RunTest(new TestExecutionRequest(test, new TestStopConditions()));

            //var testResult = TestRunnerExtensions.RunTest(theRunner, test);
            testResult.Counts.ShouldEqual(0, 0, 0, 0);
            //testResult.Counts.ShouldEqual(1, 0, 0, 0);
        }
Пример #13
0
        public void run_more_complicated_test_negative()
        {
            var test    = new Test("Try it");
            var section = Section.For <NameScreenFixture>()
                          .WithStep("GoTo", "name:Jeremy")
                          .WithStep("CheckName", "Name:Max");

            test.Add(section);

            var testResult = theRunner.RunTest(test);

            testResult.Counts.ShouldEqual(0, 1, 0, 0);
        }
Пример #14
0
        private TestResult runStep(IStep step)
        {
            ActionsFixture.Reset();

            var test    = new Test("something");
            var section = new Section("Actions");

            section.Add(step);
            test.Add(section);

            var runner = TestRunnerBuilder.ForFixture <ActionsFixture>();

            return(runner.RunTest(new TestExecutionRequest(test, new TestStopConditions())));
        }
Пример #15
0
        public void run_more_complicated_test_positive()
        {
            var test    = new Test("Try it");
            var section = Section.For <NameScreenFixture>()
                          .WithStep("GoTo", "name:Jeremy")
                          .WithStep("CheckName", "Name:Jeremy");

            test.Add(section);

            var testResult = theRunner.RunTest(new TestExecutionRequest(test, new TestStopConditions()));

            //var testResult = theRunner.RunTest(test);
            testResult.Counts.ShouldEqual(1, 0, 0, 0);
            //testResult.Counts.ShouldEqual(1, 0, 0, 0);
        }
Пример #16
0
        private void addTest(string name, Action <StepLeaf> configure)
        {
            var test    = new Test(name);
            var section = new Section(typeof(SampleTableFixture).GetFixtureAlias());

            test.Add(section);
            var step = new Step("Table1");

            section.Add(step);

            var leaf = step.LeafFor("rows");

            configure(leaf);

            AddTest(name, test);
        }
Пример #17
0
 private void readFromChildNode(INode node, Test test)
 {
     if (node.IsComment())
     {
         test.AddComment(node.InnerText);
     }
     else if (node.IsTags())
     {
         test.AddTags(node.InnerText);
     }
     else
     {
         Section section = ReadSection(node);
         test.Add(section);
     }
 }
Пример #18
0
        static void Main(string[] args)
        {
            Console.WriteLine(Reverse("Hello, World!"));
            Console.WriteLine(Fib(0, 1, 10));


            var t = new Test();

            t.string1 = "string value 1";

            t.Add(1);
            Console.WriteLine(t.Int1);
            Console.WriteLine(t.string1);


            Generic <string>();
        }
        public ReportViewModel()
        {
            Test.Clear();

            Random r = new Random();

            for (int i = 0; i < 100; i++)
            {
                ReportRow row = new ReportRow(r.Next(2, 3000));
                row.Columns = new List <ReportColumn>();

                for (int x = 0; x < 100; x++)
                {
                    row.Columns.Add(new ReportColumn(r.Next(2, 2000)));
                }
                Test.Add(row);
            }
        }
Пример #20
0
        public Task <Test> GetById(long testId)
        {
            var testDefinition = this.GetTest();
            var test           = new Test(testDefinition.Id);

            foreach (var item in testDefinition)
            {
                ITestCommand testCommand = this.testCommandFactory.Create(item);
                if (testCommand == null)
                {
                    throw new ApplicationException("The testCommand is null.");
                }

                test.Add(testCommand);
            }

            return(Task.FromResult(test));
        }
Пример #21
0
        public MNISTDataCollection()
        {
            trainingKeep = new List <int> [10];
            for (int i = 0; i < 10; ++i)
            {
                trainingKeep[i] = new List <int>();
            }

            foreach (var image in MnistReader.ReadTrainingData())
            {
                Training.Add(new Datum(ProcessImage(image.Data), ProcessLabel(image.Label)));
                trainingKeep[image.Label].Add(Training.Count - 1);
            }

            foreach (var image in MnistReader.ReadTestData())
            {
                Test.Add(new Datum(ProcessImage(image.Data), ProcessLabel(image.Label)));
            }

            InputFeatureCount  = Training[0].Input.Count;
            OutputFeatureCount = Training[0].Output.Count;
        }
Пример #22
0
        private void DistributeFilesNames()
        {
            string fileName;
            string versionMarker;

            foreach (string filePath in InitialPaths)
            {
                fileName      = Path.GetFileName(filePath);
                versionMarker = fileName.Substring(0, 1);

                if (versionMarker == "[")
                {
                    Master.Add(fileName);
                }
                else if (versionMarker == "]")
                {
                    Test.Add(fileName);
                }
                else
                {
                    Common.Add(fileName);
                }
            }
        }
Пример #23
0
        public void Execute(IJobExecutionContext context)
        {
            var test = new Test();

            Console.WriteLine(test.Add(1000, 10000));
        }
Пример #24
0
        public Guid TestAdd(Guid customerid, string url)
        {
            var test = new Test();

            return(test.Add(customerid, url));
        }
        public static void Main(string[] args)
        {
            Shape shape = new Shape(4, 5);

            Console.WriteLine("{0}, {1}", shape.X, shape.Y);

            // ConstReadOnlyStatic
            ConstReadonlyStatic constReadonlyStatic = new ConstReadonlyStatic();

            //RefAndOut (swap numbers and testing Out params)
            RefAndOut refAndOut = new RefAndOut();
            int       a         = 6;
            int       b         = 9;
            int       c;

            refAndOut.SwapNubers(ref a, ref b);
            refAndOut.OutExampleSumNumbers(a, b, out c);
            Console.WriteLine("sum of numbers is : {0}", c);

            // ExtensionMethods
            Class1 c1 = new Class1();

            c1.Display();
            c1.NewMethod();


            //DisposeVsFinalize
            DisposeVsFinalize d = new DisposeVsFinalize();

            d.Dispose();
            d = null;

            // DelegatesDemo
            DelegatesDemo dd = new DelegatesDemo();
            SumDelegate   sd = new SumDelegate(dd.Sum);

            Console.WriteLine("sum is: {0}", sd.Invoke(30, 40));
            sd += dd.Multiply; //multicast delegate
            Console.WriteLine("Multiply : {0}", sd.Invoke(1, 2));

            SumDelegate[] sd1 =
            {
                new SumDelegate(dd.Sum),
                new SumDelegate(dd.Multiply)
            };
            for (int i = 0; i < sd1.Length; i++)
            {
                Console.WriteLine("{0}", sd1[i](2, 5));
                Console.WriteLine("{0}", sd1[i](8, 5));
                Console.WriteLine("{0}", sd1[i](4, 6));
            }

            //EventsDemo
            EventsDemo ed = new EventsDemo();

            event1 += new SampleDel(ed.India);
            event1 += new SampleDel(ed.USA);
            event1 += new SampleDel(ed.Netherlands);

            event1.Invoke();
            event1 -= new SampleDel(ed.USA);
            event1.Invoke();

            ed.Action("hello");
            ed.xyz += new StrDel(ed.Action);


            //MicrosoftEventsPattern demo
            MicrosoftEventPattern mep = new MicrosoftEventPattern();

            mep.MyEvent += new MicrosoftEventPattern.MyDelegate(mep.DisplayMsg);
            mep.RaiseEvent("Hello from the event!!!");

            // Patter 2 demo
            MicrosoftEventPattern2 mep2 = new MicrosoftEventPattern2();

            mep2.MyEvent2 += new MicrosoftEventPattern2.MyDelegate2(mep2.DisplayMsg);
            mep2.RaiseEvent("Hello MEP !!!!", 26);

            //IEnumerableDemo
            IEnumerableDemo id = new IEnumerableDemo();

            id.Print();
            id.ListOperations();


            Test t1 = new Test();

            t1.Name    = "Bhawna";
            t1.Surname = "Deonani";
            Test t2 = new Test();

            t2.Name    = "Darwin";
            t2.Surname = "Rajpal";
            Test myList = new Test();

            myList.Add(t1);
            myList.Add(t2);
            foreach (Test obj in myList)
            {
                Console.WriteLine("Name:- " + obj.Name + " Surname :- " + obj.Surname);
            }

            // static Polymorphism
            StaticPolymorphism sp = new StaticPolymorphism();

            sp.Add(1, 2);
            sp.Add("bhawna", "deonani");

            //Dynamic Polymorphism
            //Method hiding using new keyword
            Base b2 = new Base();

            b2.Foo();

            Base base1 = new Child1();

            base1.Foo();

            Child1 child1 = new Child1();

            child1.Foo();

            // Method overriding
            Base b3 = new Child2();

            b3.Foo();

            Child1 child11 = new Child3();

            child11.Foo();

            //Abstract methods
            Base2 b123 = new ChildAbstract();

            b123.Test();
            b123.Test1();

            //Interfaces, you can create interface objects only for instance of class
            // Meaning that You cannot instantiate an interface
            // even if the object here is of interface type but the memory is allocated only for the class
            IInterface1 iiii = new A();

            iiii.Print();

            A aa = new A();

            aa.Sum(2, 3);
            aa.Display();

            B bb = new B();

            bb.Sum(33, 44);
            bb.Print();

            // this can only call interface 1 methods
            IInterface1 ii1 = aa;

            ii1.Print();
            ii1.Sum(5, 6);


            //This can only call interface 2 methods
            IInterface2 ii2 = aa;

            ii2.Display();

            if (ii1 is IInterface2)
            {
                IInterface2 interface2 = (IInterface2)ii1;
                interface2.Display();
            }

            IInterface2 int21 = ii1 as IInterface2;

            int21.Display();

            //ConstructorsDemo

            ClassConst cd  = new ClassDerived();
            ClassConst cd1 = new ClassDerived("Bhawna");

            //Array
            ArrayClass ar = new ArrayClass();

            ar.ReverseArray();

            //Ienumerable
            Test1 t11 = new Test1();

            t11.Display();

            IEnumerable <int> e1 = t11.GetPowersofTwo();

            foreach (int i in e1)
            {
                Console.WriteLine(i.ToString());
            }

            //Singleton Demo
            //only one object is created via using a static property and Private constructor
            SingletonClass a1 = SingletonClass.Instance;

            a1.Test();

            //Threadsafe singleton demo
            ThreadSafeSingleton tss = ThreadSafeSingleton.Instance;

            tss.Test();

            ThreadSafeSingleton1 tss1 = ThreadSafeSingleton1.Instance;

            tss1.Test();

            //Thread Safe Singleton without using locks and no lazy instantiation
            ThreadSafeSingletonNoLocksNoLazy tnl = ThreadSafeSingletonNoLocksNoLazy.Instance;

            tnl.Test();

            LazySingleton ls = LazySingleton.Instance;

            ls.Test();

            //using .NET 4's Lazy<T> type
            LazyClassSingleton lcs = LazyClassSingleton.Instance;

            lcs.Test();

            //Object Pooling in .Net
            Factory f  = new Factory();
            Student s1 = f.GetStudentObject();

            s1.FirstName = "BHawna"; s1.LastName = "deonani";
            Console.WriteLine("First object: {0}, {1}: ", s1.FirstName, s1.LastName);
            Student s2 = f.GetStudentObject();

            s2.FirstName = "Darwin"; s2.LastName = "Rajpal";
            Console.WriteLine("Second Object: {0}, {1}: ", s2.FirstName, s2.LastName);
            Student s3 = f.GetStudentObject();

            if (s3.FirstName == null && s3.LastName == null)
            {
                s3.FirstName = "Nyra"; s3.LastName = "Darwin Rajpal";
            }
            Console.WriteLine("Third Object: {0}, {1}: ", s3.FirstName, s3.LastName);
            Student s4 = f.GetStudentObject();

            if (s4.FirstName == null && s4.LastName == null)
            {
                s4.FirstName = "N"; s4.LastName = "DR";
            }
            Console.WriteLine("Fourth Object: {0}, {1}: ", s4.FirstName, s4.LastName);
            Student s5 = f.GetStudentObject();

            if (s5.FirstName == null && s5.LastName == null)
            {
                s5.FirstName = "Hello"; s5.LastName = "World";
            }
            Console.WriteLine("Fifth Object: {0}, {1}: ", s5.FirstName, s5.LastName);


            // ACtionFuncPredicate Demo

            ActionFuncPredicate afp = new ActionFuncPredicate();

            Action <int> action = new Action <int>(afp.ActionMethod);

            action.Invoke(100);

            Func <int, int, int> func = new Func <int, int, int>(afp.FuncMethodSum);

            func.Invoke(2, 3);

            Predicate <int> predicate = new Predicate <int>(afp.IsPositive);

            predicate.Invoke(3);
            predicate.Invoke(-234);

            //Generics Demo (provides typesafety, performance, and code reuse)
            GenericsDemo gd = new GenericsDemo();
            int          a12 = 3, b12 = 4;
            string       str1 = "bhawna", str2 = "deonani";

            gd.Swap(ref a12, ref b12);
            gd.Swap(ref str1, ref str2);

            gd.ReverseUsingStack();

            //MultithreadingDemo
            Console.WriteLine("Main method");
            MultithreadingDemo md1 = new MultithreadingDemo();
            int    a222            = 10;
            Thread t   = new Thread(new ParameterizedThreadStart(md1.Method));
            Thread t21 = new Thread(new ParameterizedThreadStart(md1.Method));

            t.Start(a222);
            t21.Start(a222);

            Thread[] tArr = new Thread[5];
            for (int i = 0; i < tArr.Length; i++)
            {
                tArr[i] = new Thread(new ThreadStart(md1.Calculate));
                Console.WriteLine("Working from Thread: {0}", i);
                tArr[i].Name = i.ToString();
            }

            foreach (Thread ttt in tArr)
            {
                ttt.Start();
            }

            for (int i = 0; i < 4; i++)
            {
                Thread tmutex = new Thread(new ThreadStart(MultithreadingDemo.MutexDemo));
                tmutex.Name = string.Format("Thread {0} :", i + 1);
                tmutex.Start();
            }

            //Semaphore demo
            for (int i = 0; i < 5; i++)
            {
                Thread abc = new Thread(new ParameterizedThreadStart(MultithreadingDemo.SemphoreDemo));
                abc.Start(i);
            }



            Console.ReadLine();
        }