Пример #1
0
        public IActionResult Privacy()
        {
            var lib = new ClassTest();

            ViewBag.Msg = lib.GetMessage();
            return(View());
        }
Пример #2
0
        public static void ExecuteExample()
        {
            //In this example, we must to explicitly cast the object in the return
            Stack s = new Stack();

            s.Push(new ClassTest());
            ClassTest c = (ClassTest)s.Pop(); //casting (performance penalty)

            //Here, we have a boxing ocurring when adding a value type
            //and an unboxing when retrieving
            s.Push(3);
            int i = (int)s.Pop();

            //The Stack accepts instances different classes, all derived from object
            //However, if you try casting in a different you, you will have an exception at runtime
            s.Push(new ClassTest());
            AnotherClassTest c2 = (AnotherClassTest)s.Pop(); //InvalidCastException

            //using generics, you ensure the type you are adding (no cast needed)
            Stack <ClassTest> s2 = new Stack <ClassTest>();

            s2.Push(new ClassTest());
            ClassTest c3 = s2.Pop(); //no cast

            //Now, if your stack is of type ClassTest, you will have a type error at compile time
            //AnotherClassTest c4 = (AnotherClassTest)s2.Pop(); //Design type error

            //Creating a Stack of type int, it'll not incur in boxing/unboxing.
            //Now, the value type is saved directly in the array, not the pointer to a reference type (object)
            Stack <int> s3 = new Stack <int>();

            s3.Push(3);
            int x = s3.Pop();
        }
Пример #3
0
        public void ClassTestHelloWorldReturnNotEmptyNUnitTestLongTestName()
        {
            var target = new ClassTest();
            var actual = target.HelloWorld();

            Assert.That(actual, Does.Match(@"^Hello\susers\sof\s(?<AppName>[A-Za-z]*){1};"), "Wrong string returned"); //NUnit
        }
Пример #4
0
 void ChangeClassStringByRef(ref ClassTest strClass)
 {
     Debug.Log("ChangeClassStringByRef Before: " + strClass.name);
     strClass      = new ClassTest();
     strClass.name = "ChangeString";
     Debug.Log("ChangeClassStringByRef After: " + strClass.name);
 }
Пример #5
0
    void Start()
    {
        Debug.Log("Start");
        index = 0;

        StartCoroutine(PerFrameLoad());

        string    testStr   = "testStr";
        ClassTest testClass = new ClassTest();

        testClass.name = "testClass.name";
        ChangeString(testStr);
        Debug.Log("Start|ChangeString:" + testStr);

        ChangeClassString(testClass);
        Debug.Log("Start|ChangeClassString:" + testClass.name);

        ChangeStringByRef(ref testStr);
        Debug.Log("Start|ChangeStringByRef:" + testStr);

        ChangeClassStringByRef(ref testClass);
        Debug.Log("Start|ChangeClassStringByRef:" + testClass.name);

        PerFrameLoad();
        LOG.Log("after PerFrameLoad");
    }
Пример #6
0
        public static void ExecuteExample()
        {
            //is pattern
            var input = 12;

            if (input is int count)
            {
                Console.WriteLine(count);
            }

            ClassTest classTest = null;

            if (classTest is null)
            {
                classTest = new ClassTest();
                Console.WriteLine("ClassTest is not null anymore");
            }

            //case pattern, with input of type int = 12
            switch (input)
            {
            case int n when n > 100:
                Console.WriteLine("Value of n is more than 100.");
                break;

            case int n when n <= 100:
                Console.WriteLine("Value of n is less than 100.");
                break;

            default:
                Console.WriteLine("value not found");
                break;
            }
        }
        public void TestMethod1()
        {
            ClassTest test = new ClassTest();
            var       a    = test.Test();

            Assert.AreEqual(Convert.ToDecimal(a[2]), 6000m);
        }
Пример #8
0
        public void ClassTestHelloWorldReturnNotEmptyMsTestTestLongTestName()
        {
            ClassTest target = new ClassTest();
            string    actual = target.HelloWorld();

            Assert.IsTrue(!string.IsNullOrEmpty(actual), "Empty string returned");
        }
