12#include <com/sun/star/container/ElementExistException.hpp>
13#include <com/sun/star/container/NoSuchElementException.hpp>
14#include <com/sun/star/container/XNameContainer.hpp>
15#include <com/sun/star/lang/IllegalArgumentException.hpp>
17#include <com/sun/star/uno/Any.hxx>
18#include <com/sun/star/uno/Reference.hxx>
20#include <cppunit/TestAssert.h>
28 uno::Reference<container::XNameContainer> xNameContainer(
init(), uno::UNO_QUERY_THROW);
30 CPPUNIT_ASSERT(!xNameContainer->hasByName(
m_aName +
"Insert"));
32 CPPUNIT_ASSERT(xNameContainer->hasByName(
m_aName +
"Insert"));
37 uno::Reference<container::XNameContainer> xNameContainer(
init(), uno::UNO_QUERY_THROW);
40 CPPUNIT_ASSERT_THROW(xNameContainer->insertByName(
"", aAny), lang::IllegalArgumentException);
45 uno::Reference<container::XNameContainer> xNameContainer(
init(), uno::UNO_QUERY_THROW);
54 uno::Reference<container::XNameContainer> xNameContainer(
init(), uno::UNO_QUERY_THROW);
56 CPPUNIT_ASSERT(!xNameContainer->hasByName(
m_aName +
"Duplicate"));
58 CPPUNIT_ASSERT(xNameContainer->hasByName(
m_aName +
"Duplicate"));
60 bool bExceptionThrown =
false;
65 catch (
const container::ElementExistException&)
67 bExceptionThrown =
true;
69 catch (
const lang::IllegalArgumentException&)
71 bExceptionThrown =
true;
73 CPPUNIT_ASSERT(bExceptionThrown);
78 uno::Reference<container::XNameContainer> xNameContainer(
init(), uno::UNO_QUERY_THROW);
79 CPPUNIT_ASSERT(xNameContainer->hasByName(
m_aName));
80 xNameContainer->removeByName(
m_aName);
81 CPPUNIT_ASSERT(!xNameContainer->hasByName(
m_aName));
86 uno::Reference<container::XNameContainer> xNameContainer(
init(), uno::UNO_QUERY_THROW);
88 CPPUNIT_ASSERT_THROW(xNameContainer->removeByName(
""), lang::IllegalArgumentException);
93 uno::Reference<container::XNameContainer> xNameContainer(
init(), uno::UNO_QUERY_THROW);
95 CPPUNIT_ASSERT_THROW(xNameContainer->removeByName(
"UnitTest"),
96 container::NoSuchElementException);
void testRemoveByNameEmptyName()
virtual css::uno::Reference< css::uno::XInterface > init()=0
void testRemoveByNameNoneExistingElement()
void testInsertByNameInvalidElement()
void testInsertByNameDuplicate()
void testInsertByNameEmptyName()