예제 #1
0
        private static bool InvokeMethod(Detail item2)
        {
            bool stop;
            //預設設定
            Type            TestToolType     = TestTool.GetType();
            ConstructorInfo magicConstructor = TestToolType.GetConstructor(Type.EmptyTypes);
            object          magicClassObject = magicConstructor.Invoke(new object[] { });
            //查詢方法名稱
            MethodInfo magicMethod = TestToolType.GetMethods().Where(p => p.Name == item2.IniName && p.ToString().Contains(TestDriver)).FirstOrDefault();
            //取得方法有幾個Parameter
            int parameters = magicMethod.GetParameters().Count();

            //宣告組要執行的parameters字串
            object[] arr = new object[parameters];
            if (TestDriver == "AndroidDriver")
            {
                arr[0] = androidDriver;
            }
            else
            {
                arr[0] = driver;
            }
            for (int i = 1; i < parameters; i++)
            {
                arr[i] = item2.Inivalue[i - 1];
            }
            //執行方法
            stop = Convert.ToBoolean(magicMethod.Invoke(magicClassObject, arr));
            return(stop);
        }
        public void SinhBorderTest()
        {
            MultiPrecision <Pow2.N8>[] borders = new MultiPrecision <Pow2.N8>[] { -1, 0, 1 };

            foreach (MultiPrecision <Pow2.N8> b in borders)
            {
                List <MultiPrecision <Pow2.N8> > ys = new();

                foreach (MultiPrecision <Pow2.N8> x in TestTool.EnumerateNeighbor(b))
                {
                    MultiPrecision <Pow2.N8> y = MultiPrecision <Pow2.N8> .Sinh(x);

                    Console.WriteLine(x);
                    Console.WriteLine(x.ToHexcode());
                    Console.WriteLine(y);
                    Console.WriteLine(y.ToHexcode());
                    Console.Write("\n");

                    TestTool.Tolerance(Math.Sinh((double)x), y);

                    ys.Add(y);
                }

                if (b != 0)
                {
                    TestTool.NearlyNeighbors(ys, 2);
                }
                TestTool.SmoothnessSatisfied(ys, 1);
                TestTool.MonotonicitySatisfied(ys);

                Console.Write("\n");
            }
        }
예제 #3
0
        public void ThreadTest(int repeat, int concurrent)
        {
            for (var i = 0; i < repeat; i++)
            {
                TestTool.RunTasks(concurrent,
                                  () => ExecuteDataSet(0, 0),
                                  () => ExecuteDataSetByQuery(0, 0),
                                  ExecuteDataSetInTransactionScope,
                                  () => ExecuteDataSetByPaging(0, 0),
                                  ExecuteDataSet_MultiResultSet_BySqlString,
                                  () => ExecuteDataTable(0, 0),
                                  () => ExecuteDataTableByQuery(0, 0),
                                  () => ExecuteDataTableAndCopy(0, 0),
                                  () => ExecuteDataTableBySqlString(0, 0),
                                  () => ExecuteDataTableToInstance(0, 0),
                                  ExecuteDataTableAsList_BySqlString,
                                  () => ExecutePagingDataTableTest(0, 10, 0.0),
                                  () => ExecutePagingDataTableByQueryTest(0, 10, 0.0),
                                  () => ExecutePagingDataTableBySelectSqlTest(0, 10, 0.0),
                                  ExecuteScalar,
                                  ExecuteNonQuery,
                                  ExecuteReaderByQuery,
                                  CountOfDataReader,
                                  ExistsByDataReader,
                                  () => ExecuteReaderToInstanceByNameMapping(0, 1000),
                                  () => ExecuteReaderWithPaging(0, 10),
                                  () => ExecuteReaderWithPagingByPersister(0, 10),
                                  ExecuteReaderToInstanceByConverter,
                                  DatabaseToPersistentObject,
                                  FluentByNameMapper_Load
                                  );

                Thread.Sleep(100);
            }
        }
 public void Thread_Test()
 {
     TestTool.RunTasks(15,
                       DefaultFactory,
                       IoCFactory,
                       UnitOfWork_ThreadSafely);
 }
 public void ConcurrentDictionary_GetOrAdd_Not_ThreadSafe_In_Threads()
 {
     TestTool.RunTasks(5,
                       ConcurrentDictionary_GetOrAdd_Not_ThreadSafe,
                       ConcurrentDictionary_GetOrAdd_Not_ThreadSafe,
                       ConcurrentDictionary_GetOrAdd_Not_ThreadSafe);
 }
 public void ThreadTest()
 {
     TestTool.RunTasks(10, () => {
         GetQueries();
         GetQuery();
     });
 }
