public void AddIn_Should_Return_True_On_Adding_New_Code()
        {
            const int One = 0x0001;
            var table = new TestTable();

            table.AddIn(One, "One").Should().BeTrue();
        }
        public void AddOut_Should_Return_True_On_Adding_New_Label()
        {
            const int One = 0x0001;
            var table = new TestTable();

            table.AddOut("One", One).Should().BeTrue();
        }
        public void AddOut_Should_Throw_On_Empty_Label()
        {
            var table = new TestTable();

            table
                .Invoking(t => t.AddOut("", 0x0000))
                .ShouldThrow<ArgumentException>();
        }
        public void AddIn_Should_Throw_On_Null_Label()
        {
            var table = new TestTable();

            table
                .Invoking(t => t.AddIn(0x0000, null))
                .ShouldThrow<ArgumentNullException>();
        }
Beispiel #5
0
 public void TablesCanCreateDataTablesWithSubsetOfColumns()
 {
     TestTable t = new TestTable();
     DataTable dt = t.CreateDataTable(t.StringColumn, t.IntColumn);
     Assert.AreEqual("TestTable", dt.TableName);
     Assert.AreEqual(2, dt.Columns.Count);
     AssertDataColumn(dt.Columns[0], "StringColumn", typeof(string));
     AssertDataColumn(dt.Columns[1], "IntColumn", typeof(int));
 }
        public void AddIn_Should_Return_False_On_Adding_Existing_Code()
        {
            const int One = 0x0001;
            const string OneString = "One";

            var table = new TestTable();
            table.AddIn(One, OneString);

            table.AddIn(One, OneString).Should().BeFalse();
        }
Beispiel #7
0
 public void TablesCanCreateDataTablesWithCorrectNameAndColumns()
 {
     TestTable t = new TestTable();
     DataTable dt = t.CreateDataTable();
     Assert.AreEqual("TestTable", dt.TableName);
     Assert.AreEqual(3, dt.Columns.Count);
     AssertDataColumn(dt.Columns[0], "IntColumn", typeof(int));
     AssertDataColumn(dt.Columns[1], "StringColumn", typeof(string));
     AssertDataColumn(dt.Columns[2], "DateColumn", typeof(DateTime));
 }
        public void AddOut_Should_Return_False_On_Adding_Existing_Label()
        {
            const int One = 0x0001;
            const string OneString = "One";

            var table = new TestTable();
            table.AddOut(OneString, One);

            table.AddOut(OneString, One).Should().BeFalse();
        }
        public void ToUpper()
        {
            var db = new TestDb();

            db.CreateTable<TestTable>();
            var testTable = new TestTable()
            {
                Name = "test"
            };
            db.Insert(testTable);

            var x = db.Table<TestTable>().Where(t => t.Name.ToUpper() == "TEST");

            Assert.AreEqual(1, x.Count());
        }
Beispiel #10
0
        public ActionResult Create(TestTable model)
        {
            if (ModelState.IsValid)
            {
                var mappedresult = Mapper.Map<Models.TestTable>(model);
                var result = _testTableLogic.SaveOrUpdate(mappedresult);

                if (result.HasErrors) result.UpdateModelState(ModelState);

                if (ModelState.IsValid)
                {
                    return RedirectToAction("Index");
                }
            }
            return View(model);
        }
