Esempio n. 1
0
        public void SQLPageLinkExistsInListView()
        {
            ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);

            Assert.That(listViewTester.Items[4].Text, Does.Match("SQL Server"));
        }
Esempio n. 2
0
 public void JaggedArray()
 {
     Assert.That(CompilationFinishedHook.WeaveFailed, Is.True);
     Assert.That(m_weaverErrors.Count, Is.AtLeast(1));
     Assert.That(m_weaverErrors[0], Does.Match("Jagged and multidimensional arrays are not supported"));
 }
Esempio n. 3
0
        public void DisplayHeader()
        {
            CreateTextUI().DisplayHeader();

            Assert.That(Report, Does.Match("^NUnitLite.*\nCopyright.*\n\n$"));
        }
        public async Task GetFieldPropertiesFromFullAlias()
        {
            Guid fieldGuid = HRBCClientPrivate.Util.UuidUtil.BuildFieldGuid(101, 303, ResourceId.Client);

            var expectedResponseGet    = "{'values':{'" + fieldGuid + "':{'alias':'P_TestAlias','resource':'client','properties':{'s.type':3}}}}";
            var expectedResponseSearch = "{'result':[{'id':'" + fieldGuid + "'}]}";

            using (var mocker = HrbcVersion.Trunk.ToRequestMocker())
            {
                mocker.WhenRequest(HttpRequestConstraint.HttpRequest().WithMethod(HttpMethod.Get)
                                   .WithUri(UriConstraint.Uri(Is.EqualTo("/privateapi/field/field-search"), Does.Match($".*w%5Balias%5D=P_TestAlias.*")))
                                   .WithAnyContent())
                .RespondWith(expectedResponseSearch);

                mocker.WhenRequest(HttpRequestConstraint.HttpRequest().WithMethod(HttpMethod.Get)
                                   .WithUri(UriConstraint.Uri(Is.EqualTo("/privateapi/field/field"), Does.Match($".*id%5B%5D={fieldGuid}.*").And.Match(".*s%5B%5D=properties%2Fs.type.*")))
                                   .WithAnyContent())
                .RespondWith(expectedResponseGet);

                using (var session = mocker.Session)
                {
                    // fake user login account
                    ((PrivateSession)session).Cache.Set("HrbcAccount", "303-1");

                    var response = await session.CallAsync(GetFieldPropertyRequest.Builder().Select(FieldProperty.FieldType).WhereField("Client.P_TestAlias".ToField()));

                    Assert.That(response, Has.Count.EqualTo(1));
                    Assert.That(response.Keys, Does.Contain("Client.P_TestAlias".ToField()));
                    Assert.That(response["Client.P_TestAlias".ToField()], Has.Count.EqualTo(5));
                }
            }
        }
        static void AssertStagePackageOutputVariableSet(CalamariResult result, SampleFeedPackage testFeed)
        {
            var newPacakgeRegex = PackageName.ToRegexPattern(testFeed.PackageId, testFeed.Version, testFeed.DownloadFolder);

            result.AssertOutputVariable("StagedPackage.FullPathOnRemoteMachine", Does.Match(newPacakgeRegex + ".*"));
        }
        public void Field_ToString_RedContainsCorrectValues()
        {
            var uut = new Field(4, FieldColor.Red);

            Assert.That(uut.ToString().ToLower(), Does.Match("4.*red"));
        }
Esempio n. 7
0
        public void RegExCaseMatchFails()
        {
            var          expectedErrorMessage = $"  Expected: String matching \"make.*tests.*fail\"{NL}  But was:  \"Make your tests fail before passing!\"{NL}";
            const string testMatcher          = "make.*tests.*fail";
            const string testPhrase           = "Make your tests fail before passing!";

            var ex = Assert.Throws <AssertionException>(() => Assert.That(testPhrase, Does.Match(testMatcher)));

            Assert.That(ex.Message, Is.EqualTo(expectedErrorMessage));

            ex = Assert.Throws <AssertionException>(() => Assert.That(testPhrase, Does.Match(new Regex(testMatcher))));
            Assert.That(ex.Message, Is.EqualTo(expectedErrorMessage));
        }
Esempio n. 8
0
        public void GetDecimalTypeName()
        {
            var cfg     = TestConfigurationHelper.GetDefaultConfiguration();
            var dialect = Dialect.Dialect.GetDialect(cfg.Properties);

            Assert.That(dialect.GetTypeName(SqlTypeFactory.GetSqlType(DbType.Decimal, 40, 40)), Does.Not.Contain("40"), "oversized decimal");
            // This regex tests wether the type is qualified with expected length/precision/scale or not qualified at all.
            Assert.That(dialect.GetTypeName(SqlTypeFactory.GetSqlType(DbType.Decimal, 3, 2)), Does.Match(@"^[^(]*(\(\s*3\s*,\s*2\s*\))?\s*$"), "small decimal");
        }
