Exemple #1
0
        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));
        }
Exemple #2
0
        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));
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }