Пример #1
0
        public void Query()
        {
            var data = new List <Widget>();

            for (var i = 0; i < 10; i++)
            {
                data.Add(new Widget
                {
                    Description = "A widget",
                    Expiration  = DateTime.Now.AddYears(1),
                    Name        = "Widget",
                    Price       = 9.99m,
                    Size        = i
                });
            }

            var widgets = new MongoyList <Widget>(Host, Database, Collection);

            widgets.Add(data);

            var query = from w in widgets
                        where w.Size > 5 && w.Size < 8
                        select w;

            Assert.Equal(2, query.Count());
        }
Пример #2
0
        public void Delete()
        {
            var widget = new Widget()
            {
                Description = "A widget",
                Expiration = DateTime.Now.AddYears(1),
                Name = "Widget",
                Price = 9.99m,
                Size = 2
            };

            var widgets = new MongoyList<Widget>(Host, Database, Collection);
            widgets.Add(widget);
            widgets.Remove(widget);

            Assert.Equal(0, _dbVerifier.Count());
        }
Пример #3
0
        public void Delete()
        {
            var widget = new Widget()
            {
                Description = "A widget",
                Expiration  = DateTime.Now.AddYears(1),
                Name        = "Widget",
                Price       = 9.99m,
                Size        = 2
            };

            var widgets = new MongoyList <Widget>(Host, Database, Collection);

            widgets.Add(widget);
            widgets.Remove(widget);

            Assert.Equal(0, _dbVerifier.Count());
        }
Пример #4
0
        public void Update()
        {
            var widget = new Widget()
            {
                Description = "A widget",
                Expiration  = DateTime.Now.AddYears(1),
                Name        = "Widget",
                Price       = 9.99m,
                Size        = 2
            };

            var widgets = new MongoyList <Widget>(Host, Database, Collection);

            widgets.Add(widget);

            widget.Name = "I updated this!!";
            widgets.Flush();

            var updatedWidget = _dbVerifier.Find(widget.Id);

            Assert.Equal(widget.Name, updatedWidget.Name);
        }
Пример #5
0
        public void WriteALot()
        {
            var data = new List <Widget>();

            for (var i = 0; i < 10000; i++)
            {
                data.Add(new Widget
                {
                    Description = "A widget",
                    Expiration  = DateTime.Now.AddYears(1),
                    Name        = "Widget",
                    Price       = 9.99m,
                    Size        = i
                });
            }

            var widgets = new MongoyList <Widget>(Host, Database, Collection);

            widgets.Add(data);

            Assert.Equal(data.Count, widgets.Count);
            Assert.Equal(data.Count, _dbVerifier.Count());
        }
Пример #6
0
        public void Query()
        {
            var data = new List<Widget>();
            for (var i = 0; i < 10; i++)
            {
                data.Add(new Widget
                {
                    Description = "A widget",
                    Expiration = DateTime.Now.AddYears(1),
                    Name = "Widget",
                    Price = 9.99m,
                    Size = i
                });
            }

            var widgets = new MongoyList<Widget>(Host, Database, Collection);
            widgets.Add(data);

            var query = from w in widgets
                        where w.Size > 5 && w.Size < 8
                        select w;

            Assert.Equal(2, query.Count());
        }
Пример #7
0
        public void WriteALot()
        {
            var data = new List<Widget>();
            for (var i = 0; i < 10000; i++)
            {
                data.Add(new Widget
                    {
                        Description = "A widget",
                        Expiration = DateTime.Now.AddYears(1),
                        Name = "Widget",
                        Price = 9.99m,
                        Size = i
                    });
            }

            var widgets = new MongoyList<Widget>(Host, Database, Collection);
            widgets.Add(data);

            Assert.Equal(data.Count, widgets.Count);
            Assert.Equal(data.Count, _dbVerifier.Count());
        }
Пример #8
0
        public void Update()
        {
            var widget = new Widget()
            {
                Description = "A widget",
                Expiration = DateTime.Now.AddYears(1),
                Name = "Widget",
                Price = 9.99m,
                Size = 2
            };

            var widgets = new MongoyList<Widget>(Host, Database, Collection);
            widgets.Add(widget);

            widget.Name = "I updated this!!";
            widgets.Flush();

            var updatedWidget = _dbVerifier.Find(widget.Id);
            Assert.Equal(widget.Name, updatedWidget.Name);
        }