public void CollectionAnyContainsSingleItem()
        {
            var item = "Bread - Dark Rye, Loaf";

            DataAssert.SameSequence(DataAssert.Data.SearchQuery <Listing>().Where(w => AzureSearchMethods.ContainsAny(w.Tags, item)).ToList(),
                                    DataAssert.Data.Memory <Listing>().Where(w => w.Tags.Any(q => q.Contains(item))).ToList());
        }
Пример #2
0
        public void given_empty_cache_and_valid_commit_function()
        {
            var cache = new LockingInMemoryCache();

            long?commitStoreVersion  = null;
            long?commitStreamVersion = null;

            cache.ConcurrentAppend("stream", GetEventBytes(1), (version, storeVersion) =>
            {
                commitStoreVersion  = storeVersion;
                commitStreamVersion = version;
            });

            Assert.AreEqual(1, commitStoreVersion, "commitStoreVersion");
            Assert.AreEqual(1, commitStreamVersion, "commitStreamVersion");

            Assert.AreEqual(1, cache.StoreVersion);

            var expected = new[]
            {
                CreateKey(1, 1, "stream"),
            };

            DataAssert.AreEqual(expected, cache.ReadStream("stream", 0, 100));
            DataAssert.AreEqual(expected, cache.ReadAll(0, 100));
        }
        public void CollectionAnyContainsManyItems()
        {
            var items = new[] { "Bread - Dark Rye, Loaf", "Beef - Striploin Aa" };

            DataAssert.SameSequence(DataAssert.Data.SearchQuery <Listing>().Where(w => AzureSearchMethods.ContainsAny(w.Tags, items)).ToList(),
                                    DataAssert.Data.Memory <Listing>().Where(w => w.Tags.Any(q => items.Contains(q))).ToList());
        }
        public void DataTableSerialize()
        {
            DataTable dt = new DataTable("MyTable");

            dt.Columns.Add("IntColumn", typeof(int));
            dt.Columns.Add("StringColumn", typeof(string));
            dt.Columns.Add("BoolColumn", typeof(bool));
            dt.Columns.Add("DateTimeColumn", typeof(DateTime));
            dt.Columns.Add("DoubleColumn", typeof(double));
            dt.Rows.Add((int)32, "row 1", true, new DateTime(2009, 9, 1), 213.45d);
            dt.Rows.Add((int)64, "row 2", false, new DateTime(2005, 5, 15), 124.95d);

            Serializer s = new Serializer();

            s.Settings.ExpressionHandlers.Insert(0, new DataTableExpressionHandler());
            s.Settings.Types.RegisterTypeConverter <Type>(new TypeToStringConverter()); // for DataType property of Column
            string result = s.Serialize(dt);

            DataTable dtResult = s.Deserialize <DataTable>(result);
            DataSet   expected = new DataSet();

            expected.Tables.Add(dt);

            DataSet actual = new DataSet();

            actual.Tables.Add(dtResult);
            DataAssert.AreDataEqual(expected, actual);
        }
Пример #5
0
 public void ProjectWithObjectInitializerAndContructorArgs()
 {
     DataAssert.Same <Listing>(q => q.OrderBy(x => x.CreatedAt).Select(x => new Listing(x.Id)
     {
         Title = x.Title
     }), useDefaultOrder: false);
 }
Пример #6
0
        public async void ToListAsyncReturnsCorrectResults()
        {
            var memory = DataAssert.Data.Memory <Listing>().Where(w => w.Price > MiddlePrice).OrderBy(w => w.Price).ToList();
            var search = await DataAssert.Data.SearchQuery <Listing>().Where(w => w.Price > MiddlePrice).OrderBy(w => w.Price).ToListAsync();

            DataAssert.SameSequence(memory, search);
        }
Пример #7
0
 public void given_tail_range()
 {
     DataAssert.AreEqual(new[]
     {
         CreateKey(3, 2, "stream1")
     }, Cache.ReadStream("stream1", 1, 1));
 }
Пример #8
0
        public void AreEqualDataColumn()
        {
            DataColumn d1 = new DataColumn("Col");
            DataColumn d2 = d1;


            DataAssert.AreEqual(d1, d2);
        }
Пример #9
0
 public void given_full_range()
 {
     DataAssert.AreEqual(new[]
     {
         CreateKey(1, 1, "stream1"),
         CreateKey(3, 2, "stream1")
     }, Cache.ReadStream("stream1", 0, int.MaxValue));
 }