Beispiel #11
0
        static unsafe int Main(string[] args)
        {
            int testResult = Pass;

            if (Sse2.IsSupported)
            {
                using (TestTable <long> longTable = new TestTable <long>(new long[2] {
                    1, -5
                }, new long[2]))
                {
                    if (Environment.Is64BitProcess)
                    {
                        var vd = Sse2.ConvertScalarToVector128Int64((long)-5);
                        Unsafe.Write(longTable.outArrayPtr, vd);

                        if (!longTable.CheckResult((x, y) => (y[0] == -5) && (y[1] == 0)))
                        {
                            Console.WriteLine("SSE2 ConvertScalarToVector128Int32 failed on long:");
                            foreach (var item in longTable.outArray)
                            {
                                Console.Write(item + ", ");
                            }
                            Console.WriteLine();
                            testResult = Fail;
                        }
                    }
                    else
                    {
                        try
                        {
                            var vd = Sse2.ConvertScalarToVector128Int64(-5l);
                            testResult = Fail;
                            Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.ConvertScalarToVector128Int64)} failed: expected PlatformNotSupportedException exception.");
                        }
                        catch (PlatformNotSupportedException)
                        {
                        }
                    }
                }
            }

            return(testResult);
        }
        public async Task <int> AddTestTable(TestTable testTable)
        {
            if (db != null)
            {
                try
                {
                    await db.TestTable.AddAsync(testTable);

                    await db.SaveChangesAsync();

                    return(testTable.Id);
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
            return(0);
        }
        static unsafe int Main(string[] args)
        {
            int testResult = Pass;

            using (TestTable <ulong> ulongTable = new TestTable <ulong>(new ulong[2], new ulong[2]))
            {
                if (Sse2.X64.IsSupported)
                {
                    var vd = Sse2.X64.ConvertScalarToVector128UInt64(0xffffffff01ul);
                    Unsafe.Write(ulongTable.outArrayPtr, vd);

                    if (!ulongTable.CheckResult((x, y) => (y[0] == 0xffffffff01ul) && (y[1] == 0)))
                    {
                        Console.WriteLine("SSE2.X64 ConvertScalarToVector128Single failed on ulong:");
                        foreach (var item in ulongTable.outArray)
                        {
                            Console.Write(item + ", ");
                        }
                        Console.WriteLine();
                        testResult = Fail;
                    }
                }
                else
                {
                    try
                    {
                        var vd = Sse2.X64.ConvertScalarToVector128UInt64((ulong)5);
                        testResult = Fail;
                        Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.X64.ConvertScalarToVector128UInt64)} failed: expected PlatformNotSupportedException exception.");
                    }
                    catch (PlatformNotSupportedException)
                    {
                    }
                    catch (Exception ex)
                    {
                        testResult = Fail;
                        Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.X64.ConvertScalarToVector128UInt64)}-{ex} failed: expected PlatformNotSupportedException exception.");
                    }
                }
            }

            return(testResult);
        }
Beispiel #14
0
        public List <TestTable> GetAll()
        {
            string           vSql     = "SELECT * FROM TestTable";
            SqlCommand       vCommand = new SqlCommand(vSql, BuildConnection());
            List <TestTable> vResult  = new List <TestTable>();

            using (SqlDataReader vReader = vCommand.ExecuteReader())
            {
                while (vReader.Read())
                {
                    TestTable vRec = new TestTable();
                    vRec.TestTableId = (Guid)vReader["TestTableId"];
                    vRec.SomeInteger = (int)vReader["SomeInteger"];
                    vRec.SomeString  = (string)vReader["SomeSyr=tring"];
                    vResult.Add(vRec);
                }
            }
            return(vResult);
        }
Beispiel #15
0
        // POST api/values
        public IHttpActionResult Post(TestValue value)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid data."));
            }

            annshopDBEntities db = new annshopDBEntities();

            TestTable tt = new TestTable();

            tt.value = value.value;

            db.TestTable.Add(tt);

            db.SaveChanges();

            return(Ok());
        }
Beispiel #16
0
        public void DaoDataGetSetTest()
        {
            TestTable instance  = new TestTable();
            string    propValue = "ByProperty";

            instance.Name = propValue;
            string value      = 16.RandomLetters();
            string setValue   = instance.Value <string>("MonkeyBoy", value);
            string checkValue = instance.Value <string>("MonkeyBoy");

            Expect.AreEqual(value, checkValue);
            dynamic obj = instance.ToDynamic();

            Expect.AreEqual(value, obj.MonkeyBoy);
            dynamic jsonSafe = instance.ToJsonSafe(true);

            Expect.AreEqual(propValue, jsonSafe.Name);
            Expect.AreEqual(value, jsonSafe.MonkeyBoy);
        }
Beispiel #17
0
        /// <summary>
        /// 新增数据。必须传入姓名Name,手机号MobilePhone,身份证号IDNumber
        /// </summary>
        public BaseResult AddUser(TestTableParam param)
        {
            if (string.IsNullOrWhiteSpace(param.Name) || string.IsNullOrWhiteSpace(param.MobilePhone) ||
                string.IsNullOrWhiteSpace(param.IDNumber))
            {
                return(new BaseResult(false, null, "参数错误!"));
            }
            var model = new TestTable
            {
                Id          = Guid.NewGuid(),
                Name        = param.Name,
                IDNumber    = param.IDNumber,
                MobilePhone = param.MobilePhone,
                CreateTime  = DateTime.Now
            };
            var count = DB.MySql.Insert <TestTable>(model);

            return(new BaseResult(count > 0, count, count > 0 ? "" : "数据库受影响行数为0!"));
        }
