コード例 #1
0
        public void SelectDataInKeyValueFormatTest()
        {
            const string connectionString = @"Data Source=VLADIMIR5D4B\SQLSERVER;Initial Catalog=Crate;Integrated Security=true;";
            var dc = new SqlServerContext(connectionString, "");

            var p = new Person
            {
                Name = "John Doe",
                Age = 24,
                Email = "*****@*****.**"
            };

            var repository = new Repository("ConsoleApp");

            dc.Clear<Person>(repository);

            repository.Add(p);
            dc.SubmitChanges(repository);

            var people = dc.Select(repository.Name, "Person").ToList();

            Assert.AreEqual(4, people[0].Count());
        }
コード例 #2
0
        public void ClearItemsOfCertainTypeFromRepositoryTest()
        {
            const string connectionString = @"Data Source=VLADIMIR5D4B\SQLSERVER;Initial Catalog=Crate;Integrated Security=true;";
            var dc = new SqlServerContext(connectionString, "");

            var p = new Person
            {
                Name = "John Doe",
                Age = 24,
                Email = "*****@*****.**"
            };

            var repository = new Repository("ConsoleApp");

            repository.Add(p);
            dc.SubmitChanges(repository);

            dc.Clear<Person>(repository);

            var people = dc.Select<Person>(repository);
            Assert.AreEqual(0, people.Count());
        }
コード例 #3
0
        public void UpdateEntryTest()
        {
            const string connectionString = @"Data Source=VLADIMIR5D4B\SQLSERVER;Initial Catalog=Crate;Integrated Security=true;";
            var dc = new SqlServerContext(connectionString, "");

            var p = new Person
            {
                Name = "John Doe",
                Age = 24,
                Email = "*****@*****.**"
            };

            var repository = new Repository("ConsoleApp");

            dc.Clear<Person>(repository);

            repository.Add(p);
            dc.SubmitChanges(repository);

            var man = dc.Select<Person>(repository).First(c => c.Age == 24);
            man.Age = 35;

            repository.Update(man);
            dc.SubmitChanges(repository);

            var actual = dc.Select<Person>(repository).First(c => c.Age == 35);

            Assert.AreEqual(35, actual.Age);
        }