Пример #10
0
 public void EqualToConstant()
 {
     DataAssert.Same <WebUser>(q => q.Where(w => Middle == w.Id));
     DataAssert.Same <WebUser>(q => q.Where(w => w.Id == Middle));
     DataAssert.Same <WebUser>(q => q.Where(w => w.Id.Equals(Middle)));
     DataAssert.Same <WebUser>(q => q.Where(w => Middle.Equals(w.Id)));
     DataAssert.Same <WebUser>(q => q.Where(w => Equals(w.Id, Middle)));
     DataAssert.Same <WebUser>(q => q.Where(w => Equals(Middle, w.Id)));
 }
Пример #11
0
 public void NotEqualToConstant()
 {
     DataAssert.Same <Listing>(q => q.Where(w => MiddlePrice != w.Price));
     DataAssert.Same <Listing>(q => q.Where(w => w.Price != MiddlePrice));
     DataAssert.Same <Listing>(q => q.Where(w => !w.Price.Equals(MiddlePrice)));
     DataAssert.Same <Listing>(q => q.Where(w => !MiddlePrice.Equals(w.Price)));
     DataAssert.Same <Listing>(q => q.Where(w => !Equals(w.Price, MiddlePrice)));
     DataAssert.Same <Listing>(q => q.Where(w => !Equals(MiddlePrice, w.Price)));
 }
Пример #12
0
        public void LuceneQueryRegex()
        {
            var item = "Smirnoff";

            DataAssert.Same(DataAssert.Data.SearchQuery <Listing>().LuceneQuery($"/.*{item}.*/").OrderBy(q => q.CreatedAt),
                            DataAssert.Data.Memory <Listing>()
                            .Where(w => w.Title.Contains(item, StringComparison.OrdinalIgnoreCase) ||
                                   w.Description.Contains(item, StringComparison.OrdinalIgnoreCase)).OrderBy(q => q.CreatedAt));
        }
Пример #13
0
        public void SimpleQuerySingleItem()
        {
            var item = "Vodka - Smirnoff";

            DataAssert.Same(DataAssert.Data.SearchQuery <Listing>().SimpleQuery($"'{item}'").OrderBy(q => q.CreatedAt),
                            DataAssert.Data.Memory <Listing>()
                            .Where(w => w.Title.Contains(item, StringComparison.OrdinalIgnoreCase) ||
                                   w.Description.Contains(item, StringComparison.OrdinalIgnoreCase)).OrderBy(q => q.CreatedAt));
        }
Пример #14
0
        public void SimpleQueryMultiItemAny()
        {
            var items = new[] { "Vestibulum", "aenean" };

            DataAssert.Same(DataAssert.Data.SearchQuery <Listing>().SimpleQuery(string.Join('|', items)).OrderBy(q => q.CreatedAt),
                            DataAssert.Data.Memory <Listing>()
                            .Where(w => items.Any(item => w.Description.Contains(item, StringComparison.OrdinalIgnoreCase)) ||
                                   items.Any(item => w.Title.Contains(item, StringComparison.OrdinalIgnoreCase))).OrderBy(q => q.CreatedAt));
        }
Пример #15
0
 public void CollectionNotAllContainsManyConstant()
 {
     DataAssert.SameSequence(
         DataAssert.Data.SearchQuery <Listing>().Where(w => !AzureSearchMethods
                                                       .ContainsAll(w.Tags, new[] { "Bread - Dark Rye, Loaf", "Beef - Striploin Aa" })).OrderBy(q => q.CreatedAt).ToList(),
         DataAssert.Data.Memory <Listing>().Where(w => w.Tags
                                                  .All(q => !new[] { "Bread - Dark Rye, Loaf", "Beef - Striploin Aa" }.Contains(q))).OrderBy(q => q.CreatedAt).ToList()
         );
 }
Пример #16
0
        public void SimpleQueryMultiItemOnlyTitle()
        {
            var items = new[] { "Vestibulum", "aenean" };

            DataAssert.Same(DataAssert.Data.SearchQuery <Listing>()
                            .SimpleQuery(string.Join(' ', items), searchFields: q => q.Title).OrderBy(q => q.CreatedAt),
                            DataAssert.Data.Memory <Listing>()
                            .Where(w => items.All(item => w.Title.Contains(item, StringComparison.OrdinalIgnoreCase))).OrderBy(q => q.CreatedAt));
        }