Beispiel #18
0
        public ActionResult SubmitTestTableForm(string KeyValue, TestTable testtable, string BuildFormJson)
        {
            string        ModuleId    = DESEncrypt.Decrypt(CookieHelper.GetCookie("ModuleId"));
            IDatabase     database    = DataFactory.Database();
            DbTransaction isOpenTrans = database.BeginTrans();

            try
            {
                string Message = KeyValue == "" ? "新增成功。" : "编辑成功。";
                if (!string.IsNullOrEmpty(KeyValue))
                {
                    if (KeyValue == ManageProvider.Provider.Current().UserId)
                    {
                        throw new Exception("无权限编辑信息");
                    }
                    //base_user.Modify(KeyValue);
                    testtable.Modify(KeyValue);
                    database.Update(testtable, isOpenTrans);
                }
                else
                {
                    testtable.Create();

                    database.Insert(testtable, isOpenTrans);
                    //database.Insert(base_employee, isOpenTrans);
                    Base_DataScopePermissionBll.Instance.AddScopeDefault(ModuleId, ManageProvider.Provider.Current().UserId, testtable.TestId, isOpenTrans);
                }
                Base_FormAttributeBll.Instance.SaveBuildForm(BuildFormJson, testtable.TestId, ModuleId, isOpenTrans);
                database.Commit();
                return(Content(new JsonMessage {
                    Success = true, Code = "1", Message = Message
                }.ToString()));
            }
            catch (Exception ex)
            {
                database.Rollback();
                database.Close();
                return(Content(new JsonMessage {
                    Success = false, Code = "-1", Message = "操作失败:" + ex.Message
                }.ToString()));
            }
        }
        static unsafe int Main(string[] args)
        {
            int testResult = Pass;

            if (Sse.IsSupported)
            {
                using (TestTable <float> floatTable = new TestTable <float>(new float[4] {
                    1, -5, 100, 0
                }, new float[4] {
                    22, -1, -50, 3
                }))
                {
                    var vf1 = Unsafe.Read <Vector128 <float> >(floatTable.inArray1Ptr);
                    var vf2 = Unsafe.Read <Vector128 <float> >(floatTable.inArray2Ptr);

                    if (!Sse.CompareLessThanOrEqualUnorderedScalar(vf1, vf2))
                    {
                        Console.WriteLine("SSE CompareLessThanOrEqualUnorderedScalar failed positive test");
                        testResult = Fail;
                    }
                }

                using (TestTable <float> floatTable = new TestTable <float>(new float[4] {
                    22, -5, 100, 0
                }, new float[4] {
                    1, -1, -50, 3
                }))
                {
                    var vf1 = Unsafe.Read <Vector128 <float> >(floatTable.inArray1Ptr);
                    var vf2 = Unsafe.Read <Vector128 <float> >(floatTable.inArray2Ptr);

                    if (Sse.CompareLessThanOrEqualUnorderedScalar(vf1, vf2))
                    {
                        Console.WriteLine("SSE CompareLessThanOrEqualUnorderedScalar failed negative test");
                        testResult = Fail;
                    }
                }
            }


            return(testResult);
        }
        public void AndTest()
        {
            Expect.IsTrue(_testDatabases.Count > 0);
            string methodName            = MethodBase.GetCurrentMethod()?.Name;
            string nameStartsWith        = 4.RandomLetters();
            string descriptionStartsWith = 4.RandomLetters();

            _testDatabases.Each(db =>
            {
                Message.PrintLine("{0}.{1}: {2}", ConsoleColor.DarkYellow, this.GetType().Name, methodName, db.GetType().Name);
                TestTable one   = DataTools.CreateTestTable("{0}_{1}"._Format(nameStartsWith, 4.RandomLetters()), "{0}_{1}"._Format(descriptionStartsWith, 4.RandomLetters()), db);
                TestTable two   = DataTools.CreateTestTable("{0}_{1}"._Format(nameStartsWith, 4.RandomLetters()), "{0}_{1}"._Format(descriptionStartsWith, 4.RandomLetters()), db);
                TestTable three = DataTools.CreateTestTable(nameStartsWith, db);

                TestTableCollection results  = TestTable.Where(c => c.Name.StartsWith(nameStartsWith).And(c.Description.StartsWith(descriptionStartsWith)), db);
                TestTableCollection results2 = TestTable.Where(c => c.Name.StartsWith(nameStartsWith) && c.Description.StartsWith(descriptionStartsWith), db);
                Expect.AreEqual(2, results.Count);
                Expect.AreEqual(2, results2.Count);
            });
        }
        public void InQueryTest()
        {
            Expect.IsTrue(_testDatabases.Count > 0);
            string methodName = MethodBase.GetCurrentMethod().Name;

            _testDatabases.Each(db =>
            {
                Message.PrintLine("{0}.{1}: {2}", ConsoleColor.DarkYellow, this.GetType().Name, methodName, db.GetType().Name);
                List <TestTable> tables = new List <TestTable>();
                8.Times(i =>
                {
                    tables.Add(DataTools.CreateTestTable(4.RandomLetters(), db));
                });

                Expect.AreEqual(8, tables.Count);
                List <ulong> ids = new List <ulong>(tables.Select(t => t.Id.Value).ToArray());
                TestTableCollection retrieved = TestTable.Where(c => c.Id.In(ids.ToArray()), db);
                Expect.AreEqual(tables.Count, retrieved.Count);
            });
        }
        private TestTable GetTestTable()
        {
            var person = new EntitySet <Person>();

            person.Add(new Person()
            {
                Person1 = "test"
            });
            person.Add(new Person()
            {
                Person1 = "test2"
            });

            var table = new TestTable()
            {
                Name = "Complex", Description = "Record Insert.", Person = person
            };

            return(table);
        }