Пример #9
0
 public HomeController(IOptions <ClassTest> test, DataBase DB, IOptions <indentity> options, ActionFilter filter)
 {
     TTT       = test.Value;
     db        = DB;
     indentity = options.Value;
     context   = filter;
 }
        public static void ExecuteExample()
        {
            var number  = 10;        //implicit typed
            int number2 = 10;        //explicit typed

            var x = new ClassTest(); //x is an instance of ClassTest
        }
Пример #11
0
        /// <summary>
        /// 添加考试班级
        /// </summary>
        /// <param name="clsTest">考试班级</param>
        /// <returns></returns>
        public bool AddClassTest(ClassTest clsTest)
        {
            _db.ClassTests.Add(clsTest);
            var result = _db.SaveChanges();

            return(result > 0);
        }
Пример #12
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnEdit_Click(object sender, EventArgs e)
        {
            try
            {
                if (_selectID > 0)
                {
                    var clsTest = new ClassTest();
                    clsTest.ID         = _selectID;
                    clsTest.ClassID    = Convert.ToInt32(cmbClass.SelectedValue);
                    clsTest.TestID     = Convert.ToInt32(cmbTest.SelectedValue);
                    clsTest.IsValidate = chbIsValidate.Checked;

                    if (_classTestRepository.ModifyClassTest(clsTest))
                    {
                        ClearData();
                        dgvData.DataSource = _classTestRepository.GetClassTests();
                    }
                    else
                    {
                        MessageBox.Show("修改失败!");
                    }
                }
                else
                {
                    MessageBox.Show("请双击选择!");
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
Пример #13
0
 public IActionResult add([FromBody] ClassTest test)
 {
     db.Add(new ClassTest()
     {
         Name = test.Name, Lastname = test.Lastname
     });
     db.SaveChanges();
     return(Ok());
 }
Пример #14
0
        public void AFillTest()
        {
            var buffer = new MpmcRingBuffer <ClassTest>(0x10);
            var value  = new ClassTest();

            for (long i = 0; i < 0x10; i++)
            {
                Assert.IsTrue(buffer.Offer(value));
            }
            Assert.IsFalse(buffer.Offer(value));
        }
Пример #15
0
        private void загрузитьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string fname = "";

            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Title = "Открыть";
            //dialog.InitialDirectory = (string)value;
            dialog.Filter = "Файл теста (*.tst)|*.tst";
            //openFileDialog1.FilterIndex = 2;
            //openFileDialog1.RestoreDirectory = true;
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                fname = dialog.FileName;
                dialog.Dispose();
            }
            else
            {
                dialog.Dispose();
                return;
            }


            try
            {
                Selection.ResetControl(null);

                ClassTest tttt = ClassTest.DeSerialBinary(fname);

                for (int i = 0; i < tttt.ListQuestions.Count; i++)
                {
                    tttt.ListQuestions[i].DeSerializeQuestion(Selection);
                }

                // Удаление старого объекта тест

                Test = tttt;

                propertyGrid2.SelectedObject = Test;

                BindingSource binding1;
                binding1               = new BindingSource();
                binding1.DataSource    = Test.ListQuestions;
                listBox1.DisplayMember = "EcranName";
                listBox1.DataSource    = binding1;
                listBox1.SelectedIndex = -1;
                listBox1.SelectedIndex = 0;
            }
            catch (Exception eee)
            {
                MessageBox.Show(eee.Message);
            }
        }
Пример #16
0
        public void RemoveClassTest_Default_ReturnClass(int result)
        {
            var clsTest = new ClassTest {
                ID = 111
            };

            _dbMock.Setup(db => db.ClassTests.Find(clsTest.ID)).Returns(value: new ClassTest());
            _dbMock.Setup(db => db.SaveChanges()).Returns(value: result);
            var backResult = _classTestRepository.RemoveClassTest(111);

            Assert.Equal(result == 1, backResult);
        }
Пример #17
0
        public IActionResult grase([FromBody] ClassTest c)
        {
            int       f  = 4;
            int       d  = 5;
            ClassTest c1 = new ClassTest();

            c1.Name     = c.Name;
            c1.Lastname = c.Lastname;
            db.Classes.Add(c);
            db.SaveChanges();
            return(Ok());
        }
        public ActionResult Test()
        {
            ClassTest c1 = new ClassTest
            {
                Id        = 1,
                FirstName = "qqqq"
            };

            cache.Write <ClassTest>("c1", c1);
            ClassTest c1temp = cache.Read <ClassTest>("c1");

            return(Content(c1temp.FirstName));
        }
Пример #19
0
        static void Main(string[] args)
        {
            SdkVersion();
            //Test();
            //TestKill(2203);//现在就想实验这个
            ManagerMessage manager = new ManagerMessage();

            MakeRun("", ref manager);

            string str = ClassTest.SayHello();


            Console.WriteLine("Hello World!" + str);

            Console.ReadLine();
        }
Пример #20
0
 public IActionResult grase2([FromBody] ClassTest test)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Classes.Add(test);
             db.SaveChanges();
             return(Ok());
         }
         return(BadRequest(ModelState));
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #21
0
        /// <summary>
        /// 修改考试班级
        /// </summary>
        /// <param name="clsTest">考试班级</param>
        /// <returns></returns>
        public bool ModifyClassTest(ClassTest clsTest)
        {
            var oldClsTest = _db.ClassTests.Find(clsTest.ID);

            if (oldClsTest == null)
            {
                throw new Exception($"查询不到ID为{clsTest.ID}的考试班级");
            }
            else
            {
                oldClsTest.TestID     = clsTest.TestID;
                oldClsTest.ClassID    = clsTest.ClassID;
                oldClsTest.IsValidate = clsTest.IsValidate;

                var result = _db.SaveChanges();
                return(result > 0);
            }
        }