예제 #7
0
        public void Can_GetHostAddressesAsync()
        {
            TestTool
            .RunTasks(ThreadCount,
                      () => {
                foreach (var hostName in HostNames)
                {
                    using (var task = DnsAsync.GetHostAddresses(hostName)) {
                        // 비동기 호출 후, 다른 작업을 하는 부분을 나타낸다.
                        Thread.Sleep(10);

                        var ipAddrs = task.Result;

                        Assert.IsNotNull(ipAddrs);
                        CollectionAssert.AllItemsAreNotNull(ipAddrs);

                        if (IsDebugEnabled)
                        {
                            foreach (var ipAddr in ipAddrs)
                            {
                                log.Debug("HostName={0}, IPAddress={1}", hostName, ipAddr);
                            }
                        }
                    }
                }
            });
        }
예제 #8
0
        public void Can_GetHostEntryAsync()
        {
            TestTool
            .RunTasks(ThreadCount,
                      () => {
                foreach (var hostName in HostNames)
                {
                    using (var task = DnsAsync.GetHostEntry(hostName)) {
                        // 비동기 호출 후, 다른 작업을 하는 부분을 나타낸다.
                        Thread.Sleep(10);

                        var hostEntry = task.Result;
                        Assert.IsNotNull(hostEntry);

                        if (IsDebugEnabled)
                        {
                            hostEntry.AddressList.RunEach(
                                addr => log.Debug("HostName={0}, IPAddress={1}", hostEntry.HostName, addr));
                            hostEntry.Aliases.RunEach(
                                alias => log.Debug("HostName={0}, Alias={1}", hostEntry.HostName, alias));
                        }
                    }
                }
            });
        }
        public void TransactionScope_ShouldNotPromoteToDTC2()
        {
            TestTool.RunTasks(10,
                              () => {
                using (var txScope = AdoTool.CreateTransactionScope()) {
                    var count = TotalCount();

                    var ds = NorthwindAdoRepository.ExecuteDataSetBySqlString(SQL_REGION_SELECT, 1, 10);
                    var dt = NorthwindAdoRepository.ExecuteDataTableBySqlString(SQL_REGION_SELECT, 1, 10);

                    Assert.IsFalse(ds.Tables[0].HasErrors);
                    Assert.IsFalse(dt.HasErrors);

                    int rows = NorthwindAdoRepository.ExecuteNonQueryBySqlString(SQL_REGION_INSERT);
                    Assert.AreEqual(1, rows);
                    rows = NorthwindAdoRepository.ExecuteNonQueryBySqlString(SQL_REGION_INSERT2);
                    Assert.AreEqual(1, rows);

                    NorthwindAdoRepository.ExecuteNonQueryBySqlString(SQL_REGION_DELETE);

                    ds = NorthwindAdoRepository.ExecuteDataSetBySqlString(SQL_REGION_SELECT);
                    dt = NorthwindAdoRepository.ExecuteDataTableBySqlString(SQL_REGION_SELECT);

                    txScope.Complete();
                }
            });
        }
예제 #10
0
        public void CanCache5GBFile()
        {
            var packageA = this.CreatePackageInstaller("PackageA");
            var bundleC  = this.CreateBundleInstaller("BundleC");

            packageA.VerifyInstalled(false);

            // Recreate the 5GB payload to avoid having to copy it to the VM to run the tests.
            var targetFilePath = Path.Combine(this.TestContext.TestDataFolder, "fivegb.file");

            if (!File.Exists(targetFilePath))
            {
                var testTool = new TestTool(Path.Combine(TestData.Get(), "win-x86", "TestExe.exe"))
                {
                    Arguments        = "/lf \"" + targetFilePath + "|5368709120\"",
                    ExpectedExitCode = 0,
                };
                testTool.Run(true);
            }

            bundleC.Install();
            bundleC.VerifyRegisteredAndInPackageCache();

            packageA.VerifyInstalled(true);
        }
