Inheritance: MonoBehaviour
    static void Main(string[] args)
    {
        something s = new something();

        s.DoIt(10);
        Console.Write(s.testCount);
    }
Exemplo n.º 2
0
        public void TestComparer()
        {
            var s1 = new something {
                Thing = 4, Stuff = "tests"
            };
            var s2 = new something {
                Thing = 7, Stuff = "testS"
            };

            Assert.AreEqual(-1, new CustomComparer <something>((a, b) => a.Thing.CompareTo(b.Thing)).Compare(s1, s2));
            Assert.AreEqual(-1, CustomComparer <something> .By(s => s.Thing).Compare(s1, s2));
            Assert.AreEqual(-1, CustomComparer <something> .By(s => s.Stuff).Compare(s1, s2));
            Assert.AreEqual(0, CustomComparer <something> .By(s => s.Stuff, StringComparer.OrdinalIgnoreCase).Compare(s1, s2));
            Assert.AreEqual(0, CustomComparer <something> .By(s => s.Stuff, ignoreCase: true).Compare(s1, s2));
            Assert.AreEqual(-1, CustomComparer <something> .By(s => s.Stuff, ignoreCase: false).Compare(s1, s2));
            Assert.AreEqual(-1, CustomComparer <something> .By(s => s.Stuff, (a, b) => string.Compare(a, b)).Compare(s1, s2));

            Assert.AreEqual(-1, CustomComparer <something> .By(s => s.Stuff, ignoreCase: true).ThenBy(s => s.Thing).Compare(s1, s2));
            Assert.AreEqual(1, CustomComparer <something> .By(s => s.Stuff, ignoreCase: true).ThenBy(s => - s.Thing).Compare(s1, s2));
            Assert.AreEqual(0, CustomComparer <something> .By(s => s.Stuff, ignoreCase: true).ThenBy(s => 25).Compare(s1, s2));
            Assert.AreEqual(-1, CustomComparer <something> .By(s => s.Stuff, ignoreCase: false).ThenBy(s => - s.Thing).Compare(s1, s2));

            // a bit incomplete: not testing all the ThenBy overloads
            // a lot incomplete: CustomEqualityComparer tests
        }
Exemplo n.º 3
0
        public ActionResult DeleteConfirmed(int id)
        {
            something something = db.something.Find(id);

            db.something.Remove(something);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "somethingid,someName,someIDNumber")] something something)
 {
     if (ModelState.IsValid)
     {
         db.Entry(something).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(something));
 }
Exemplo n.º 5
0
        public ActionResult Create([Bind(Include = "somethingid,someName,someIDNumber")] something something)
        {
            if (ModelState.IsValid)
            {
                db.something.Add(something);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(something));
        }
Exemplo n.º 6
0
        // GET: something/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            something something = db.something.Find(id);

            if (something == null)
            {
                return(HttpNotFound());
            }
            return(View(something));
        }
Exemplo n.º 7
0
        public void TestComparer()
        {
            var s1 = new something { Thing = 4, Stuff = "tests" };
            var s2 = new something { Thing = 7, Stuff = "testS" };
            Assert.AreEqual(-1, new CustomComparer<something>((a, b) => a.Thing.CompareTo(b.Thing)).Compare(s1, s2));
            Assert.AreEqual(-1, CustomComparer<something>.By(s => s.Thing).Compare(s1, s2));
            Assert.AreEqual(-1, CustomComparer<something>.By(s => s.Stuff).Compare(s1, s2));
            Assert.AreEqual(0, CustomComparer<something>.By(s => s.Stuff, StringComparer.OrdinalIgnoreCase).Compare(s1, s2));
            Assert.AreEqual(0, CustomComparer<something>.By(s => s.Stuff, ignoreCase: true).Compare(s1, s2));
            Assert.AreEqual(-1, CustomComparer<something>.By(s => s.Stuff, ignoreCase: false).Compare(s1, s2));
            Assert.AreEqual(-1, CustomComparer<something>.By(s => s.Stuff, (a, b) => string.Compare(a, b)).Compare(s1, s2));

            Assert.AreEqual(-1, CustomComparer<something>.By(s => s.Stuff, ignoreCase: true).ThenBy(s => s.Thing).Compare(s1, s2));
            Assert.AreEqual(1, CustomComparer<something>.By(s => s.Stuff, ignoreCase: true).ThenBy(s => -s.Thing).Compare(s1, s2));
            Assert.AreEqual(0, CustomComparer<something>.By(s => s.Stuff, ignoreCase: true).ThenBy(s => 25).Compare(s1, s2));
            Assert.AreEqual(-1, CustomComparer<something>.By(s => s.Stuff, ignoreCase: false).ThenBy(s => -s.Thing).Compare(s1, s2));

            // a bit incomplete: not testing all the ThenBy overloads
            // a lot incomplete: CustomEqualityComparer tests
        }
 public HomeController(something sth)
 {
     _sth = sth;
 }