public IHttpActionResult Putsimple(int id, simple simple)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != simple.Id)
            {
                return(BadRequest());
            }

            db.Entry(simple).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!simpleExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public void DivadedShouldReturnProperValue(double number1, double numer2, double result)
        {
            var simple = new simple();

            var calculatedResult = simple.Divaded(number1, numer2);

            calculatedResult.Should().Be(result);
        }
        public void DivadedShouldReturnArgumentExceptionWhenSecondNumberIsZero()
        {
            var simple = new simple();

            Action calculateAct = () => simple.Divaded(2, 0);

            calculateAct.Should().Throw <ArgumentException>();
        }
        public void ThrowExceptionTest()
        {
            var simple = new simple();

            Action act = () => simple.ThrowExcpetion();

            act.Should().Throw <Exception>();
        }
        public void SumNumbersShouldReturnSum(double[] numbers, double result)
        {
            var simple = new simple();

            var calculatedResult = simple.SumNumbers(numbers);

            calculatedResult.Should().Be(result);
        }
Beispiel #6
0
 public complex(double d, string str, bool b, double[] da, simple s)
 {
     this.dbl      = d;
     this.str      = str;
     this.b        = b;
     this.dblArray = da;
     this.inside   = s;
     this.json     = null;
 }
        public void CalulateDaysShouldReturnDaysBeetwenTwoDates(int year1, int month1, int day1, int year2, int month2, int day2, int result)
        {
            var date1  = new DateTime(year1, month1, day1);
            var date2  = new DateTime(year2, month2, day2);
            var simple = new simple();

            var calculateResult = simple.CalculateDays(date1, date2);

            calculateResult.Should().Be(result);
        }
 public complex(double d, string str, bool b, double[] da, simple s)
 {
     this.dbl      = d;
     this.str      = str;
     this.b        = b;
     this.dblArray = da;
     this.inside   = s;
     this.json     = null;
     this.id       = Guid.NewGuid().ToString();
     this.pk       = "Test";
 }
        public IHttpActionResult Getsimple(int id)
        {
            simple simple = db.simples.Find(id);

            if (simple == null)
            {
                return(NotFound());
            }

            return(Ok(simple));
        }
        public IHttpActionResult Postsimple(simple simple)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.simples.Add(simple);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = simple.Id }, simple));
        }
Beispiel #11
0
        static void Main(string[] args)
        {
            Console.WriteLine("Size int :{0}", TestSize <int> .SizeOf(1));
            Console.WriteLine("Size long :{0}", TestSize <long> .SizeOf(long.MaxValue));
            Console.WriteLine("Size int?null :{0}", TestSize <int?> .SizeOf(null));
            Console.WriteLine("Size int? :{0}", TestSize <int?> .SizeOf(2));


            Console.WriteLine("Size string[10] :{0}", TestSize <string> .SizeOf("0123456789"));

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < 100; i++)
            {
                sb.Append("0123456789");
            }
            Console.WriteLine("Size stringbulder[10*100] :{0}", TestSize <StringBuilder> .SizeOf(sb));


            sb = new StringBuilder();
            for (int i = 0; i < 100; i++)
            {
                sb.Append("わたしわたしわたしわ");
            }
            Console.WriteLine("Size stringbulder U[10*100] :{0}", TestSize <StringBuilder> .SizeOf(sb));


            Console.WriteLine("Size C:simple :{0}", TestSize <simple> .SizeOf(new simple()));
            Console.WriteLine("Size C:strings :{0}", TestSize <twostring> .SizeOf(new twostring()));
            Console.WriteLine("Size C:strings[setted]:{0}", TestSize <twostring> .SizeOf(new twostring()
            {
                a = "0123456789", b = "0123456789"
            }));
            var arrayint = new int[100];

            Console.WriteLine("Size arrayint[100] :{0}", TestSize <int[]> .SizeOf(arrayint));

            var arraysimple = new simple[3];

            Console.WriteLine("Size simple[3] :{0}", TestSize <simple[]> .SizeOf(arraysimple));

            var list = new List <int>();

            Console.WriteLine("Size list Empty :{0}", TestSize <List <int> > .SizeOf(list));
            for (int i = 0; i < 100; i++)
            {
                list.Add(i);
            }
            Console.WriteLine("Size list<int>[100] :{0}", TestSize <List <int> > .SizeOf(list));

            Console.ReadLine();
        }
Beispiel #12
0
        private void openSmallScreenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form frm in Application.OpenForms)
            {
                if (frm.Name == "simple")
                {
                    frm.Activate();
                    return;
                }
            }
            simple sfrm = new simple();

            sfrm.Show();
        }