예제 #11
0
        public void WaintForEventToRun()
        {
            const int count = 50;

            TestTool.RunTasks(ThreadCount,
                              () => {
                var countdown = new CountdownLatch(count);
                var done      = new bool[count];


                for (int i = 0; i < count; i++)
                {
                    var j = i;
                    ThreadPool.QueueUserWorkItem(delegate {
                        done[j] = true;
                        countdown.Set();
                    });
                }

                bool result = countdown.WaitOne();
                Assert.IsTrue(result);

                for (var i = 0; i < count; i++)
                {
                    Assert.IsTrue(done[i], "{0} was not set to true", i);
                }
            });
        }
        public void GammaBorderTest()
        {
            MultiPrecision <Pow2.N8>[] borders = new MultiPrecision <Pow2.N8>[] { 0.5, 1 };

            foreach (MultiPrecision <Pow2.N8> b in borders)
            {
                List <MultiPrecision <Pow2.N8> > ys = new();

                foreach (MultiPrecision <Pow2.N8> x in TestTool.EnumerateNeighbor(b))
                {
                    MultiPrecision <Pow2.N8> y = MultiPrecision <Pow2.N8> .Gamma(x);

                    Console.WriteLine(x);
                    Console.WriteLine(x.ToHexcode());
                    Console.WriteLine(y);
                    Console.WriteLine(y.ToHexcode());
                    Console.Write("\n");

                    TestTool.Tolerance(Approx.Gamma((double)x), y, ignore_sign: true);

                    ys.Add(y);
                }

                TestTool.NearlyNeighbors(ys, 2);
                TestTool.SmoothnessSatisfied(ys, 1);
                TestTool.MonotonicitySatisfied(ys);

                Console.Write("\n");
            }
        }
예제 #13
0
        public void Atan2BorderTest()
        {
            foreach (MultiPrecision <Pow2.N8> x in TestTool.EnumerateNeighbor <Pow2.N8>(0))
            {
                MultiPrecision <Pow2.N8> y = MultiPrecision <Pow2.N8> .Atan2(x, 1);

                Console.WriteLine(x);
                Console.WriteLine(x.ToHexcode());
                Console.WriteLine(y);
                Console.WriteLine(y.ToHexcode());
                Console.Write("\n");

                TestTool.Tolerance(Math.Atan2((double)x, 1), y);
            }

            Console.Write("\n");

            foreach (MultiPrecision <Pow2.N8> x in TestTool.EnumerateNeighbor <Pow2.N8>(0))
            {
                MultiPrecision <Pow2.N8> y = MultiPrecision <Pow2.N8> .Atan2(x, -1);

                Console.WriteLine(x);
                Console.WriteLine(x.ToHexcode());
                Console.WriteLine(y);
                Console.WriteLine(y.ToHexcode());
                Console.Write("\n");

                TestTool.Tolerance(Math.Atan2((double)x, -1), y);
            }

            Console.Write("\n");

            foreach (MultiPrecision <Pow2.N8> x in TestTool.EnumerateNeighbor <Pow2.N8>(0))
            {
                MultiPrecision <Pow2.N8> y = MultiPrecision <Pow2.N8> .Atan2(1, x);

                Console.WriteLine(x);
                Console.WriteLine(x.ToHexcode());
                Console.WriteLine(y);
                Console.WriteLine(y.ToHexcode());
                Console.Write("\n");

                TestTool.Tolerance(Math.Atan2(1, (double)x), y);
            }

            Console.Write("\n");

            foreach (MultiPrecision <Pow2.N8> x in TestTool.EnumerateNeighbor <Pow2.N8>(0))
            {
                MultiPrecision <Pow2.N8> y = MultiPrecision <Pow2.N8> .Atan2(-1, x);

                Console.WriteLine(x);
                Console.WriteLine(x.ToHexcode());
                Console.WriteLine(y);
                Console.WriteLine(y.ToHexcode());
                Console.Write("\n");

                TestTool.Tolerance(Math.Atan2(-1, (double)x), y);
            }
        }
