public void TestInsert()
        {
            Category category = new Category();
            category.Name = "toto";
            category.Guid = Guid.Empty;

            int key = (int)sqlMap.Insert("InsertCategoryGenerate", category);
            Assert.AreEqual(1, key);
        }
        public void TestInsertSelectKey()
        {
            Category category = new Category();
            category.Name = "toto";
            category.Guid = Guid.NewGuid();

            int key = (int)sqlMap.Insert("Category.InsertCategoryViaInsertStatement", category);
            Assert.AreEqual(1, key);
        }
Beispiel #3
0
        public void TestInsertCategoryViaParameterMap()
        {
            Category category = new Category();
            category.Name = "Cat";
            category.Guid = Guid.NewGuid();

            int key = (int)sqlMap.Insert("InsertCategoryViaParameterMap", category);
            Assert.AreEqual(1, key);
        }
Beispiel #4
0
        public void TestInsertAutonumberViaInsertQuery()
        {
            Category category = new Category();
            category.Name = "toto";
            category.Guid = Guid.NewGuid();

            int key = (int)sqlMap.Insert("InsertCategory", category);
            Assert.AreEqual(1, key);
        }
        public void TestMultipleResultClass()
        {
            Category category = new Category();
            category.Name = "toto";
            category.Guid = Guid.NewGuid();

            int key = (int)sqlMap.Insert("InsertCategory", category);

            IList list = sqlMap.QueryForList("GetMultipleResultClass", null);
            Assert.AreEqual(2, list.Count);
        }
Beispiel #6
0
        public void GenericTestGuidColumn()
        {
            Category category = new Category();
            category.Name = "toto";
            category.Guid = Guid.NewGuid();

            int key = (int)sqlMap.Insert("InsertCategory", category);

            Category categoryTest = sqlMap.QueryForObject<Category>("GetCategory", key);
            Assert.AreEqual(key, categoryTest.Id);
            Assert.AreEqual(category.Name, categoryTest.Name);
            Assert.AreEqual(category.Guid, categoryTest.Guid);
        }
Beispiel #7
0
        public void InsertTestSequenceViaProcedure()
        {
            Category category = new Category();
            category.Name = "Mapping object relational";

            sqlMap.Insert("InsertCategoryViaStoreProcedure", category);
            Assert.AreEqual(1, category.Id );

            category = new Category();
            category.Name = "Nausicaa";

            sqlMap.Insert("InsertCategoryViaStoreProcedure", category);
            Assert.AreEqual(2, category.Id );
        }
        public void TestDelete()
        {
            Category category = new Category();
            category.Name = "toto";
            category.Guid = Guid.NewGuid();

            int key = (int)sqlMap.Insert("InsertCategoryGenerate", category);
            category.Id = key;
            Assert.AreEqual(1, category.Id);

            sqlMap.Delete("DeleteCategoryGenerate", category);

            Category categoryRead = null;
            categoryRead = sqlMap.QueryForObject("GetCategory", key) as Category;

            Assert.IsNull(categoryRead);
        }
        public void TestSelectAll()
        {
            Category category = new Category();
            category.Name = "toto";
            category.Guid = Guid.NewGuid();

            int key = (int)sqlMap.Insert("InsertCategoryGenerate", category);
            Assert.AreEqual(1, key);

            category.Name = "toto";
            category.Guid = Guid.NewGuid();

            key = (int)sqlMap.Insert("InsertCategoryGenerate", category);
            Assert.AreEqual(2, key);

            IList categorieList = sqlMap.QueryForList("SelectAllCategoryGenerate",null) as IList;
            Assert.AreEqual(2, categorieList.Count);
        }
        public void TestUpdate()
        {
            Category category = new Category();
            category.Name = "Cat";
            category.Guid = Guid.NewGuid();

            int key = (int)sqlMap.Insert("InsertCategoryGenerate", category);
            category.Id = key;

            category.Name = "Dog";
            category.Guid = Guid.NewGuid();

            sqlMap.Update("UpdateCategoryGenerate", category);

            Category categoryRead = null;
            categoryRead = (Category) sqlMap.QueryForObject("GetCategory", key);

            Assert.AreEqual(category.Id, categoryRead.Id);
            Assert.AreEqual(category.Name, categoryRead.Name);
            Assert.AreEqual(category.Guid.ToString(), categoryRead.Guid.ToString());
        }
        public void TestSelectByPK()
        {
            Category category = new Category();
            category.Name = "toto";
            category.Guid = Guid.NewGuid();

            category.Id = (int)sqlMap.Insert("InsertCategoryGenerate", category);
            Assert.AreEqual(1, category.Id);

            // Workaround!
            // Null out unneeded properties, otherwise those property values will be added
            // as command parameters for the auto-generated SELECT query even if
            // only 1 parameter for Id is needed.
            category.Name = null;
            category.Guid = Guid.Empty;

            Category categoryRead = null;
            categoryRead = (Category) sqlMap.QueryForObject("SelectByPKCategoryGenerate", category);

            Assert.AreEqual(category.Id, categoryRead.Id);
            Assert.AreEqual(category.Name, categoryRead.Name);
            Assert.AreEqual(category.Guid.ToString(), categoryRead.Guid.ToString());
        }