Esempio n. 9
0
        public void GetTypeCastName()
        {
            var cfg = TestConfigurationHelper.GetDefaultConfiguration();

            cfg.SetProperty(Environment.QueryDefaultCastLength, "20");
            cfg.SetProperty(Environment.QueryDefaultCastPrecision, "10");
            cfg.SetProperty(Environment.QueryDefaultCastScale, "3");
            var dialect = Dialect.Dialect.GetDialect(cfg.Properties);

            // Those regex test wether the type is qualified with expected length/precision/scale or not qualified at all.
            Assert.That(dialect.GetCastTypeName(SqlTypeFactory.Decimal), Does.Match(@"^[^(]*(\(\s*10\s*,\s*3\s*\))?\s*$"), "decimal");
            Assert.That(dialect.GetCastTypeName(SqlTypeFactory.GetSqlType(DbType.Decimal, 12, 4)), Does.Match(@"^[^(]*(\(\s*12\s*,\s*4\s*\))?\s*$"), "decimal(12,4)");
            Assert.That(dialect.GetCastTypeName(new SqlType(DbType.String)), Does.Match(@"^[^(]*(\(\s*20\s*\))?\s*$"), "string");
            Assert.That(dialect.GetCastTypeName(SqlTypeFactory.GetString(25)), Does.Match(@"^[^(]*(\(\s*25\s*\))?\s*$"), "string(25)");
        }
        public void Should_Generate_Phone_Number_Based_On_Pattern(string pattern, string regexMatchPattern)
        {
            string number = Phone.Number(pattern);

            Assert.That(number, Does.Match(regexMatchPattern));
        }
Esempio n. 11
0
        public void Constraint_AssertStringMatchesKeyWords_ReturnsTrue()
        {
            var someString = "Do something somewhere for some other purpose";

            Assert.That(someString, Does.Match("something.*for.*purpose"));
        }
 protected void ExceptionMessageMatchesRegex(string pattern)
 {
     Assert.That(_exception.Message, Does.Match(pattern));
 }
        public void TabsPanelPageLinkExistsInListView()
        {
            ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);

            Assert.That(listViewTester.Items[2].Text, Does.Match("Tabs & Panels"));
        }
Esempio n. 14
0
        public void DisplayRuntimeEnvironment()
        {
            CreateTextUI().DisplayRuntimeEnvironment();

            Assert.That(Report, Does.Match("^Runtime Environment\n   OS Version:.*\n  CLR Version:.*\n\n$"));
        }
        public void Field_ToString_BlackContainsCorrectValues()
        {
            var uut = new Field(3, FieldColor.Black);

            Assert.That(uut.ToString().ToLower(), Does.Match("3.*black"));
        }
Esempio n. 16
0
 public void Cipher_key_is_made_of_letters()
 {
     Assert.That(cipher.Key, Does.Match("[a-z]+"));
 }
        public void Field_ToString_GreenContainsCorrectValues()
        {
            var uut = new Field(0, FieldColor.Green);

            Assert.That(uut.ToString().ToLower(), Does.Match("0.*green"));
        }
Esempio n. 18
0
 public void WhenClipboardContentTypeIsPlainTextWithOutLabel_GetClipboardTextShouldReturnActualText()
 {
     _driver.SetClipboardText(ClipboardTestString, null);
     Assert.That(() => _driver.GetClipboardText(), Does.Match(ClipboardTestString));
 }
Esempio n. 19
0
 public void SetUp()
 {
     parseTree     = @"<regex ""X"">";
     staticSyntax  = Does.Match("X").IgnoreCase;
     builderSyntax = Builder().Matches("X").IgnoreCase;
 }