예제 #14
0
 public void ThreadTest()
 {
     TestTool.RunTasks(5,
                       CanSaveAndLoadValueType,
                       NotYetSetValueIsNull,
                       SaveAndLoadRefenceType,
                       GetOrAdd);
 }
예제 #15
0
 public void ThreadTest()
 {
     TestTool.RunTasks(15,
                       () => {
         SleepTest();
         SleepPerfCounterTest();
     });
 }
예제 #16
0
 public void Can_Cache_Html_Threads()
 {
     TestTool.RunTasks(4,
                       () => {
         _htmlCache = new HtmlAsyncCache();
         Can_Cache_Html();
     });
 }
예제 #17
0
 public void ThreadTest()
 {
     TestTool.RunTasks(2,
                       DownloadDataTaskTest,
                       DownloadStringTaskTest,
                       DownloadFileTaskTest,
                       OpenReadTaskTest);
 }
예제 #18
0
 public void MultiTest()
 {
     TestTool.RunTasks(4, () => NHWith.Transaction(delegate {
         FindAll();
         FindAll_Paging();
         Get();
     }));
 }
예제 #19
0
 public void ThreadTest()
 {
     TestTool.RunTasks(4,
                       Can_GetAppSettings,
                       Display_ConnectionStrings,
                       Can_GetConnectionString,
                       Can_GetConnectionStringSettings);
 }
예제 #20
0
 public void Thread_Test()
 {
     TestTool.RunTasks(4,
                       WriteToStreamUsingBackgroundThread,
                       WriteToStreamUsingBackgroundThread_WriteToClosedTransferStream,
                       WriteToStreamUsingBackgroundThread,
                       WriteToStreamUsingBackgroundThread_WriteToClosedTransferStream);
 }
예제 #21
0
 public void WaitForConsumersDoesNotWaitIfConsumersAreZero()
 {
     TestTool.RunTasks(ThreadCount,
                       () => {
         var result = new CountdownLatch(0).WaitOne();
         Assert.IsTrue(result);
     });
 }
예제 #22
0
 public void ThreadTest()
 {
     TestTool.RunTasks(5,
                       Memory_Compress_Decompress,
                       Memory_Compress_Decompress_Async,
                       FileAsync_Compress_Decompress,
                       FileAsync_Compress_Decompress_Async);
 }
 public void Thread_Test()
 {
     TestTool.RunTasks(2,
                       Transaction_Without_DTC,
                       Rollback_Test,
                       LoadDataSet_With_Multiple_Query,
                       LoadDataSet_With_Multiple_Procedure);
 }
예제 #24
0
 public void MultiTesting()
 {
     TestTool.RunTasks(4, () => NHWith.Transaction(delegate {
         Get();
         FindAll_With_Paging();
         GetByCategory();
     }));
 }
예제 #25
0
 public void Thread_Test()
 {
     TestTool.RunTasks(3, () => {
         ExternalResourceTest();
         LoadParameterizedValue();
         LoadParameterizedValueInOtherResourceName();
     });
 }
예제 #26
0
 public void Thread_Test()
 {
     TestTool.RunTasks(5,
                       DataReaderGetByIndex,
                       CanGetNullableFromOrderDetails,
                       CanGetNullableFromProducts,
                       DataReaderGetByName);
 }