Beispiel #23
0
    public void Property_Exists__Get_Value_Is_Null__Returns_None_With_UnableToGetColumnFromAliasMsg()
    {
        // Arrange
        var table = new TestTable();
        var alias = nameof(TestTable.Foo);

        // Act
        var r0 = QueryF.GetColumnFromAlias(table, alias);
        var r1 = QueryF.GetColumnFromAlias <TestTable>(alias);

        // Assert
        var n0 = r0.AssertNone().AssertType <UnableToGetColumnFromAliasMsg>();

        Assert.Equal(table, n0.Table);
        Assert.Equal(alias, n0.ColumnAlias);
        var n1 = r1.AssertNone().AssertType <UnableToGetColumnFromAliasMsg>();

        Assert.Equal(table, n1.Table);
        Assert.Equal(alias, n1.ColumnAlias);
    }
Beispiel #24
0
        public ActionResult SetTestForm(string KeyValue)
        {
            TestTable base_user = DataFactory.Database().FindEntity <TestTable>(KeyValue);

            if (base_user == null)
            {
                return(Content(""));
            }
            //Base_Employee base_employee = DataFactory.Database().FindEntity<Base_Employee>(KeyValue);
            //Base_Company base_company = DataFactory.Database().FindEntity<Base_Company>(base_user.CompanyId);
            string strJson = base_user.ToJson();

            //公司
            //strJson = strJson.Insert(1, "\"CompanyName\":\"" + base_company.FullName + "\",");
            //员工信息
            //strJson = strJson.Insert(1, base_employee.ToJson().Replace("{", "").Replace("}", "") + ",");
            //自定义
            strJson = strJson.Insert(1, Base_FormAttributeBll.Instance.GetBuildForm(KeyValue));
            return(Content(strJson));
        }
Beispiel #25
0
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //

        #endregion

        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static TestPanelUI CreateTestPanelUI()
        {
            TestTable testTable = TestTable.CreateInstance();

            TestTable.Accessor accessor = TestTable.Accessor.Instance(null);
            //наполняем тестовыми действиями
            accessor.Actions.Add(new ActionMetaItem("Action1", ActionTypes.Action, true, null, null, null, null, null));
            accessor.Actions.Add(new ActionMetaItem("Action2", ActionTypes.Action, true, null, null, null, null, null));
            accessor.Actions.Add(new ActionMetaItem("Action3", ActionTypes.Action, true, null, null, null, null, null));

            /*
             * accessor.Actions.Add(new ActionMetaItem("Action1", "This is action 1", "icon 1", "tooltip 1", String.Empty, String.Empty, String.Empty, String.Empty, null, ActionsAlignment.Left, ActionsPanelType.Main, ActionsAppType.All, true,
             *                                      true, false, null, null, null, ActionTypes.Action, ActionTypes.Action, ActionTypes.Unknown, String.Empty));
             * accessor.Actions.Add(new ActionMetaItem("Action2", "This is action 2", "icon 2", "tooltip 2", String.Empty, String.Empty, String.Empty, String.Empty, null, ActionsAlignment.Left, ActionsPanelType.Main, ActionsAppType.All, true,
             *                                      true, false, null, null, null, ActionTypes.Action, ActionTypes.Action, ActionTypes.Unknown, String.Empty));
             * accessor.Actions.Add(new ActionMetaItem("Action3", "Some another action 3", "icon 3", "tooltip 3", String.Empty, String.Empty, String.Empty, String.Empty, null, ActionsAlignment.Left, ActionsPanelType.Main, ActionsAppType.All,
             *                                      true, true, false, null, null, null, ActionTypes.Action, ActionTypes.Action, ActionTypes.Unknown, String.Empty));
             */
            //TODO здесь должен быть BaseFormManager, который создаст Layout и поместит на него панель
            return(SetTestPanelUIBO(testTable));
        }