Beispiel #13
0
        public void b7_Click(object sender, EventArgs e)
        {
            foreach (Form frm in Application.OpenForms)
            {
                if (frm.Name == "simple")
                {
                    frm.Activate();
                    return;
                }
            }
            simple sfrm = new simple();

            sfrm.Show();
        }
        public IHttpActionResult Deletesimple(int id)
        {
            simple simple = db.simples.Find(id);

            if (simple == null)
            {
                return(NotFound());
            }

            db.simples.Remove(simple);
            db.SaveChanges();

            return(Ok(simple));
        }
Beispiel #15
0
 public nested(int x, simple s)
 {
     this.x = x;
     this.s = s;
 }
Beispiel #16
0
        public void ValidateSQLTranslation()
        {
            int constInt = 2;

            int[] array = { 1, 2, 3 };
            ParameterExpression paramx = Expression.Parameter(typeof(int), "x");
            float floatValue           = 5.23f;

            const int             Records       = 100;
            Func <Random, simple> createDataObj = (random) =>
            {
                simple obj = new simple();
                obj.x  = random.Next();
                obj.y  = random.Next();
                obj.id = Guid.NewGuid().ToString();
                obj.pk = "Test";
                return(obj);
            };
            Func <bool, IQueryable <simple> > dataQuery = LinqTestsCommon.GenerateTestCosmosData <simple>(createDataObj, Records, testContainer);

            List <LinqTestInput> inputs = new List <LinqTestInput>();

            inputs.Add(new LinqTestInput("Select cast float", b => dataQuery(b).Select(x => (int)floatValue)));
            inputs.Add(new LinqTestInput("Select identity", b => dataQuery(b).Select(x => x)));
            inputs.Add(new LinqTestInput("Select int expr", b => dataQuery(b).Select(x => (x.x % 10) + 2 + (x.x % 5))));
            inputs.Add(new LinqTestInput("Select int expr w const", b => dataQuery(b).Select(x => x.x + constInt)));
            inputs.Add(new LinqTestInput("Select w new array", b => dataQuery(b).Select(d => new int[2] {
                d.x, d.x + 1
            })));
            inputs.Add(new LinqTestInput("Select new", b => dataQuery(b).Select(d => new { first = d.x, second = d.x })));
            inputs.Add(new LinqTestInput("Select nested new", b => dataQuery(b).Select(d => new { first = d.x, second = new { third = d.x } })));
            inputs.Add(new LinqTestInput("Filter int >", b => dataQuery(b).Where(x => x.x > 2)));
            inputs.Add(new LinqTestInput("Filter method >", b => dataQuery(b).Where(x => x.x > id(3))));
            inputs.Add(new LinqTestInput("Filter int > -> Select int expr", b => dataQuery(b).Where(x => x.x > 2).Select(x => x.x + 2)));
            inputs.Add(new LinqTestInput("Select int expr -> Filter int >", b => dataQuery(b).Select(x => x.x + 2).Where(x => x > 2)));
            inputs.Add(new LinqTestInput("Filter int > -> Filter another field", b => dataQuery(b).Where(x => x.x > 2).Where(y => y.x < 4)));
            inputs.Add(new LinqTestInput("Filter x -> Filter y -> Select y expr", b => dataQuery(b).Where(x => x.x > 2).Where(y => y.x < 4).Select(y => y.x + y.x)));
            inputs.Add(new LinqTestInput("Select expr w const array", b => dataQuery(b).Select(x => x.x + array[2])));
            inputs.Add(new LinqTestInput("Select const array index", b => dataQuery(b)
                                         .Where(x => x.x >= 0 && x.x < 3)
                                         .Select(x => new int[] { 1, 2, 3 }[x.x])));
            inputs.Add(new LinqTestInput("Select new simple", b => dataQuery(b).Select(x => new simple {
                x = x.x, y = x.x
            })));
            inputs.Add(new LinqTestInput("Select new nested", b => dataQuery(b).Select(x => new nested {
                s = new simple {
                    x = x.x, y = x.x
                }, x = 2
            })));
            inputs.Add(new LinqTestInput("Select new complex", b => dataQuery(b).Select(d => new complex {
                dbl = 1.0, str = "", b = false, dblArray = new double[] { 1.0, 2.0, }, inside = new simple {
                    x = d.x, y = d.x
                }
            })));
            inputs.Add(new LinqTestInput("Select cast double x", b => dataQuery(b).Select(x => (double)x.x)));
            inputs.Add(new LinqTestInput("Select indexer x", b => dataQuery(b)
                                         .Where(x => x.x >= 0 && x.x < array.Length)
                                         .Select(x => array[x.x])));
            inputs.Add(new LinqTestInput("Select new constructor", b => dataQuery(b).Select(x => new TimeSpan(x.x))));
            inputs.Add(new LinqTestInput("Select method id", b => dataQuery(b).Select(x => id(x))));
            inputs.Add(new LinqTestInput("Select identity", b => dataQuery(b).Select(x => x)));
            inputs.Add(new LinqTestInput("Select simple property", b => dataQuery(b).Select(x => x.x)));
            this.ExecuteTestSuite(inputs);
        }
 public string UseArrayOfStruct(simple[] myarr)
 {
   return "";
 }