Пример #22
0
        public void DrainTest()
        {
            var buffer = new MpmcRingBuffer <ClassTest>(0x100);

            var goThrough    = 10000;
            var threadCount  = 5;
            var writeThreads = new Thread[threadCount];
            var readThreads  = new Thread[threadCount];
            var value        = new ClassTest();

            for (var i = 0; i < threadCount; i++)
            {
                writeThreads[i] = new Thread((obj) =>
                {
                    for (var j = 0; j < goThrough; j++)
                    {
                        buffer.Offer(value);
                    }
                });
                readThreads[i] = new Thread((obj) =>
                {
                    for (var j = 0; j < goThrough; j++)
                    {
                        buffer.Drain((me) =>
                        {
                        }, 100);
                    }
                });
            }

            for (var i = 0; i < threadCount; i++)
            {
                writeThreads[i].Start();
                readThreads[i].Start();
            }

            for (var i = 0; i < threadCount; i++)
            {
                writeThreads[i].Join();
                readThreads[i].Join();
            }
        }
        public void TestCountOne()
        {
            var repository = new MongoRepository<ClassTest>(Configuration.TestCollection);

            var classTest = new ClassTest()
                {
                    IntProperty = 10,
                    ChildClassTests = new List<ChildClassTest>()
                        {
                            new ChildClassTest() {StringProperty = "first string"},
                            new ChildClassTest() {StringProperty = "second string"}
                        }
                };

            repository.Add(classTest);

            var count = repository.Count();

            Assert.AreEqual(1, count);
        }