Beispiel #26
0
        public void PagedQueryTest()
        {
            Setup();
            CleanUp();
            Setup();

            Expect.IsTrue(_testDatabases.Count > 0);
            string name = MethodBase.GetCurrentMethod().Name;

            _testDatabases.Each(db =>
            {
                TestTableCollection testTables = CreateTestTableEntries(name, db);
                testTables = TestTable.Where(c => c.Name.StartsWith(name), db);
                Expect.AreEqual(8, testTables.Count, "There should have been 8 records but there were {0}"._Format(testTables.Count));
                PagedQuery <TestTableColumns, TestTable> q = new PagedQuery <TestTableColumns, TestTable>(new TestTableColumns().Id, testTables.Query, db);
                q.LoadMeta();
                Expect.IsGreaterThan(q.PageCount, 0, "Page count should have been greater than 0");
                OutLineFormat("Page count was {0} for {1}", ConsoleColor.Cyan, q.PageCount, db.GetType().Name);
                CheckExpectations(q);
            });
        }
Beispiel #27
0
        public void DeleteTest()
        {
            Expect.IsTrue(_testDatabases.Count > 0);
            string methodName = MethodBase.GetCurrentMethod().Name;

            _testDatabases.Each(db =>
            {
                OutLineFormat("{0}.{1}: {2}", ConsoleColor.DarkYellow, this.GetType().Name, methodName, db.GetType().Name);
                string name    = 6.RandomLetters();
                TestTable test = new TestTable(db);
                test.Name      = name;
                test.Save(db);

                TestTable toDelete = TestTable.OneWhere(t => t.Id == test.Id, db);
                Expect.IsNotNull(toDelete);
                toDelete.Delete(db);

                TestTable shouldBeNull = TestTable.OneWhere(t => t.Id == test.Id, db);
                Expect.IsNull(shouldBeNull);
            });
        }
        public ActionResult Add([FromBody] TestTable testTable)
        {
            try
            {
                _testService.Add(testTable);
                return(CreatedAtAction("Get", new { id = testTable.Testid }, testTable));
            }
            catch (Exception ex)
            {
                if (ex is ItemNotFoundException)
                {
                    return(NotFound());
                }
                else if (ex is InvalidInputException)
                {
                    return(BadRequest());
                }

                return(StatusCode(500));
            }
        }