Пример #17
0
 public void NotEqualToConstant()
 {
     DataAssert.Same <WebUser>(q => q.Where(w => Middle != w.Id));
     DataAssert.Same <WebUser>(q => q.Where(w => w.Id != Middle));
     DataAssert.Same <WebUser>(q => q.Where(w => !w.Id.Equals(Middle)));
     DataAssert.Same <WebUser>(q => q.Where(w => !Middle.Equals(w.Id)));
     DataAssert.Same <WebUser>(q => q.Where(w => !Equals(w.Id, Middle)));
     DataAssert.Same <WebUser>(q => q.Where(w => !Equals(Middle, w.Id)));
 }
 public void EqualToConstant()
 {
     DataAssert.Same <Listing>(q => q.Where(w => Title == w.Title));
     DataAssert.Same <Listing>(q => q.Where(w => w.Title == Title));
     DataAssert.Same <Listing>(q => q.Where(w => w.Title.Equals(Title)));
     DataAssert.Same <Listing>(q => q.Where(w => Title.Equals(w.Title)));
     DataAssert.Same <Listing>(q => q.Where(w => Equals(w.Title, Title)));
     DataAssert.Same <Listing>(q => q.Where(w => Equals(Title, w.Title)));
 }
 public void NotEqualToConstant()
 {
     DataAssert.Same <Listing>(q => q.Where(w => Title != w.Title));
     DataAssert.Same <Listing>(q => q.Where(w => w.Title != Title));
     DataAssert.Same <Listing>(q => q.Where(w => !w.Title.Equals(Title)));
     DataAssert.Same <Listing>(q => q.Where(w => !Title.Equals(w.Title)));
     DataAssert.Same <Listing>(q => q.Where(w => !Equals(w.Title, Title)));
     DataAssert.Same <Listing>(q => q.Where(w => !Equals(Title, w.Title)));
 }
Пример #20
0
        public void CollectionNotAllContainsSingleItem()
        {
            var item = "Bread - Dark Rye, Loaf";

            DataAssert.SameSequence(
                DataAssert.Data.SearchQuery <Listing>()
                .Where(w => !AzureSearchMethods.ContainsAll(w.Tags, item)).OrderBy(q => q.CreatedAt).ToList(),
                DataAssert.Data.Memory <Listing>().Where(w => w.Tags.All(q => !q.Contains(item))).OrderBy(q => q.CreatedAt).ToList());
        }
Пример #21
0
 public void NotEqualToConstant()
 {
     DataAssert.Same <WebUser>(q => q.Where(w => Surname != w.Surname));
     DataAssert.Same <WebUser>(q => q.Where(w => w.Surname != Surname));
     DataAssert.Same <WebUser>(q => q.Where(w => !w.Surname.Equals(Surname)));
     DataAssert.Same <WebUser>(q => q.Where(w => !Surname.Equals(w.Surname)));
     DataAssert.Same <WebUser>(q => q.Where(w => !Equals(w.Surname, Surname)));
     DataAssert.Same <WebUser>(q => q.Where(w => !Equals(Surname, w.Surname)));
 }
Пример #22
0
 public void EqualToConstant()
 {
     DataAssert.Same <WebUser>(q => q.Where(w => Surname == w.Surname));
     DataAssert.Same <WebUser>(q => q.Where(w => w.Surname == Surname));
     DataAssert.Same <WebUser>(q => q.Where(w => w.Surname.Equals(Surname)));
     DataAssert.Same <WebUser>(q => q.Where(w => Surname.Equals(w.Surname)));
     DataAssert.Same <WebUser>(q => q.Where(w => Equals(w.Surname, Surname)));
     DataAssert.Same <WebUser>(q => q.Where(w => Equals(Surname, w.Surname)));
 }
Пример #23
0
        public void EqualToConstant()
        {
            DataAssert.Same <WebUser>(q => q.Where(w => w.Surname.Equals(Surname, StringComparison.InvariantCultureIgnoreCase)));
            DataAssert.Same <WebUser>(q => q.Where(w => Surname == w.Surname));
            DataAssert.Same <WebUser>(q => q.Where(w => w.Surname == Surname));

            DataAssert.Same <WebUser>(q => q.Where(w => Surname.Equals(w.Surname)));
            DataAssert.Same <WebUser>(q => q.Where(w => Equals(w.Surname, Surname)));
            DataAssert.Same <WebUser>(q => q.Where(w => Equals(Surname, w.Surname)));
        }