Beispiel #12
0
        public void TestJIRA176()
        {
            Category category = new Category();
            category.Name = "toto";
            category.Guid = Guid.Empty;

            int key = (int)sqlMap.Insert("InsertCategory", category);

            ImmutableCategoryPropertyContainer categoryContainerFromDB = (ImmutableCategoryPropertyContainer)sqlMap.QueryForObject("GetImmutableCategoryInContainer", key);
            Assert.IsNotNull(categoryContainerFromDB);
            Assert.IsNotNull(categoryContainerFromDB.ImmutableCategory);
            Assert.AreEqual(category.Name, categoryContainerFromDB.ImmutableCategory.Name);
            Assert.AreEqual(key, categoryContainerFromDB.ImmutableCategory.Id);
            Assert.AreEqual(category.Guid, categoryContainerFromDB.ImmutableCategory.Guid);
        }
        public void TestDynamicWithGUID()
        {
            Category category = new Category();
            category.Name = "toto";
            category.Guid = Guid.Empty;

            int key = (int)sqlMap.Insert("InsertCategory", category);

            category = new Category();
            category.Name = "titi";
            category.Guid = Guid.NewGuid();

            Category categoryTest = (Category)sqlMap.QueryForObject("DynamicGuid", category);
            Assert.IsNull(categoryTest);

            category = new Category();
            category.Name = "titi";
            category.Guid = Guid.Empty;

            categoryTest = (Category)sqlMap.QueryForObject("DynamicGuid", category);
            Assert.IsNotNull(categoryTest);
        }
Beispiel #14
0
        public void GenericTestUpdateCategoryWithExtendParameterMap()
        {
            Category category = new Category();
            category.Name = "Cat";
            category.Guid = Guid.NewGuid();

            int key = (int)sqlMap.Insert("InsertCategoryViaParameterMap", category);
            category.Id = key;

            category.Name = "Dog";
            category.Guid = Guid.NewGuid();

            sqlMap.Update("UpdateCategoryViaParameterMap", category);

            Category categoryRead = null;
            categoryRead = sqlMap.QueryForObject<Category>("GetCategory", key);

            Assert.AreEqual(category.Id, categoryRead.Id);
            Assert.AreEqual(category.Name, categoryRead.Name);
            Assert.AreEqual(category.Guid.ToString(), categoryRead.Guid.ToString());
        }
