コード例 #1
0
ファイル: Select.cs プロジェクト: jamietre/IQMap
        public void Contains()
        {
            var dog = IQ.From<Dog>("Name=@name", "Fido2").Single();

            Assert.IsTrue(IQ.From<Dog>().Contains(dog));
            dog = new Dog();

            Assert.IsFalse(IQ.From<Dog>().Contains(dog));
        }
コード例 #2
0
ファイル: To.cs プロジェクト: jamietre/IQMap
        public void Simple()
        {
            Dog target=new Dog();

            var firstDog = IQ.From<Dog>().To(target).ElementAt(1);

            Assert.AreEqual("Bulldog", firstDog.Breed, "The output object was correct");
            Assert.AreEqual("Bulldog", target.Breed, "The existing target object was correct");
            Assert.IsTrue(ReferenceEquals(firstDog, target));
        }
コード例 #3
0
ファイル: Create.cs プロジェクト: saneman1/IQMap
        public void Insert()
        {
            // use alternate table def for methods that alter data during testing
            var opts = IQ.GetQueryOptions(tableName: tempTable);
            var table = IQ.From<Dog>(opts);

            var dog = new Dog();
            dog.Name = "Fido";
            IQ.Save(dog,opts);

            var sameDog = table.Where("pk=@pk", dog.PK).Single();
            Assert.AreEqual("Fido",sameDog.Name);

            dog = new Dog();
            dog.Name="Spot";
            IQ.Save(dog,opts);

             sameDog = table.First("pk=@pk",dog.PK);
             Assert.AreEqual("Spot", sameDog.Name);
        }
コード例 #4
0
ファイル: To.cs プロジェクト: jamietre/IQMap
        public void Mixed()
        {
            Dog dog = new Dog();
            // should map the first record to dog
            bool anyDogs = IQ.From<Dog>().To(dog).Any();

            Assert.IsTrue(anyDogs);
            Assert.AreEqual(1, dog.PK, "The first record was mapped to Dog");

            dog.Name="test";
            anyDogs = IQ.From<Dog>().Where("1=2").Any();
            Assert.IsFalse(anyDogs);
            Assert.AreEqual("test",dog.Name);

            IQ.From<Dog>().To(dog).Take(5).Last();

            // this "target" business needs to be fixed
            //Assert.AreEqual(1, dog.PK);
            //Assert.AreEqual("Fido4", dog.Name);
        }