Beispiel #29
0
        public async Task <ActionResult <TestTable> > PostTestTable(TestTable testTable)
        {
            _context.TestTable.Add(testTable);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (TestTableExists(testTable.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetTestTable", new { id = testTable.Id }, testTable));
        }
        public ActionResult Update([FromBody] TestTable testTable)
        {
            try
            {
                _testService.Update(testTable);
                return(NoContent());
            }
            catch (Exception ex)
            {
                if (ex is ItemNotFoundException)
                {
                    return(NotFound());
                }
                else if (ex is InvalidInputException)
                {
                    return(BadRequest());
                }

                return(StatusCode(500));
            }
        }
Beispiel #31
0
        /// <summary>
        /// 新增数据。必须传入姓名Name,手机号MobilePhone,身份证号IDNumber
        /// </summary>
        public BaseResult AddUser(TestTableParam param)
        {
            if (string.IsNullOrWhiteSpace(param.Name) || string.IsNullOrWhiteSpace(param.MobilePhone) ||
                string.IsNullOrWhiteSpace(param.IDNumber))
            {
                return(new BaseResult(false, null, Msg.ParamError));
            }
            var model = new TestTable
            {
                Id          = Guid.NewGuid(),
                Name        = param.Name,
                IDNumber    = param.IDNumber,
                MobilePhone = param.MobilePhone,
                CreateTime  = DateTime.Now
            };
            var count = TestTableRepository.Insert(model);

            //设置缓存
            TestTableCache.SetUserModel(model);
            return(new BaseResult(count > 0, count, count > 0 ? "" : Msg.Line0));
        }
Beispiel #32
0
        static unsafe int Main(string[] args)
        {
            int testResult = Pass;

            if (Avx2.IsSupported)
            {
                using (TestTable <byte> byteTable = new TestTable <byte>(new byte[32] {
                    255, 2, 0, 80, 0, 7, 0, 1, 2, 7, 80, 0, 123, 127, 5, 255, 255, 2, 0, 80, 0, 7, 0, 1, 2, 7, 80, 0, 123, 127, 5, 255
                }))
                {
                    var vf1 = Unsafe.Read <Vector256 <byte> >(byteTable.inArray1Ptr);
                    var res = Avx2.MoveMask(vf1);

                    if (res != -2147385343)
                    {
                        Console.WriteLine("AVX2 MoveMask failed on byte:");
                        Console.WriteLine(res);
                        testResult = Fail;
                    }
                }

                using (TestTable <sbyte> sbyteTable = new TestTable <sbyte>(new sbyte[32] {
                    -1, 2, 0, 6, 0, 7, 111, 1, 2, 55, 80, 0, 11, 127, 5, -9, -1, 2, 0, 6, 0, 7, 111, 1, 2, 55, 80, 0, 11, 127, 5, -9
                }))
                {
                    var vf1 = Unsafe.Read <Vector256 <sbyte> >(sbyteTable.inArray1Ptr);
                    var res = Avx2.MoveMask(vf1);

                    if (res != -2147385343)
                    {
                        Console.WriteLine("AVX2 MoveMask failed on sbyte:");
                        Console.WriteLine(res);
                        testResult = Fail;
                    }
                }
            }


            return(testResult);
        }
Beispiel #33
0
        public IActionResult Index()
        {
            var allUser = this._repository.GetAll();

            foreach (var user in allUser)
            {
                this._repository.Delete(user);
            }
            this._repository.Save();
            using (TransactionScope ts = new TransactionScope())
            {
                UserInfo ui = new UserInfo();
                ui.CreateDate = DateTime.Now;
                ui.Username   = "******";
                ui.Password   = "******";

                _dbContext1.UserInfo.Add(ui);
                _dbContext1.SaveChanges();

                TestTable tt = new TestTable();
                tt.StrCol = "abc";
                _dbContext2.TestTable.Add(tt);
                _dbContext2.SaveChanges();

                ts.Complete();
            }


            //this._repository.Insert(ui);
            //this._repository.Save();

            _logger.LogInformation("adsbv");

            List <UserInfo>       users             = this._repository.GetAll().ToList();
            IEnumerable <UserDTO> sendMsgViewModels = _mapper.Map <List <UserInfo>, IEnumerable <UserDTO> >(users);


            throw new Exception("ddsdfsdfsd");
            return(View());
        }
Beispiel #34
0
        static unsafe int Main(string[] args)
        {
            int testResult = Pass;

            if (Avx.IsSupported)
            {
                using (TestTable <float> floatTable = new TestTable <float>(new float[8] {
                    1, -5, 100, 0, 1, -5, 100, 0
                }))
                {
                    var vf1 = Unsafe.Read <Vector256 <float> >(floatTable.inArray1Ptr);
                    var res = Avx.MoveMask(vf1);

                    if (res != 0b00100010)
                    {
                        Console.WriteLine("Avx MoveMask failed on float:");
                        Console.WriteLine(res);
                        testResult = Fail;
                    }
                }

                using (TestTable <double> doubleTable = new TestTable <double>(new double[4] {
                    1, -5, 1, -5
                }))
                {
                    var vf1 = Unsafe.Read <Vector256 <double> >(doubleTable.inArray1Ptr);
                    var res = Avx.MoveMask(vf1);

                    if (res != 0b1010)
                    {
                        Console.WriteLine("Avx MoveMask failed on double:");
                        Console.WriteLine(res);
                        testResult = Fail;
                    }
                }
            }


            return(testResult);
        }
        public void 寫入資料庫_Guid_由小到大排序_得到連續順序()
        {
            var dbContext = new TestDbContext();

            try
            {
                //arrange
                dbContext.Database.Delete();

                for (var i = 1; i < 100; i++)
                {
                    var key   = SequentialGuid.NewGuid();
                    var name  = i.ToString("000");
                    var table = new TestTable {
                        Name = name, Key = key
                    };
                    dbContext.TestTables.Add(table);
                }

                dbContext.SaveChanges();

                //act
                var tables = dbContext.TestTables
                             .OrderBy(p => p.Key)
                             .AsNoTracking()
                             .ToList();

                var targetArray = tables.Select(p => p.Id).ToArray();

                var actual = this.IsSequential(targetArray);

                //assert
                Assert.IsTrue(actual);
            }
            finally
            {
                dbContext.Database.Delete();
                dbContext.Dispose();
            }
        }
Beispiel #36
0
        public void TestEnumCRUD(SqlCeDataStore store)
        {
            // truncate the table for this test
            store.Delete <TestTable>();

            var testRow = new TestTable
            {
                EnumField = TestEnum.ValueB
            };

            store.Insert(testRow);

            var existing = store.Select <TestTable>().First();

            Assert.AreEqual(existing.EnumField, testRow.EnumField);

            existing.EnumField = TestEnum.ValueC;
            store.Update(existing);
            var secondPull = store.Select <TestTable>().First();

            Assert.AreEqual(existing.EnumField, secondPull.EnumField);
        }
Beispiel #37
0
        public void TestOracleClientStringExpressionExtenstionMethods()
        {
            var table = new TestTable();

            Assert.AreEqual("[StringColumn] LIKE '%' + ? + '%'", table.StringColumn.Contains("a").ToConditionCacheableSql());
            Assert.AreEqual("[StringColumn] LIKE ? + '%'", table.StringColumn.StartsWith("a").ToConditionCacheableSql());
            Assert.AreEqual("[StringColumn] LIKE '%' + ?", table.StringColumn.EndsWith("a").ToConditionCacheableSql());
            Assert.AreEqual("INSTR([StringColumn], ?) - 1", table.StringColumn.IndexOf("a").ToExpressionCacheableSql());
            Assert.AreEqual("INSTR([StringColumn], ?) - 1", table.StringColumn.IndexOf(new StringParameterExpression("a", true)).ToExpressionCacheableSql());
            Assert.AreEqual("REPLACE([StringColumn], ?, ?)", table.StringColumn.Replace("a", "b").ToExpressionCacheableSql());
            Assert.AreEqual("REPLACE([StringColumn], ?, ?)", table.StringColumn.Replace("a", new StringParameterExpression("b", true)).ToExpressionCacheableSql());
            Assert.AreEqual("REPLACE([StringColumn], ?, ?)", table.StringColumn.Replace(new StringParameterExpression("a", true), "b").ToExpressionCacheableSql());
            Assert.AreEqual("REPLACE([StringColumn], ?, ?)", table.StringColumn.Replace(new StringParameterExpression("a", true), new StringParameterExpression("b", true)).ToExpressionCacheableSql());
            Assert.AreEqual("SUBSTR([StringColumn], ? + 1, ?)", table.StringColumn.Substring(1, 1).ToExpressionCacheableSql());
            Assert.AreEqual("SUBSTR([StringColumn], ? + 1, ?)", table.StringColumn.Substring(1, new Int32ParameterExpression(1)).ToExpressionCacheableSql());
            Assert.AreEqual("SUBSTR([StringColumn], ? + 1, ?)", table.StringColumn.Substring(new Int32ParameterExpression(1), 1).ToExpressionCacheableSql());
            Assert.AreEqual("SUBSTR([StringColumn], ? + 1, ?)", table.StringColumn.Substring(new Int32ParameterExpression(1), new Int32ParameterExpression(1)).ToExpressionCacheableSql());
            Assert.AreEqual("LTRIM([StringColumn])", table.StringColumn.LTrim().ToExpressionCacheableSql());
            Assert.AreEqual("RTRIM([StringColumn])", table.StringColumn.RTrim().ToExpressionCacheableSql());
            Assert.AreEqual("ASCII([StringColumn])", table.StringColumn.ToAscii().ToExpressionCacheableSql());
            Assert.AreEqual("LENGTH([StringColumn])", table.StringColumn.GetLength().ToExpressionCacheableSql());
        }
Beispiel #38
0
    public void Adds_Predicate_To_Where_List()
    {
        // Arrange
        var table   = new TestTable();
        var builder = new QueryBuilderWithFrom(table);
        var value   = Rnd.Str;

        // Act
        var result = (QueryBuilderWithFrom)builder.Where <TestTable>(t => t.Foo, Compare.Like, value);

        // Assert
        Assert.Collection(result.Parts.Where,
                          x =>
        {
            Assert.Equal(nameof(TestTable), x.column.TblName.Name);
            Assert.Equal(TestTable.Prefix + nameof(TestTable0.Foo), x.column.ColName);
            Assert.Equal(nameof(TestTable.Foo), x.column.ColAlias);
            Assert.Equal(Compare.Like, x.compare);
            Assert.Equal(value, x.value);
        }
                          );
    }
Beispiel #39
0
        public ActionResult PatientView(Patient patient)

        {
            var patients    = PatientTable.GetPatientById(Properties.UserId);
            var description = MedicalDescriptionTable.GetDataByPatientId(Properties.UserId);
            var visit       = VisitTable.GetDataByPatientId(Properties.UserId);
            var prescript   = PrescriptionTable.GetData(Properties.UserId);
            var test        = TestTable.GetData(Properties.UserId);
            var leavesick   = SickLeaveTable.GetDataByPatientId(Properties.UserId);
            var doc         = DocumentationTable.GetDataByPatientId(Properties.UserId);

            //  ViewData["PatientName"] = PatientTable.GetPatientById(patient.Id);
            ViewData["PatientName"]        = patients[0];
            ViewData["visitData"]          = visit;
            ViewData["prescriptioneData"]  = prescript;
            ViewData["Tests"]              = test;
            ViewData["sickLeaveData"]      = leavesick;
            ViewData["medicalDescription"] = description;
            ViewData["documentation"]      = doc;

            return(View());
        }
Beispiel #40
0
        public void SqlStringBuilderCreateTest()
        {
            HashSet <Database> dbs = DataTools.Setup();

            dbs.Each(db =>
            {
                try
                {
                    ObjectIdentifier id  = new ObjectIdentifier();
                    string name          = "Name_".RandomLetters(10);
                    SqlStringBuilder sql = db.Sql().Insert(nameof(TestTable), new { Name = name, Uuid = id.Uuid, Cuid = id.Cuid });
                    db.ExecuteSql(sql);
                    RetrieveByNameAndValidate(db, TestTable.OneWhere(c => c.Name == name, db));
                    Pass($"{db.GetType().Name} passed");
                }
                catch (Exception ex)
                {
                    Error($"{db.GetType().Name}: failed: {ex.Message}", ex);
                }
            });
            DataTools.Cleanup(dbs);
        }
        public void TryGetIncomingLabel_Should_Retrieve_Correct_Label()
        {
            const int One = 0x0001;
            const string OneString = "One";

            var table = new TestTable();
            table.AddIn(One, OneString);

            string label;
            table.TryGetIncomingLabel(One, out label);
            label.Should().Be(OneString);
        }
        public void TryGetOutgoingCode_Should_Retrieve_Correct_Code()
        {
            const int One = 0x0001;
            const string OneString = "One";

            var table = new TestTable();
            table.AddOut(OneString, One);

            ushort code;
            table.TryGetOutgoingCode(OneString, out code);
            code.Should().Be(One);
        }
        public void LoadPacketCodesInternal_Should_Be_Called()
        {
            var table = new TestTable();

            table.LoadPacketCodes();

            table.LoadPacketCodesCallCount.Should().Be(1);
        }
        public void LoadPacketCodes_Should_Not_Throw()
        {
            var table = new TestTable();

            table
                .Invoking(t => t.LoadPacketCodes())
                .ShouldNotThrow();
        }
        public void GetOutgoingCode_Should_Return_Correct_Code()
        {
            const int One = 0x0001;
            const string OneString = "One";

            var table = new TestTable();
            table.AddOut(OneString, One);

            table.GetOutgoingCode(OneString).Should().Be(One);
        }
        public void GetOutgoingCode_Should_Throw_For_Missing_Label()
        {
            const int One = 0x0001;
            const string ZeroString = "Zero";
            const string OneString = "One";

            var table = new TestTable();
            table.AddOut(OneString, One);

            table
                .Invoking(t => t.GetOutgoingCode(ZeroString))
                .ShouldThrow<KeyNotFoundException>();
        }
Beispiel #47
0
 public void TableClassesAutomaticallyInitializeTableName()
 {
     TestTable t = new TestTable();
     Assert.AreEqual("TestTable", t.GetTableName());
 }
        public void GetIncomingLabel_Should_Return_Correct_Label()
        {
            const int One = 0x0001;
            const string OneString = "One";

            var table = new TestTable();
            table.AddIn(One, OneString);

            table.GetIncomingLabel(One).Should().Be(OneString);
        }
Beispiel #49
0
 public void TableClassesAutomaticallyInitializeColumnFields()
 {
     TestTable t = new TestTable();
     Assert.AreEqual("IntColumn", t.IntColumn.GetColumnName());
 }
 private static void TryGetNullCode(TestTable t)
 {
     ushort code;
     t.TryGetOutgoingCode(null, out code);
 }
        public void GetIncomingLabel_Should_Throw_KeyNotFoundException_For_Missing_Code()
        {
            const int Zero = 0x0000;
            const int One = 0x0001;

            var table = new TestTable();
            table.AddIn(Zero, "Zero");

            table
                .Invoking(t => t.GetIncomingLabel(One))
                .ShouldThrow<KeyNotFoundException>();
        }
        public void TryGetOutgoingCode_Should_Throw_On_Null_Label()
        {
            var table = new TestTable();

            table
                .Invoking(TryGetNullCode)
                .ShouldThrow<ArgumentNullException>();
        }
        public void TryGetIncomingLabel_Should_Return_True_For_Existing_Code()
        {
            const int Zero = 0x0000;

            var table = new TestTable();
            table.AddIn(Zero, "Zero");

            string s;
            table.TryGetIncomingLabel(Zero, out s).Should().BeTrue();
        }
        public void TryGetOutgoingCode_Should_Return_True_For_Existing_Label()
        {
            const int Zero = 0x0000;
            const string ZeroString = "Zero";

            var table = new TestTable();
            table.AddOut(ZeroString, Zero);

            ushort code;
            table.TryGetOutgoingCode(ZeroString, out code).Should().BeTrue();
        }
        public void TryGetOutgoingCode_Should_Return_False_For_Missing_Label()
        {
            const int Zero = 0x0000;

            var table = new TestTable();
            table.AddOut("Zero", Zero);

            ushort code;
            table.TryGetOutgoingCode("One", out code).Should().BeFalse();
        }
        public void TryGetIncomingLabel_Should_Return_False_For_Missing_Code()
        {
            const int Zero = 0x0000;
            const int One = 0x0001;

            var table = new TestTable();
            table.AddIn(Zero, "Zero");

            string s;
            table.TryGetIncomingLabel(One, out s).Should().BeFalse();
        }
 private static void TryGetEmptyCode(TestTable t)
 {
     ushort code;
     t.TryGetOutgoingCode("", out code);
 }