Пример #24
0
        public void given_matching_range()
        {
            var dataWithKeys = Cache.ReadAll(0, 3);

            DataAssert.AreEqual(new[]
            {
                CreateKey(1, 1, "stream1"),
                CreateKey(2, 1, "stream2"),
                CreateKey(3, 2, "stream1")
            }, dataWithKeys);
        }
Пример #25
0
        public void NotEqualToConstant()
        {
            var firstDate = DataAssert.Data.Memory <WebUser>().First().Joined;

            DataAssert.Same <WebUser>(q => q.Where(w => firstDate != w.Joined));
            DataAssert.Same <WebUser>(q => q.Where(w => w.Joined != firstDate));
            DataAssert.Same <WebUser>(q => q.Where(w => !w.Joined.Equals(firstDate)));
            DataAssert.Same <WebUser>(q => q.Where(w => !firstDate.Equals(w.Joined)));
            DataAssert.Same <WebUser>(q => q.Where(w => !Equals(w.Joined, firstDate)));
            DataAssert.Same <WebUser>(q => q.Where(w => !Equals(firstDate, w.Joined)));
        }
Пример #26
0
        public void NotEqualToConstant()
        {
            var firstDate = DataAssert.Data.Memory <Listing>().First().CreatedAt;

            DataAssert.Same <Listing>(q => q.Where(w => firstDate != w.CreatedAt));
            DataAssert.Same <Listing>(q => q.Where(w => w.CreatedAt != firstDate));
            DataAssert.Same <Listing>(q => q.Where(w => !w.CreatedAt.Equals(firstDate)));
            DataAssert.Same <Listing>(q => q.Where(w => !firstDate.Equals(w.CreatedAt)));
            DataAssert.Same <Listing>(q => q.Where(w => !Equals(w.CreatedAt, firstDate)));
            DataAssert.Same <Listing>(q => q.Where(w => !Equals(firstDate, w.CreatedAt)));
        }
Пример #27
0
        public void given_full_range()
        {
            var dataWithKeys = Cache.ReadAll(0, int.MaxValue);

            DataAssert.AreEqual(new[]
            {
                CreateKey(1, 1, "stream1"),
                CreateKey(2, 1, "stream2"),
                CreateKey(3, 2, "stream1")
            }, dataWithKeys);
        }
Пример #28
0
 public void SpatialFilterByDistance()
 {
     DataAssert.SameSequence(
         DataAssert.Data.SearchQuery <Listing>()
         .Where(w => AzureSearchMethods.Distance(w.Place, filterPoint) < 10000).OrderBy(q => q.CreatedAt).ToList(),
         DataAssert.Data.Memory <Listing>()
         .Where(w => w.Place != null && SpatialHelper.GetDistance(w.Place, filterPoint, DistanceUnit.Kilometers) < 10000)
         .OrderBy(q => q.CreatedAt)
         .ToList()
         );
 }
Пример #29
0
 public void SpatialOrderByDistance()
 {
     DataAssert.SameSequence(
         DataAssert.Data.SearchQuery <Listing>()
         .Where(q => q.Place != null)
         .OrderBy(w => AzureSearchMethods.Distance(w.Place, filterPoint)).Take(10).ToList(),
         DataAssert.Data.Memory <Listing>()
         .Where(q => q.Place != null)
         .OrderBy(w => SpatialHelper.GetDistance(w.Place, filterPoint, DistanceUnit.Kilometers))
         .Take(10)
         .ToList()
         );
 }
Пример #30
0
        public void SpatialOrderByDescendingDistance()
        {
            var expect = DataAssert.Data.SearchQuery <Listing>()
                         .Where(q => q.Place != null)
                         .OrderByDescending(w => AzureSearchMethods.Distance(w.Place, filterPoint)).Take(10).ToList();
            var actual = DataAssert.Data.Memory <Listing>()
                         .Where(q => q.Place != null)
                         .OrderByDescending(w => SpatialHelper.GetDistance(w.Place, filterPoint, double.MaxValue, DistanceUnit.Kilometers))
                         .Take(10)
                         .ToList();

            DataAssert.SameSequence(
                expect,
                actual
                );
        }