Xunit.Assert.True(bool)

Here are the examples of the csharp api Xunit.Assert.True(bool) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

523 Examples 7

19 View Source File : GridifyNestedCollectionTests.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void Filtering_OnSecondLevelNestedProperty()
      {
         var gm = new GridifyMapper<Level2>()
            .GenerateMappings()
            .AddMap("prop1", l2 => l2.Level3List.Select(l3 => l3.Property1));


         var actual = _fakeRepository2Nesting.AsQueryable()
            .ApplyFiltering("prop1 <= 3", gm)
            .ToList();

         var expected = _fakeRepository2Nesting.Where(q => q.Level3List.Any(z => z.Property1 <= 3)).ToList();

         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyEntityFrameworkSqlTests.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void ApplyFiltering_GreaterThanBetweenTwoStringsInEF_SqlServerProvider_EnableCompatibilityLayer()
      {
         GridifyGlobalConfiguration.EnableEnreplacedyFrameworkCompatibilityLayer();
         var sb = new StringBuilder();
         sb.AppendLine("DECLARE @__Value_0 nvarchar(4000) = N'h';");
         sb.AppendLine("SELECT [u].[Id], [u].[CreateDate], [u].[FkGuid], [u].[Name]");
         sb.AppendLine("FROM [Users] AS [u]");
         sb.AppendLine("WHERE [u].[Name] > @__Value_0");

         var actual = _dbContext.Users.ApplyFiltering("name > h").ToQueryString();
         replacedert.True(string.Compare(
            sb.ToString(),
            actual,
            CultureInfo.CurrentCulture,
            CompareOptions.IgnoreCase | CompareOptions.IgnoreSymbols) == 0);
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact] // issue #27
      public void ApplyFiltering_GreaterThanBetweenTwoStrings()
      {
         var actual = _fakeRepository.AsQueryable().ApplyFiltering("name > ali").ToList();

         var expected = _fakeRepository.Where(q => string.Compare(q.Name, "ali", StringComparison.Ordinal) > 0).ToList();
         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void Gridify_ActionOverload()
      {
         var actual = _fakeRepository.AsQueryable()
            .Gridify(q =>
            {
               q.Filter = "name=John";
               q.PageSize = 13;
               q.OrderBy = "name desc";
            });

         var query = _fakeRepository.AsQueryable().Where(q => q.Name == "John").OrderByDescending(q => q.Name);
         var totalItems = query.Count();
         var items = query.Skip(-2).Take(15).ToList();
         var expected = new Paging<TestClreplaced>() { Data = items, Count = totalItems };

         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected.Data.Count(), actual.Data.Count());
         replacedert.True(actual.Data.Any());
         replacedert.Equal(expected.Data.First().Id, actual.Data.First().Id);
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact] // issue #27
      public void ApplyFiltering_GreaterThanOrEqual_CaseInsensitive_BetweenTwoStrings()
      {
         var actual = _fakeRepository.AsQueryable().ApplyFiltering("name >= j/i").ToList();
         var expected = _fakeRepository.Where(q => string.Compare(q.Name, "j", StringComparison.OrdinalIgnoreCase) >= 0).ToList();

         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void ApplyFiltering_UsingChildClreplacedProperty()
      {
         var gq = new GridifyQuery { Filter = "Child_Name=Bob" };
         var gm = new GridifyMapper<TestClreplaced>()
            .GenerateMappings()
            .AddMap("Child_name", q => q.ChildClreplaced!.Name);

         var actual = _fakeRepository.AsQueryable()
            .Where(q => q.ChildClreplaced != null)
            .ApplyFiltering(gq, gm)
            .ToList();

         var expected = _fakeRepository.Where(q => q.ChildClreplaced is { Name: "Bob" }).ToList();
         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : EntityFramework6Tests.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void EnreplacedyFramework6_OrderBySupport() // Issue #8
      {
         var connection = GetConnection();

         using (var context = new EnreplacedyContext(connection))
         {
            var gm = new GridifyQuery() { OrderBy = "name desc" };
            var expected = context.Customers.ApplyOrdering(gm).ToList();
            var actual = context.Customers
                           .OrderByDescending(q => q.Name)
                           .ToList();
            replacedert.True(actual.Any());
            replacedert.Equal(expected.First(),actual.First());
            replacedert.Equal(expected,actual);
         }
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void ApplyEverything_EmptyGridifyQuery()
      {
         var gq = new GridifyQuery();

         var actual = _fakeRepository.AsQueryable()
            .ApplyFilteringOrderingPaging(gq)
            .ToList();

         var expected = _fakeRepository.Skip(0).Take(GridifyExtensions.DefaultPageSize).ToList();

         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : ApplicationPoolStopTest.cs
License : Apache License 2.0
Project Creator : aspnet

[Theory, Trait("FunctionalTests", "General")]
        [InlineData(HostType.HttpListener)]
        [InlineData(HostType.IIS)]
        public void ApplicationPoolStop(HostType hostType)
        {
            var serverInstance = new NotificationServer();
            serverInstance.StartNotificationService();
            try
            {
                using (ApplicationDeployer deployer = new ApplicationDeployer())
                {
                    string applicationUrl = deployer.Deploy(hostType, Configuration);
                    replacedert.True(HttpClientUtility.GetResponseTextFromUrl(applicationUrl) == "SUCCESS");

                    if (hostType == HostType.IIS)
                    {
                        string webConfig = deployer.GetWebConfigPath();
                        string webConfigContent = File.ReadAllText(webConfig);
                        File.WriteAllText(webConfig, webConfigContent);
                    }
                }

                bool receivedNotification = serverInstance.NotificationReceived.WaitOne(20 * 1000);
                replacedert.True(receivedNotification, "Cancellation token was not issued on closing host");
            }
            finally
            {
                serverInstance.Dispose();
            }
        }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void ApplyFiltering_NotStartsWith()
      {
         const string gq = "name!^A";

         var actual = _fakeRepository.AsQueryable()
            .ApplyFiltering(gq)
            .ToList();

         var expected = _fakeRepository.Where(q => !q.Name!.StartsWith("A")).ToList();

         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact] // issue #34
      public void ApplyFiltering_UnmappedFields_ShouldSkipWhenIgnored()
      {
         var gm = new GridifyMapper<TestClreplaced>(configuration => configuration.IgnoreNotMappedFields = true)
            .AddMap("Id", q => q.Id);
      
         // name=*a filter should be ignored
         var actual = _fakeRepository.AsQueryable().ApplyFiltering("name=*a, id>15", gm).ToList();
         var expected = _fakeRepository.Where(q => q.Id > 15).ToList();
      
         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact] // issue #25
      public void ApplyFiltering_NotEqual_ProcessingNullOrDefaultValue()
      {
         var actual = _fakeRepository.AsQueryable().ApplyFiltering("tag!=").ToList();
         var expected = _fakeRepository.Where(q => !string.IsNullOrEmpty(q.Tag)).ToList();
         var expected2 = _fakeRepository.Where(q => q.Tag is not null && q.Tag != "").ToList();

         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected2.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.Equal(expected2, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void ApplyFiltering_ComplexWithParenthesis()
      {
         var actual = _fakeRepository.AsQueryable()
            .ApplyFiltering("(name=*J|name=*S),(Id<5)")
            .ToList();
         var expected = _fakeRepository.Where(q => (q.Name!.Contains("J") || q.Name.Contains("S")) && q.Id < 5).ToList();
         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyNestedCollectionTests.cs
License : MIT License
Project Creator : alirezanet

[Fact] //https://github.com/alirezanet/Gridify/issues/17 #17
      public void Filtering_OnThirdLevelNestedPropertyWithMultipleUnChainedConditions()
      {
         var gm = new GridifyMapper<Level1>()
            .GenerateMappings()
            .AddMap("Level2List_Level3List_Property1", l1 => l1.Level2List.SelectMany(l2 => l2.Level3List).Select(l3 => l3.Property1))
            .AddMap("Level2List_Id", l1 => l1.Level2List.Select(l2 => l2.Id));

         var actual = _fakeRepository3Nesting.AsQueryable()
            .ApplyFiltering("Level2List_Id = 101, Level2List_Level3List_Property1 >= 3,id < 10", gm)
            .ToList();


         var expected = _fakeRepository3Nesting.AsQueryable().Where(
            l1 => l1.Level2List != null && l1.Level2List.Any(l2 => l2.Id == 101) &&
                  l1.Level2List.Any(l2 => l2.Level3List.Any(l3 => l3.Property1 >= 3))).ToList();

         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void ApplyFiltering_CustomConvertor()
      {
         const string gq = "name=liam";
         var gm = new GridifyMapper<TestClreplaced>()
            .GenerateMappings()
            .AddMap("name", q => q.Name, q => q.ToUpper()); // using client side Custom convertor

         var actual = _fakeRepository.AsQueryable()
            .ApplyFiltering(gq, gm)
            .ToList();

         var expected = _fakeRepository.Where(q => q.Name == "LIAM").ToList();
         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyNestedCollectionTests.cs
License : MIT License
Project Creator : alirezanet

[Fact] // issue #29 https://github.com/alirezanet/Gridify/issues/29 
      public void ApplyFiltering_UsingSubCollection_PreplacedIndexes()
      {
         var gm = new GridifyMapper<Level2>()
            .GenerateMappings()
            .AddMap("l3p2", (l1, index) => l1.Level3List[index].Property2);
         
         var expected = _fakeRepository2Nesting.Where(q => q.Level3List[0].Property2 > 50).ToList();
         var actual = _fakeRepository2Nesting.AsQueryable().ApplyFiltering("l3p2[1] > 50", gm).ToList();
         
         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void ApplyFiltering_CaseInsensitiveSearch() //issue #21
      {
         var gq = new GridifyQuery { Filter = "name=BOB/i " };

         var actual = _fakeRepository.AsQueryable()
            .ApplyFiltering(gq)
            .ToList();

         var expected = _fakeRepository.Where(q => q.Name!.ToLower() == "BOB".ToLower()).ToList();
         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : EntityFramework6Tests.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void EnreplacedyFramework6_FilteringAndOrdering() // Issue #8
      {
         var connection = GetConnection();

         using (var context = new EnreplacedyContext(connection))
         {
            var gm = new GridifyQuery() { OrderBy = "name desc" , Filter = "id > 3"};
            var expected = context.Customers.ApplyFilteringAndOrdering(gm).ToList();
            var actual = context.Customers
               .Where(q=>q.Id > 3)   
               .OrderByDescending(q => q.Name)
               .ToList();
            replacedert.True(actual.Any());
            replacedert.Equal(expected.First(),actual.First());
            replacedert.Equal(expected,actual);
         }
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Theory]
      [InlineData(@" name =\(LI\,AM\)", "(LI,AM)")]
      [InlineData(@" name =jessi=ca", "jessi=ca")]
      [InlineData(@" name =\\Liam", @"\Liam")]
      [InlineData(@" name =LI \| AM", @"LI | AM")]
      public void ApplyFiltering_EscapeSpecialCharacters(string textFilter, string rawText)
      {
         var gq = new GridifyQuery { Filter = textFilter };
         var actual = _fakeRepository.AsQueryable()
            .ApplyFiltering(gq)
            .ToList();
         var expected = _fakeRepository.Where(q => q.Name == rawText).ToList();
         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void ApplyPaging_UsingDefaultValues()
      {
         var gq = new GridifyQuery();
         var actual = _fakeRepository.AsQueryable()
            .ApplyPaging(gq)
            .ToList();

         // just returning first page with default size 
         var expected = _fakeRepository.Take(GridifyExtensions.DefaultPageSize).ToList();

         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact] // issue #27
      public void ApplyFiltering_LessThanOrEqualBetweenTwoStrings()
      {
         var actual = _fakeRepository.AsQueryable().ApplyFiltering("name <= l").ToList();
         var expected = _fakeRepository.Where(q => string.Compare(q.Name, "l", StringComparison.Ordinal) <= 0).ToList();

         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact] // issue #27
      public void ApplyFiltering_GreaterThanOrEqualBetweenTwoStrings()
      {
         var actual = _fakeRepository.AsQueryable().ApplyFiltering("name >= c").ToList();
         var expected = _fakeRepository.Where(q => string.Compare(q.Name, "c", StringComparison.Ordinal) >= 0).ToList();

         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void ApplyFiltering_SingleGuidField()
      {
         var guidString = "e2cec5dd-208d-4bb5-a852-50008f8ba366";
         var guid = Guid.Parse(guidString);
         var gq = new GridifyQuery { Filter = "myGuid=" + guidString };
         var actual = _fakeRepository.AsQueryable()
            .ApplyFiltering(gq)
            .ToList();
         var expected = _fakeRepository.Where(q => q.MyGuid == guid).ToList();
         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact] // issue #25
      public void ApplyFiltering_Equal_ProcessingNullOrDefaultValue()
      {
         var actual = _fakeRepository.AsQueryable().ApplyFiltering("tag=").ToList();
         var expected = _fakeRepository.Where(q => string.IsNullOrEmpty(q.Tag)).ToList();
         var expected2 = _fakeRepository.Where(q => q.Tag is null or "").ToList();

         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected2.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.Equal(expected2, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void ApplyFiltering_EndsWith()
      {
         const string gq = "name $ li";

         var actual = _fakeRepository.AsQueryable()
            .ApplyFiltering(gq)
            .ToList();

         var expected = _fakeRepository.Where(q => q.Name!.EndsWith("li")).ToList();
         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact] // issue #33
      public void ApplyFiltering_WithSpaces()
      {
         var actual = _fakeRepository.AsQueryable().ApplyFiltering("name =ali reza").ToList();
         var expected = _fakeRepository.Where(q => q.Name == "ali reza" ).ToList();
         
         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact] // issue #25
      public void ApplyFiltering_Equal_ProcessingNullOrDefaultValueNonStringTypes()
      {
         var actual = _fakeRepository.AsQueryable().ApplyFiltering("myGuid=").ToList();
         var expected = _fakeRepository.Where(q => q.MyGuid == default).ToList();

         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void ApplyFiltering_MultipleCondition()
      {
         var actual = _fakeRepository.AsQueryable()
            .ApplyFiltering("name=Jack|name=Rose|id>=7")
            .ToList();
         var expected = _fakeRepository.Where(q => q.Name == "Jack" || q.Name == "Rose" || q.Id >= 7).ToList();
         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact] // issue #34
      public void ApplyOrdering_UnmappedFields_ShouldSkipWhenIgnored()
      {
         var gm = new GridifyMapper<TestClreplaced>(configuration => configuration.IgnoreNotMappedFields = true)
            .AddMap("Id", q => q.Id);
      
         // name orderBy should be ignored
         var actual = _fakeRepository.AsQueryable().ApplyOrdering("name,id", gm).ToList();
         var expected = _fakeRepository.OrderBy(q => q.Id ).ToList();
      
         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Theory]
      [InlineData(null)]
      [InlineData("")]
      public void ApplyFiltering_NullOrEmptyFilter_ShouldSkip(string? filter)
      {
         var gq = new GridifyQuery();
         if (filter == null)
            gq = null;
         else
            gq.Filter = filter;

         var actual = _fakeRepository.AsQueryable()
            .ApplyFiltering(gq)
            .ToList();

         var expected = _fakeRepository.ToList();
         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyNestedCollectionTests.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void Filtering_OnThirdLevelNestedProperty()
      {
         var gm = new GridifyMapper<Level1>()
            .GenerateMappings()
            .AddMap("prop1", l1 => l1.Level2List.SelectMany(l2 => l2.Level3List).Select(l3 => l3.Property1));


         var actual = _fakeRepository3Nesting.AsQueryable()
            .ApplyFiltering("prop1 <= 3", gm)
            .ToList();

         var expected = _fakeRepository3Nesting.Where(q => q.Level2List.Any(w => w.Level3List.Any(z => z.Property1 <= 3))).ToList();

         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void ApplyFiltering_NestedParenthesisWithSpace()
      {
         // we shouldn't add spaces for values 
         var gq = new GridifyQuery { Filter = " ( name =*J| ( name =*S , Id <5 ) )" };
         var actual = _fakeRepository.AsQueryable()
            .ApplyFiltering(gq)
            .ToList();
         var expected = _fakeRepository.Where(q => q.Name!.Contains("J") || q.Name.Contains("S") && q.Id < 5).ToList();
         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyNestedCollectionTests.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void Filtering_OnThirdLevelNestedPropertyWithMultipleUnChainedConditionsWithNestedParenthesis()
      {
         var gm = new GridifyMapper<Level1>()
            .GenerateMappings()
            .AddMap("Level2List_Level3List_Property1", l1 => l1.Level2List.SelectMany(l2 => l2.Level3List).Select(l3 => l3.Property1))
            .AddMap("Level2List_Id", l1 => l1.Level2List.Select(l2 => l2.Id));

         var actual = _fakeRepository3Nesting.AsQueryable()
            .ApplyFiltering("( (id < 10 ), Level2List_Id = 101, Level2List_Level3List_Property1 >= 3)", gm)
            .ToList();


         var expected = _fakeRepository3Nesting.AsQueryable().Where(
            l1 => l1.Level2List != null && l1.Level2List.Any(l2 => l2.Id == 101) &&
                  l1.Level2List.Any(l2 => l2.Level3List.Any(l3 => l3.Property1 >= 3))).ToList();

         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void ApplyFiltering_DuplicatefieldName()
      {
         const string gq = "name=John|name=Sara";
         var actual = _fakeRepository.AsQueryable()
            .ApplyFiltering(gq)
            .ToList();
         var expected = _fakeRepository.Where(q => (q.Name == "John") | (q.Name == "Sara")).ToList();
         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyNestedCollectionTests.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void Filtering_OnThirdLevelNestedPropertyUsingSecondLevelProp()
      {
         var gm = new GridifyMapper<Level1>()
            .GenerateMappings()
            .AddMap("lvl", l1 => l1.Level2List.Select(l2 => l2.ChildProp).SelectMany(sl2 => sl2.Level3List).Select(l3 => l3.Level));

         var actual = _fakeRepository3Nesting.AsQueryable()
            .ApplyFiltering("lvl < 2", gm)
            .ToList();

         var expected = _fakeRepository3Nesting.Where(l1 => l1.Level2List != null && l1.Level2List.Any(l2 => l2.ChildProp != null &&
            l2.ChildProp.Level3List != null &&
            l2.ChildProp.Level3List.Any(l3 => l3.Level < 2))).ToList();

         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void ApplyFiltering_CaseInsensitiveSearchUsingConvertor() //issue #21
      {
         var gq = new GridifyQuery { Filter = "name=BOB" };
         var gm = new GridifyMapper<TestClreplaced>()
            .AddMap("name", q => q.Name!.ToLower(), c => c.ToLower());

         var actual = _fakeRepository.AsQueryable()
            .ApplyFiltering(gq, gm)
            .ToList();

         var expected = _fakeRepository.Where(q => q.Name!.ToLower() == "BOB".ToLower()).ToList();
         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : Issue36Tests.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      private void UserReportTest1()
      {
         List<Level1> level1List = new List<Level1>();
         level1List.Add(new Level1());

         var gridifyMapper = new GridifyMapper<Level1>().GenerateMappings()
            .AddMap("level4_property1", (l1, index) => l1.Level2List.Select(x => x.Level3.Level4List[index].Property1));

         var gridifyQuery = new GridifyQuery() { Filter = "level4_property1[0] > 5" };
         var query = gridifyQuery.GetFilteringExpression(gridifyMapper);
         var expression = query.Compile();

         var actual = level1List.Where(expression).ToList();

         replacedert.Single(actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void ApplyFiltering_StartsWith()
      {
         const string gq = "name^A";

         var actual = _fakeRepository.AsQueryable()
            .ApplyFiltering(gq)
            .ToList();

         var expected = _fakeRepository.Where(q => q.Name!.StartsWith("A")).ToList();

         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : EntityFramework6Tests.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void EnreplacedyFramework6_OrderBySupportAscending() // Issue #8
      {
         var connection = GetConnection();

         using (var context = new EnreplacedyContext(connection))
         {
            var gm = new GridifyQuery() { OrderBy = "name" };
            var expected = context.Customers.ApplyOrdering(gm).ToList();
            var actual = context.Customers
               .OrderBy(q => q.Name)
               .ToList();
            replacedert.True(actual.Any());
            replacedert.Equal(expected.First(),actual.First());
            replacedert.Equal(expected,actual);
         }
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void ApplyFiltering_EscapeCaseInsensitiveSearch() //issue #21
      {
         var actual = _fakeRepository.AsQueryable()
            .ApplyFiltering(@"name=Case\/i")
            .ToList();

         var expected = _fakeRepository.Where(q => q.Name == "Case/i").ToList();
         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyEntityFrameworkTests.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void ApplyFiltering_GreaterThanBetweenTwoStringsInEF()
      {
         GridifyGlobalConfiguration.EnableEnreplacedyFrameworkCompatibilityLayer();

         var actual = _dbContext.Users.ApplyFiltering("name > h").ToList();
         var expected = _dbContext.Users.Where(q => string.Compare(q.Name, "h") > 0).ToList();

         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void ApplyFiltering_NullHandlingUsingCustomConvertor()
      {
         // create custom mapper
         var gm = new GridifyMapper<TestClreplaced>(q => q.AllowNullSearch = false).GenerateMappings();

         // map any string to related property , also use Client convertor to handle custom scenarios
         gm.AddMap("date", g => g.MyDateTime!, q => (q == "null" ? null : q)!);

         var actual = _fakeRepository.AsQueryable()
            .ApplyFiltering("date=null", gm)
            .ToList();

         var expected = _fakeRepository.Where(q => q.MyDateTime == null).ToList();
         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void ApplyFiltering_SingleField()
      {
         var actual = _fakeRepository.AsQueryable()
            .ApplyFiltering("name=John")
            .ToList();
         var expected = _fakeRepository.Where(q => q.Name == "John").ToList();
         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact] // issue #27
      public void ApplyFiltering_LessThanBetweenTwoStrings()
      {
         var actual = _fakeRepository.AsQueryable().ApplyFiltering("name < v").ToList();

         var expected = _fakeRepository.Where(q => string.Compare(q.Name, "v", StringComparison.Ordinal) < 0).ToList();
         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void ApplyFiltering_StartsWithOnNotStringsShouldNotThrowError()
      {
         const string gq = "Id^2";

         var actual = _fakeRepository.AsQueryable()
            .ApplyFiltering(gq)
            .ToList();

         var expected = _fakeRepository.Where(q => q.Id.ToString().StartsWith("2")).ToList();

         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void ApplyFiltering_SingleField_GridifyQuery()
      {
         var gq = new GridifyQuery { Filter = "name=John" };
         var actual = _fakeRepository.AsQueryable()
            .ApplyFiltering(gq)
            .ToList();
         var expected = _fakeRepository.Where(q => q.Name == "John").ToList();
         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void ApplyFiltering_NullHandlingUsingMapper()
      {
         // create custom mapper
         var gm = new GridifyMapper<TestClreplaced>(q => q.AllowNullSearch = true) // default is true
            .GenerateMappings();

         var actual = _fakeRepository.AsQueryable()
            .ApplyFiltering("MyDateTime=null", gm)
            .ToList();

         var expected = _fakeRepository.Where(q => q.MyDateTime == null).ToList();
         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void ApplyFiltering_SingleBrokenGuidField_NotEqual()
      {
         var brokenGuidString = "e2cec5dd-208d-4bb5-a852-";
         var gq = new GridifyQuery { Filter = "myGuid!=" + brokenGuidString };

         var actual = _fakeRepository.AsQueryable()
            .ApplyFiltering(gq)
            .ToList();

         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact]
      public void ApplyFiltering_NotEndsWith()
      {
         const string gq = "name !$ i";

         var actual = _fakeRepository.AsQueryable()
            .ApplyFiltering(gq)
            .ToList();

         var expected = _fakeRepository.Where(q => !q.Name!.EndsWith("i")).ToList();

         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

19 View Source File : GridifyExtensionsShould.cs
License : MIT License
Project Creator : alirezanet

[Fact] // issue #25
      public void ApplyFiltering_NotEqual_ProcessingNullOrDefaultValueNonStringTypes()
      {
         var actual = _fakeRepository.AsQueryable().ApplyFiltering("myGuid!=").ToList();
         var expected = _fakeRepository.Where(q => q.MyGuid != default).ToList();

         replacedert.Equal(expected.Count, actual.Count);
         replacedert.Equal(expected, actual);
         replacedert.True(actual.Any());
      }

See More Examples