Пример #24
0
        private void Form1_Shown(object sender, EventArgs e)
        {
            Selection = new ControlSelection(panel2, propertyGrid1, propertyGrid3, propertyGrid2, listBox1, null, contextMenuStrip1);

            ArrayCreate = new ArrayCreateElement();
            ArrayCreate.Add(null);
            ArrayCreate.Add(new CreateElementButton());
            ArrayCreate.Add(new CreateElementRichTextBox());
            ArrayCreate.Add(new CreateElementRadioButton());
            ArrayCreate.Add(new CreateElementCheckBox());
            ArrayCreate.Add(new CreateElementTextBox());
            ArrayCreate.Add(new CreateElementPictureBox());
            ArrayCreate.Add(new CreateElementLabel());

            radioButtonPanel0.Text = "";
            radioButtonPanel1.Text = ArrayCreate[1].ToString();
            radioButtonPanel2.Text = ArrayCreate[2].ToString();
            radioButtonPanel3.Text = ArrayCreate[3].ToString();
            radioButtonPanel4.Text = ArrayCreate[4].ToString();
            radioButtonPanel5.Text = ArrayCreate[5].ToString();
            radioButtonPanel6.Text = ArrayCreate[6].ToString();
            radioButtonPanel7.Text = ArrayCreate[7].ToString();

            Test = new ClassTest();
            Test.AddQuestion();

            propertyGrid2.SelectedObject = Test;

            BindingSource binding1;

            binding1               = new BindingSource();
            binding1.DataSource    = Test.ListQuestions;
            listBox1.DisplayMember = "EcranName";
            listBox1.DataSource    = binding1;

            this.Height               = 900;
            this.Location             = new Point(50, 50);
            tabControl1.SelectedIndex = 3;
        }
        public void TestPush()
        {
            ClassTest classTest = new ClassTest();

            classTest.PushToCloud(true, "1004");
        }
Пример #26
0
 void ResetTest(ClassTest test)
 {
     Test = test;
 }
Пример #27
0
 public void ClassTestHelloWorldReturnNotEmptyXUnitTestLongTestName()
 {
     var target = new ClassTest();
     var actual = target.HelloWorld();
     Assert.Contains("Hello users", actual, StringComparison.OrdinalIgnoreCase);
 }
Пример #28
0
        protected void okButton_Click(object sender, EventArgs e)
        {
//  ========================  These are all from within this class (Default)  ========================
            // method with a type (return value, int in this case) - CANNOT access resultLabel


            int test = runTest(); resultLabel.Text = string.Format("runTest() = : {0}<br/>", test);

            //returns:  runTest() = : 17
            // PUBLIC INT runTest(): returns testA =IRRELEVANT ...
            // just a formula of what to do with LOCAL/DEFAULT class var "int test"


            runTest2(); // PRIVATE VOID runTest2(): when called prints out the value FROM WITHIN the method
            // printing is output from the method (void):  runTest2(): 16


            runTest3();
            resultLabel.Text += string.Format("runTest3(): {0}<br/>", test3);
            // returns: runTest3(): 15
            // PRIVATE VOID runTest3(): used a DEFAULT CLASS VAR inside the method so it could be printed here
            // could have been printed inside the method
            // ** called public int runTest4 and passed its var value = [ runTest4(test3) ]


            test              = runTest4(test3);
            resultLabel.Text += string.Format("runTest4(): {0} +var test3: {1}<br/>", test, test3);
            // returns:  runTest4(): 20 +var test3: 15
            // ** PUBLIC INT runTest4(int test3): returns testsomething4 =IRRELEVANT= formula of what to do with "test3"
            // ALLOWS ACCESS to a PRIVATE VOID var!!
            // int test declared above


//  ========================  These are all from OUTSIDE this class (ClassTest)  ========================


            ClassTest classTest = new ClassTest();
            //classTest is just a handle to the class = to be accessible - class ClassTest methods MUST be public


            int newTest = classTest.runClassTest();

            resultLabel.Text += string.Format("classTest1: {0}<br/>", newTest);
            // returns:  classTest1: 40     --  "newTest" locally decalred var
            // PUBLIC INT runClassTest(): return names in method IRRELEVANT = just a formula for an INT


            int catAge = 7;

            resultLabel.Text += string.Format("Senge age test: {0}<br/>", classTest.xtraCredit(catAge));
            // returns:  Senge age test: 56
            // PUBLIC INT xtraCredit(int SengeAge):  SengeAge=IRRELEVANT, example for formula to return INT
            // local var catAge replaces method var SengeAge TO GET THIS TO WORK


            resultLabel.Text += string.Format("v.2.Senge age test: {0}<br/>", classTest.xtraCredit(8));
            // returns:  v.2.Senge age test: 64
            // SAME PUBLIC INT xtraCredit(int SengeAge): as above - but actual int entered instead of local var



// ========== This is a PUBLIC VOID/ PUBLIC INT ***COMBO***
            // -- !! uses class property to get value out



            int voidPrep = classTest.PreVoidMethod();

            // PUBLIC INT PreVoidMethod(): assigns & returns a var of 800
            classTest.VoidMethod2(voidPrep);
            // PUBLIC VOID VoidMethod2(int voidCredit): second method adds 8 to 800 from first method
            // the trick is how to access the new value ...
            resultLabel.Text += string.Format("Outside class Static VOID: {0} or? {1}<br/>",
                                              voidPrep, classTest.MyProp);
            // returns:  Outside class Static VOID: 800 or? 808
            // PUBLIC VOID VoidMethod(int voidCredit):  int voidCredit=IRRELEVANT - just a formula
            // local var voidPrep stays at 800 ... to get VOID result out
            // use a class property from the same class:

            /*  public void VoidMethod2(int voidCredit)
             *  {   voidCredit += 8;
             *  this.MyProp += voidCredit;      } // using a prop to get a value out */



//  ========================  These are STATIC methods   ========================



            // *INSIDE* class method used =====

            int creditDefault = 14;

            creditDefault = SameClassCredit(creditDefault);
            // PUBLIC STATIC INT SameClassCredit(int creditSameClass) ... adds 1000 to creditDefault
            resultLabel.Text += string.Format("Same class Static: {0}<br/>", creditDefault);
            // returns:  Same class Static: 1014
            // PUBLIC STATIC INT SameClassCredit(int creditSameClass):  int creditSameClass = IRRELEVANT, =formula



            // *OUTSIDE* class method used =====

            creditDefault = 5;
            creditDefault = ClassTest.xtraCreditOutsideClass(creditDefault);
            // needed extra step to access - NOTICE CLASS NAME -NOT- handle name (classTest)
            resultLabel.Text += string.Format("Outside class Static: {0}<br/>", creditDefault);
            // returns:  Outside class Static: 105
            // PUBLIC STATIC INT xtraCreditOutsideClass(int credit):  int credit is IRRELEVANT; just formula
        }