Esempio n. 20
0
        void RunManagedTests(Platform platform, string test_destination = "", bool debug = true)
        {
            string        dllname;
            string        dlldir;
            string        abi;
            List <string> defines              = new List <string> ();
            var           managedTestCount     = CountTests(Path.Combine(XcodeProjectGenerator.TestsRootDirectory, "objc-cli/libmanaged/Tests/Tests.m"));
            var           xamariniOSTestCount  = CountTests(Path.Combine(XcodeProjectGenerator.TestsRootDirectory, "objcgentest/xcodetemplate/ios/test/iosTests.m"));
            var           xamarinMacTestCount  = CountTests(Path.Combine(XcodeProjectGenerator.TestsRootDirectory, "objcgentest/xcodetemplate/macos/test/macTests.m"));
            var           xamarintvOSTestCount = CountTests(Path.Combine(XcodeProjectGenerator.TestsRootDirectory, "objcgentest/xcodetemplate/tvos/test/tvosTests.m"));

            switch (platform)
            {
            case Platform.macOSFull:
                dlldir  = "macos-full";
                dllname = "managed-macos-full.dll";
                defines.Add("XAMARIN_MAC=1");
                defines.Add("XAMARIN_MAC_FULL=1");
                abi = "x86_64";                 // FIXME: fat XM apps not supported yet
                managedTestCount += xamarinMacTestCount;
                break;

            case Platform.macOSSystem:
                dlldir  = "macos-system";
                dllname = "managed-macos-system.dll";
                defines.Add("XAMARIN_MAC=1");
                defines.Add("XAMARIN_MAC_SYSTEM=1");
                abi = "x86_64";                 // FIXME: fat XM apps not supported yet
                managedTestCount += xamarinMacTestCount;
                break;

            case Platform.macOSModern:
                dlldir  = "macos-modern";
                dllname = "managed-macos-modern.dll";
                defines.Add("XAMARIN_MAC=1");
                defines.Add("XAMARIN_MAC_MODERN=1");
                abi = "x86_64";                 // FIXME: fat XM apps not supported yet
                managedTestCount += xamarinMacTestCount;
                break;

            case Platform.macOS:
                dlldir  = "generic";
                dllname = "managed.dll";
                abi     = "i386,x86_64";
                break;

            case Platform.iOS:
                dlldir  = "ios";
                dllname = "managed-ios.dll";
                defines.Add("XAMARIN_IOS=1");
                abi = "armv7,arm64,i386,x86_64";
                managedTestCount += xamariniOSTestCount;
                break;

            case Platform.tvOS:
                dlldir  = "tvos";
                dllname = "managed-tvos.dll";
                defines.Add("XAMARIN_TVOS=1");
                abi = "arm64,x86_64";
                managedTestCount += xamarintvOSTestCount;
                break;

            default:
                throw new NotImplementedException();
            }
            defines.Add("TEST_FRAMEWORK=1");

            var tmpdir        = Cache.CreateTemporaryDirectory();
            var configuration = debug ? "Debug" : "Release";
            var dll_path      = Path.Combine(XcodeProjectGenerator.TestsRootDirectory, "managed", dlldir, "bin", configuration, dllname);

            // This will build all the managed.dll variants, which is easier than calculating the relative path _as the makefile sees it_ to pass as the target.
            Asserts.RunProcess("make", $"all CONFIG={configuration} -C {Embedder.Quote (Path.Combine (XcodeProjectGenerator.TestsRootDirectory, "managed"))}", "build " + Path.GetFileName(dll_path));

            var outdir      = tmpdir + "/out";
            var projectName = "foo";
            var args        = new List <string> ();

            if (debug)
            {
                args.Add("--debug");
            }
            args.Add(dll_path);
            args.Add("-c");
            args.Add($"--outdir={outdir}");
            args.Add("--target=framework");
            args.Add($"--platform={platform}");
            args.Add($"--abi={abi}");
            Asserts.Generate("generate", args.ToArray());

            var framework_path   = Path.Combine(outdir, Path.GetFileNameWithoutExtension(dll_path) + ".framework");
            var projectDirectory = XcodeProjectGenerator.Generate(platform, tmpdir, projectName, framework_path, defines: defines.ToArray());

            string output;
            var    builddir = Path.Combine(tmpdir, "xcode-build-dir");

            Asserts.RunProcess("xcodebuild", $"test -project {Embedder.Quote (projectDirectory)} -scheme Tests {test_destination} CONFIGURATION_BUILD_DIR={Embedder.Quote (builddir)}", out output, "run xcode tests");
            // assert the number of tests passed, so that we can be sure we actually ran all the tests. Otherwise it's very easy to ignore when a bug is causing tests to not be built.
            Assert.That(output, Does.Match($"Test Suite 'All tests' passed at .*\n\t Executed {managedTestCount} tests, with 0 failures"), "test count");
        }
Esempio n. 21
0
 public void CanConnect()
 {
     EnsureConnected();
     Assert.That(theirPort, Does.Match("\\b[0-9a-f]{8}\\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\\b[0-9a-f]{12}\\b"));
 }
Esempio n. 22
0
        public void AssertOutputMatches(string regex)
        {
            var allOutput = string.Join(Environment.NewLine, captured.Infos);

            Assert.That(allOutput, Does.Match(regex));
        }
        public void SameValueDifferentTypeRegexMatch(object expected, object actual)
        {
            var ex = Assert.Throws <AssertionException>(() => Assert.AreEqual(expected, actual));

            Assert.That(ex.Message, Does.Match(@"\s*Expected\s*:\s*.*\s*\(.+\)\r?\n\s*But\s*was\s*:\s*.*\s*\(.+\)"));
        }
