Пример #1
0
        public void Can_generate_an_id_based_on_the_type_and_hilo_key_generator()
        {
            var document = new Example();

            using (var store = NewDocumentStore())
            {
                using (var session = store.OpenSession())
                {
                    session.Store(document);

                    // the id is set
                    document.Id.Should().Be("examples/1");
                }
            }
        }
Пример #2
0
        public void Can_change_id_seperator_because_slashes_scare_me()
        {
            var document = new Example();
            using (var store = NewDocumentStore())
            {
                // most web developers change the identity seperator
                // to work with ASP.NET MVC routes by altering the convention
                store.Conventions.IdentityPartsSeparator = "-";

                using (var session = store.OpenSession())
                {
                    session.Store(document);

                    // the id is set
                    document.Id.Should().Be("examples-1");
                }
            }
        }
Пример #3
0
        public static IList<Example> GetExamples(int count)
        {
            return Enumerable.Range(1, count)
                .Select(i =>
                        {
                            var example = new Example
                                          {
                                              Cost = Random.Next(1, 100),
                                              Date = DateTime.Now.AddDays(Random.Next(1, 100)),
                                              Manufacturer = string.Format("Company #{0}", Random.Next(1, 10)),
                                              Price = Random.Next(1, 100),
                                              Quantity = Random.Next(1, 100),
                                              Tags = new[] {
                                                               "product",
                                                               string.Format("tag #{0}", Random.Next(1, 5))
                                                           }.ToList()
                                          };

                            example.Tags.Add(example.Manufacturer);
                            return example;
                        }).ToList();
        }
Пример #4
0
        public void Can_store_lists_in_my_objects()
        {
            var document = new Example
            {
                Id = "crazy-lists",
                Tags = new[] { "this", "is", "freaking", "awesome" }
            };

            using (var store = NewDocumentStore())
            {
                using (var session = store.OpenSession())
                {
                    session.Store(document);
                    session.SaveChanges();

                    WaitForUserToContinueTheTest(store);
                }

                // we reload the document from the database
                // and we get the tags back.
                using (var session = store.OpenSession())
                {
                    session.Load<Example>("crazy-lists")
                        .Tags.Count
                        .Should().Be(4);
                }
            }
        }