Beispiel #18
0
        public void ValidateSQLTranslation()
        {
            int constInt = 2;

            int[] array      = { 1, 2, 3 };
            var   paramx     = Expression.Parameter(typeof(int), "x");
            float floatValue = 5.23f;

            const int             Records       = 100;
            Func <Random, simple> createDataObj = (random) =>
            {
                var obj = new simple();
                obj.x = random.Next();
                obj.y = random.Next();
                return(obj);
            };
            var dataQuery = LinqTestsCommon.GenerateTestData <simple>(createDataObj, Records, client, testCollection);

            var inputs = new List <LinqTestInput>();

            inputs.Add(new LinqTestInput("Select cast float", b => dataQuery(b).Select(x => (int)(floatValue))));
            inputs.Add(new LinqTestInput("Select identity", b => dataQuery(b).Select(x => x)));
            inputs.Add(new LinqTestInput("Select int expr", b => dataQuery(b).Select(x => x.x % 10 + 2 + x.x % 5)));
            inputs.Add(new LinqTestInput("Select int expr w const", b => dataQuery(b).Select(x => x.x + constInt)));
            inputs.Add(new LinqTestInput("Select w new array", b => dataQuery(b).Select(d => new int[2] {
                d.x, d.x + 1
            })));
            inputs.Add(new LinqTestInput("Select new", b => dataQuery(b).Select(d => new { first = d.x, second = d.x })));
            inputs.Add(new LinqTestInput("Select nested new", b => dataQuery(b).Select(d => new { first = d.x, second = new { third = d.x } })));
            inputs.Add(new LinqTestInput("Filter int >", b => dataQuery(b).Where(x => x.x > 2)));
            inputs.Add(new LinqTestInput("Filter method >", b => dataQuery(b).Where(x => x.x > id(3))));
            inputs.Add(new LinqTestInput("Filter int > -> Select int expr", b => dataQuery(b).Where(x => x.x > 2).Select(x => x.x + 2)));
            inputs.Add(new LinqTestInput("Select int expr -> Filter int >", b => dataQuery(b).Select(x => x.x + 2).Where(x => x > 2)));
            inputs.Add(new LinqTestInput("Filter int > -> Filter another field", b => dataQuery(b).Where(x => x.x > 2).Where(y => y.x < 4)));
            inputs.Add(new LinqTestInput("Filter x -> Filter y -> Select y expr", b => dataQuery(b).Where(x => x.x > 2).Where(y => y.x < 4).Select(y => y.x + y.x)));
            inputs.Add(new LinqTestInput("Select expr w const array", b => dataQuery(b).Select(x => x.x + array[2])));
            inputs.Add(new LinqTestInput("Select const array index", b => dataQuery(b)
                                         .Where(x => x.x >= 0 && x.x < 3)
                                         .Select(x => new int[] { 1, 2, 3 }[x.x]), "The specified query includes 'member indexer' which is currently not supported."));
            inputs.Add(new LinqTestInput("Select new simple", b => dataQuery(b).Select(x => new simple {
                x = x.x, y = x.x
            })));
            inputs.Add(new LinqTestInput("Select new nested", b => dataQuery(b).Select(x => new nested {
                s = new simple {
                    x = x.x, y = x.x
                }, x = 2
            })));
            inputs.Add(new LinqTestInput("Select new complex", b => dataQuery(b).Select(d => new complex {
                dbl = 1.0, str = "", b = false, dblArray = new double[] { 1.0, 2.0, }, inside = new simple {
                    x = d.x, y = d.x
                }
            })));
            inputs.Add(new LinqTestInput("Select cast double x", b => dataQuery(b).Select(x => (double)x.x)));
            inputs.Add(new LinqTestInput("Select indexer x", b => dataQuery(b)
                                         .Where(x => x.x >= 0 && x.x < array.Length)
                                         .Select(x => array[x.x]), "The specified query includes 'member indexer' which is currently not supported."));
            inputs.Add(new LinqTestInput("Select new constructor", b => dataQuery(b).Select(x => new TimeSpan(x.x)), "Constructor invocation is not supported."));
            inputs.Add(new LinqTestInput("Select method id", b => dataQuery(b).Select(x => id(x)), "Method 'id' is not supported."));
            inputs.Add(new LinqTestInput("Select identity", b => dataQuery(b).Select(x => x)));
            inputs.Add(new LinqTestInput("Select simple property", b => dataQuery(b).Select(x => x.x)));
            this.ExecuteTestSuite(inputs);
        }
Beispiel #19
0
 => dateRule is DateSimpleRule simple?nameof(Type).WriteValueProperty(nameof(DateSimpleRule)).Then(nameof(DateRule).WriteObjectProperty(simple, WriteDateSimpleRule))(writer)