Exemplo n.º 1
0
        public void CompoundKeyRepositoryNoGenerics_Should_Work()
        {
            var dbPath = EfDataDirectoryFactory.Build();

            Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0");
            ICompoundKeyRepository <User> repository = new EfCompoundKeyRepository <User>(new TestObjectEntities("Data Source=" + dbPath));

            repository.Add(new User {
                Username = "******", Age = 21, FullName = "Jeff - 21"
            });
            repository.Add(new User {
                Username = "******", Age = 31, FullName = "Jeff - 31"
            });
            repository.Add(new User {
                Username = "******", Age = 41, FullName = "Jeff - 41"
            });

            repository.Add(new User {
                Username = "******", Age = 31, FullName = "Ben - 31"
            });
            repository.Add(new User {
                Username = "******", Age = 41, FullName = "Ben - 41"
            });
            repository.Add(new User {
                Username = "******", Age = 51, FullName = "Ben - 51"
            });

            repository.Get("jeff", 31).FullName.ShouldEqual("Jeff - 31");
            repository.Get("ben", 31).FullName.ShouldEqual("Ben - 31");
            repository.Get("jeff", 41).FullName.ShouldEqual("Jeff - 41");

            repository.FindAll(x => x.Age == 31).Count().ShouldEqual(2);
        }
Exemplo n.º 2
0
        public void CompoundKeyRepositoryNoGenerics_Should_Work()
        {
            var dbPath = EfDataDirectoryFactory.Build();
            ICompoundKeyRepository <User> repository = new EfCompoundKeyRepository <User>(new TestObjectContext("Data Source=" + dbPath));

            repository.Add(new User {
                Username = "******", Age = 21, FullName = "Jeff - 21"
            });
            repository.Add(new User {
                Username = "******", Age = 31, FullName = "Jeff - 31"
            });
            repository.Add(new User {
                Username = "******", Age = 41, FullName = "Jeff - 41"
            });

            repository.Add(new User {
                Username = "******", Age = 31, FullName = "Ben - 31"
            });
            repository.Add(new User {
                Username = "******", Age = 41, FullName = "Ben - 41"
            });
            repository.Add(new User {
                Username = "******", Age = 51, FullName = "Ben - 51"
            });

            repository.Get("jeff", 31).FullName.ShouldBe("Jeff - 31");
            repository.Get("ben", 31).FullName.ShouldBe("Ben - 31");
            repository.Get("jeff", 41).FullName.ShouldBe("Jeff - 41");

            repository.FindAll(x => x.Age == 31).Count().ShouldBe(2);
        }
        public void CompoundKeyRepositoryNoGenerics_Should_Work()
        {
            var dbPath = EfDataDirectoryFactory.Build();
            Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0");
            ICompoundKeyRepository<User> repository = new EfCompoundKeyRepository<User>(new TestObjectEntities("Data Source=" + dbPath));

            repository.Add(new User { Username = "******", Age = 21, FullName = "Jeff - 21" });
            repository.Add(new User { Username = "******", Age = 31, FullName = "Jeff - 31" });
            repository.Add(new User { Username = "******", Age = 41, FullName = "Jeff - 41" });

            repository.Add(new User { Username = "******", Age = 31, FullName = "Ben - 31" });
            repository.Add(new User { Username = "******", Age = 41, FullName = "Ben - 41" });
            repository.Add(new User { Username = "******", Age = 51, FullName = "Ben - 51" });

            repository.Get("jeff", 31).FullName.ShouldEqual("Jeff - 31");
            repository.Get("ben", 31).FullName.ShouldEqual("Ben - 31");
            repository.Get("jeff", 41).FullName.ShouldEqual("Jeff - 41");

            repository.FindAll(x => x.Age == 31).Count().ShouldEqual(2);
        }