Esempio n. 24
0
        public void GetOperationByNameFailtureOperationNotFound()
        {
            var ex = Assert.Throws <OperationNotFoundException>(() => new OperationHelper().GetOperationByName("FakeOperation"));

            Assert.That(ex.Message, Does.Match(@"Sorry, the operation '\w*' was not found."));
        }
Esempio n. 25
0
 public void ServerGuardWrongClass()
 {
     Assert.That(CompilationFinishedHook.WeaveFailed, Is.False);
     Assert.That(m_weaverErrors.Count, Is.EqualTo(1));
     Assert.That(m_weaverErrors[0], Does.Match("\\[Server\\] guard on non-NetworkBehaviour script"));
 }
        public async Task UsingValueTypeParameterOfDifferentTypeAsync()
        {
            var value      = 1;
            var queriables = new List <IQueryable <NumericEntity> >
            {
                db.NumericEntities.Where(o => o.Short == value),
                db.NumericEntities.Where(o => o.Short != value),
                db.NumericEntities.Where(o => o.Short >= value),
                db.NumericEntities.Where(o => o.Short <= value),
                db.NumericEntities.Where(o => o.Short > value),
                db.NumericEntities.Where(o => o.Short < value),

                db.NumericEntities.Where(o => o.NullableShort == value),
                db.NumericEntities.Where(o => o.NullableShort != value),
                db.NumericEntities.Where(o => o.NullableShort >= value),
                db.NumericEntities.Where(o => o.NullableShort <= value),
                db.NumericEntities.Where(o => o.NullableShort > value),
                db.NumericEntities.Where(o => o.NullableShort < value),

                db.NumericEntities.Where(o => o.NullableShort.Value == value),
                db.NumericEntities.Where(o => o.NullableShort.Value != value),
                db.NumericEntities.Where(o => o.NullableShort.Value >= value),
                db.NumericEntities.Where(o => o.NullableShort.Value <= value),
                db.NumericEntities.Where(o => o.NullableShort.Value > value),
                db.NumericEntities.Where(o => o.NullableShort.Value < value)
            };

            foreach (var query in queriables)
            {
                await(AssertTotalParametersAsync(
                          query,
                          1,
                          sql => Assert.That(sql, Does.Not.Contain("cast"))));
            }

            if (Sfi.Dialect is FirebirdDialect)
            {
                Assert.Ignore("Due to the regex bug in FirebirdClientDriver, the parameters are not casted.");
            }

            queriables = new List <IQueryable <NumericEntity> >
            {
                db.NumericEntities.Where(o => o.Short + value > value),
                db.NumericEntities.Where(o => o.Short - value > value),
                db.NumericEntities.Where(o => o.Short * value > value),

                db.NumericEntities.Where(o => o.NullableShort + value > value),
                db.NumericEntities.Where(o => o.NullableShort - value > value),
                db.NumericEntities.Where(o => o.NullableShort * value > value),

                db.NumericEntities.Where(o => o.NullableShort.Value + value > value),
                db.NumericEntities.Where(o => o.NullableShort.Value - value > value),
                db.NumericEntities.Where(o => o.NullableShort.Value * value > value),
            };

            var sameType = Sfi.Dialect.TryGetCastTypeName(NHibernateUtil.Int16.SqlType, out var shortCast) &&
                           Sfi.Dialect.TryGetCastTypeName(NHibernateUtil.Int32.SqlType, out var intCast) &&
                           shortCast == intCast;

            foreach (var query in queriables)
            {
                await(AssertTotalParametersAsync(
                          query,
                          1,
                          sql => {
                    // SQLiteDialect uses sql cast for transparentcast method
                    Assert.That(sql, !sameType || Sfi.Dialect is SQLiteDialect ? Does.Match("where\\s+cast") : (IResolveConstraint)Does.Not.Contain("cast"));
                    Assert.That(GetTotalOccurrences(sql, "cast"), Is.EqualTo(!sameType || Sfi.Dialect is SQLiteDialect ? 1 : 0));
                }));
            }
        }
Esempio n. 27
0
 public void SyncVarsNoHook()
 {
     Assert.That(CompilationFinishedHook.WeaveFailed, Is.True);
     Assert.That(m_weaverErrors.Count, Is.EqualTo(1));
     Assert.That(m_weaverErrors[0], Does.Match("SyncVar Hook function .* not found for"));
 }
Esempio n. 28
0
 public static void AssertFormats(this string actual, string expectedFormat1)
 {
     Assert.That(actual, Does.Match("^" + expectedFormat1 + "$"));
 }