Beispiel #15
0
        public void InsertTestIdentityViaProcedureWithReturn( )
        {
            Category category = new Category ( );
            category.Name = "Mapping object relational";

            int categoryID = ( int ) sqlMap.Insert ( "InsertCategoryViaStoreProcedureWithReturn", category );
            Assert.That(categoryID, Is.EqualTo(1));
            Assert.That(category.Id, Is.EqualTo(1));

            Category category2 = new Category ( );
            category2.Name = "Nausicaa";

            int categoryID2 = ( int ) sqlMap.Insert ( "InsertCategoryViaStoreProcedureWithReturn", category2 );
            Assert.That(categoryID2, Is.EqualTo(2));
            Assert.That(category2.Id, Is.EqualTo(2));

            Category category3 = sqlMap.QueryForObject<Category> ( "GetCategory", categoryID2 ) ;
            Category category4 = sqlMap.QueryForObject<Category> ( "GetCategory", categoryID );

            Assert.AreEqual ( categoryID2, category3.Id );
            Assert.AreEqual ( category2.Name, category3.Name );

            Assert.AreEqual ( categoryID, category4.Id );
            Assert.AreEqual ( category.Name, category4.Name );
        }
        public void TestNullValueReplacementForGuidValue()
        {
            Category category = new Category();
            category.Name = "Toto";
            category.Guid = Guid.Empty;

            int key = (int)sqlMap.Insert("InsertCategoryNull", category);

            Category categoryRead = null;
            categoryRead = (Category)sqlMap.QueryForObject("GetCategoryWithNullValueReplacementGuid", key);

            Assert.AreEqual(category.Name, categoryRead.Name);
            Assert.AreEqual(category.Guid.ToString(), categoryRead.Guid.ToString());
        }
        public void TestSelectByPK()
        {
            Category category = new Category();
            category.Name = "toto";
            category.Guid = Guid.NewGuid();

            category.Id = (int)sqlMap.Insert("InsertCategoryGenerate", category);
            Assert.AreEqual(1, category.Id);

            Category categoryRead = null;
            categoryRead = (Category) sqlMap.QueryForObject("SelectByPKCategoryGenerate", category);

            Assert.AreEqual(category.Id, categoryRead.Id);
            Assert.AreEqual(category.Name, categoryRead.Name);
            Assert.AreEqual(category.Guid.ToString(), categoryRead.Guid.ToString());
        }
Beispiel #18
0
        public void TestTimeSpan()
        {
            Guid newGuid = Guid.NewGuid();;
            Category category = new Category();
            category.Name = "toto";
            category.Guid = newGuid;

            int key = (int)sqlMap.Insert("InsertCategory", category);

            Guid guid = (Guid)sqlMap.QueryForObject("GetGuid", key);

            Assert.AreEqual(newGuid, guid);
        }
        public void TestMultipleResultMap()
        {
            Category category = new Category();
            category.Name = "toto";
            category.Guid = Guid.NewGuid();

            int key = (int)sqlMap.Insert("InsertCategory", category);
            IList list = sqlMap.QueryForList("GetMultipleResultMap", null);

            Assert.AreEqual(2, list.Count);

            Account account = list[0] as Account;
            Category saveCategory = list[01] as Category;
            AssertAccount1(account);
            Assert.AreEqual(key, saveCategory.Id);
            Assert.AreEqual(category.Name, saveCategory.Name);
            Assert.AreEqual(category.Guid, saveCategory.Guid);
        }
Beispiel #20
0
        public void GenericTestInsertCategoryWithProperties()
        {
            Category category = new Category();
            category.Guid = Guid.NewGuid();

            int key = (int)sqlMap.Insert("InsertCategoryWithProperties", category);

            Category categoryTest = sqlMap.QueryForObject<Category>("GetCategory", key);
            Assert.AreEqual(key, categoryTest.Id);
            Assert.AreEqual("Film", categoryTest.Name);
            Assert.AreEqual(category.Guid, categoryTest.Guid);
        }
Beispiel #21
0
        public void TestInsertCategoryScope()
        {
            Category category = new Category();
            category.Name = "toto";
            category.Guid = Guid.NewGuid();

            sqlMap.QueryForObject("InsertCategoryScope", category, category);
            Assert.That(category.Id, Is.EqualTo(1));
        }