Пример #29
0
 public void InitTest(ClassTest test)
 {
     Test       = test;
     Index      = 0;
     ResultData = 0;
 }
Пример #30
0
        public void ContentHolder_Test1()
        {
            string strData = "A bit fat hairy bloke.";
            ContentHolder<string> stringHolder = new ContentHolder<string>(strData);
            ContentHolder<string> stringHolderds = (ContentHolder<string>)stringHolder.Clone();

            byte[] blob1 = new byte[1000];
            ContentHolder<byte[]> byteHolder1 = new ContentHolder<byte[]>(blob1);
            ContentHolder<byte[]> byteHolder1ds = (ContentHolder<byte[]>)byteHolder1.Clone();

            byte[] blob2 = new byte[1000];
            blob2[0] = 3;
            ContentHolder<byte[]> byteHolder2 = new ContentHolder<byte[]>(blob2);
            ContentHolder<byte[]> byteHolder2ds = (ContentHolder<byte[]>)byteHolder2.Clone();

            StructTest t1 = new StructTest() { Data = "78", Count = 8 };
            ContentHolder<StructTest> byteHolder3 = new ContentHolder<StructTest>(t1);
            ContentHolder<StructTest> byteHolder3ds = (ContentHolder<StructTest>)byteHolder3.Clone();

            ClassTest t2 = new ClassTest() { Data = "78", Count = 8 };
            ContentHolder<ClassTest> byteHolder4 = new ContentHolder<ClassTest>(t2);
            ContentHolder<ClassTest> byteHolder4ds = (ContentHolder<ClassTest>)byteHolder4.Clone();

        } 
Пример #31
0
 public void ClassTestGetCustomersReturnNotEmptyXUnitTest()
 {
     var target = new ClassTest();
     var actual = target.GetCustomers();
     Assert.True(actual.Count == 0, "Customer list is not empty");
 }