예제 #1
0
 public void GetById_Should_NotByNull()
 {
     using (var session = _store.OpenSession())
     {
         var first = session.GetById <EntityForGetByIdTests>(_dummyCars[0].Id);
         first.ShouldNotBe(null);
     }
 }
예제 #2
0
 public void IQueryable_Should_ImplementOrderBy()
 {
     using (var session = _store.OpenSession())
     {
         var cars = session.Query <EntityForLinqOrderByTests>().Where(c => c.PropertyOne == "Mazda").OrderBy(o => o.PropertyTwo).ToList();
         cars[0].PropertyTwo.ShouldBe("A");
         cars[1].PropertyTwo.ShouldBe("B");
     }
 }
예제 #3
0
 public void GetAllCreatesTheTableIfItDoesNotExist()
 {
     using (var session = _store.OpenSession())
     {
         var things = session.GetAll <SomeTestClassThatNoOneWillEverUse>().ToList();
         things.Count.ShouldBe(0);
     }
 }
예제 #4
0
 public void GetAllCreatesTheTableIfItDoesNotExist()
 {
     var store = new TestStore();
     using (var session = store.OpenSession())
     {
         var things = session.GetAll<SomeTestClassThatNoOneWillEverUse>().ToList();
         things.Count.ShouldBe(0);
     }
 }
예제 #5
0
        public void SingleQuotes_ShouldBe_EscapedWhenSaving()
        {
            _entity = new EntityForCorrectEscapingTests()
            {
                Id = Guid.NewGuid(), PropertyOne = "Kia", PropertyTwo = "Cee'd"
            };


            //save the car
            using (var session = _store.OpenSession())
            {
                session.Store(_entity);
                session.SaveChanges();
            }

            //retrieve and check the make and model are correct
            using (var session = _store.OpenSession())
            {
                var savedCar = session.GetById <EntityForCorrectEscapingTests>(_entity.Id);
                savedCar.PropertyTwo.ShouldBe("Cee'd");
                savedCar.PropertyOne.ShouldBe("Kia");
            }
        }
예제 #6
0
        public GetByIdTests(DocumentStoreBaseFixture data)
        {
            _store     = data.TestStore;
            _dummyCars = new Fixture().CreateMany <EntityForGetByIdTests>().ToList();
            using (var session = _store.OpenSession())
            {
                foreach (var car in _dummyCars)
                {
                    session.Store(car);
                }

                session.SaveChanges();
            }
        }
예제 #7
0
        public void SingleQuotes_ShouldBe_EscapedWhenSaving()
        {
            var car = new Car();
            car.Id = Guid.NewGuid();
            car.Make = "Kia";
            car.Model = "Cee'd";

            var store = new TestStore();
            //save the car
            using (var session = store.OpenSession())
            {
                session.Store(car);
                session.SaveChanges();
            }

            //retrieve and check the make and model are correct
            using (var session = store.OpenSession())
            {
                var savedCar = session.GetById<Car>(car.Id);
                savedCar.Model.ShouldBe("Cee'd");
                savedCar.Make.ShouldBe("Kia");

            }
        }
예제 #8
0
        public LinqOrderByTests(DocumentStoreBaseFixture data)
        {
            _store = data.TestStore;

            var carA = new Fixture().Build <EntityForLinqOrderByTests>()
                       .With(x => x.PropertyOne, "Mazda")
                       .With(y => y.PropertyTwo, "A")
                       .Create();

            var carB = new Fixture().Build <EntityForLinqOrderByTests>()
                       .With(x => x.PropertyOne, "Mazda")
                       .With(y => y.PropertyTwo, "B")
                       .Create();

            using (var session = _store.OpenSession())
            {
                session.Store(carA);
                session.Store(carB);
                session.SaveChanges();
            }
        }
예제 #9
0
        public LinqOrderByTests()
        {
            _testStore = new StoreInfo();
            _store = new TestStore();


            var carA = new Fixture().Build<Car>()
              .With(x => x.Make, "Mazda")
              .With(y => y.Model, "A")
              .Create();

            var carB = new Fixture().Build<Car>()
                .With(x => x.Make, "Mazda")
                .With(y => y.Model, "B")
                .Create();

            using (var session = _store.OpenSession())
            {
                session.Store<Car>(carA);
                session.Store<Car>(carB);
                session.SaveChanges();
            }
        }
예제 #10
0
 public void Store_Should_OpenSession()
 {
     using (var session = _store.OpenSession())
     {
         //not really doing anything
     }
 }