예제 #27
0
 public void ThreadTest()
 {
     TestTool.RunTasks(4,
                       AsyncCache_Auto_Created,
                       AsyncCache_Lazy_Created,
                       AsyncCache_Set_Directly_Value,
                       AsyncCache_Set_Directly_Task);
 }
        public void Pow2BorderTest()
        {
            MultiPrecision <Pow2.N8>[] borders_n8 = new MultiPrecision <Pow2.N8>[] { -2, -1, -0.5, 0, 0.5, 1, 2 };

            foreach (MultiPrecision <Pow2.N8> b in borders_n8)
            {
                List <MultiPrecision <Pow2.N8> > ys = new();

                foreach (MultiPrecision <Pow2.N8> x in TestTool.EnumerateNeighbor(b))
                {
                    MultiPrecision <Pow2.N8> y = MultiPrecision <Pow2.N8> .Pow2(x);

                    Console.WriteLine(x);
                    Console.WriteLine(x.ToHexcode());
                    Console.WriteLine(y);
                    Console.WriteLine(y.ToHexcode());
                    Console.Write("\n");

                    TestTool.Tolerance(Math.Pow(2, (double)x), y);

                    ys.Add(y);
                }

                TestTool.NearlyNeighbors(ys, 4);
                TestTool.SmoothnessSatisfied(ys, 1.25);
                TestTool.MonotonicitySatisfied(ys);

                Console.Write("\n");
            }

            MultiPrecision <Pow2.N16>[] borders_n16 = new MultiPrecision <Pow2.N16>[] { -2, -1, -0.5, 0, 0.5, 1, 2 };

            foreach (MultiPrecision <Pow2.N16> b in borders_n16)
            {
                List <MultiPrecision <Pow2.N16> > ys = new();

                foreach (MultiPrecision <Pow2.N16> x in TestTool.EnumerateNeighbor(b))
                {
                    MultiPrecision <Pow2.N16> y = MultiPrecision <Pow2.N16> .Pow2(x);

                    Console.WriteLine(x);
                    Console.WriteLine(x.ToHexcode());
                    Console.WriteLine(y);
                    Console.WriteLine(y.ToHexcode());
                    Console.Write("\n");

                    TestTool.Tolerance(Math.Pow(2, (double)x), y);

                    ys.Add(y);
                }

                TestTool.NearlyNeighbors(ys, 4);
                TestTool.SmoothnessSatisfied(ys, 1.25);
                TestTool.MonotonicitySatisfied(ys);

                Console.Write("\n");
            }
        }
예제 #29
0
        public void EulerGammaTest()
        {
            MultiPrecision <Pow2.N8> eulergamma = MultiPrecision <Pow2.N8> .EulerGamma;

            Console.WriteLine(eulergamma);
            Console.WriteLine(eulergamma.ToHexcode());

            TestTool.Tolerance(0.57721566490153286, eulergamma);
        }
예제 #30
0
 public void SerializeWithCompress_DeserializeWithDecompress()
 {
     TestTool.RunTasks(ThreadCount,
                       () => {
         var serialized       = JsonTool.SerializeWithCompress(user);
         var deserializedUser = JsonTool.DeserializeWithDecompress <UserInfo>(serialized);
         VerifySerializer(user, deserializedUser);
     });
 }
예제 #31
0
        /// <summary>
        /// Executes the bundle with optional arguments.
        /// </summary>
        /// <param name="expectedExitCode">Expected exit code.</param>
        /// <param name="mode">Install mode.</param>
        /// <param name="arguments">Optional arguments to pass to the tool.</param>
        /// <returns>Path to the generated log file.</returns>
        private string RunBundleWithArguments(int expectedExitCode, MSIExec.MSIExecMode mode, params string[] arguments)
        {
            TestTool bundle = new TestTool(this.Bundle, null);
            StringBuilder sb = new StringBuilder();

            // Be sure to run silent.
            sb.Append(" -quiet");

            // Generate the log file name.
            string logFile = Path.Combine(Path.GetTempPath(), String.Format("{0}_{1:yyyyMMddhhmmss}_{3}_{2}.log", this.TestName, DateTime.UtcNow, Path.GetFileNameWithoutExtension(this.Bundle), mode));
            sb.AppendFormat(" -log \"{0}\"", logFile);

            // Set operation.
            switch (mode)
            {
                case MSIExec.MSIExecMode.Modify:
                    sb.Append(" -modify");
                    break;

                case MSIExec.MSIExecMode.Repair:
                    sb.Append(" -repair");
                    break;

                case MSIExec.MSIExecMode.Uninstall:
                    sb.Append(" -uninstall");
                    break;
            }

            // Add additional arguments.
            if (null != arguments)
            {
                sb.Append(" ");
                sb.Append(String.Join(" ", arguments));
            }

            // Set the arguments.
            bundle.Arguments = sb.ToString();

            // Run the tool and assert the expected code.
            bundle.ExpectedExitCode = expectedExitCode;
            bundle.Run();

            // Return the log file name.
            return logFile;
        }