Esempio n. 1
0
        public void UnsupportedOperationTest()
        {
            Configuration        config = new MockConfiguration(false);
            SafeType <Connector> clazz  = SafeType <Connector> .Get <MockConnector>();

            ConnectorFacadeFactory factory = ConnectorFacadeFactory.GetInstance();
            APIConfiguration       impl    = TestHelpers.CreateTestConfiguration(clazz,
                                                                                 config);
            ConnectorFacade facade;

            facade = factory.NewInstance(impl);
            facade.Authenticate(ObjectClass.ACCOUNT, "fadf", new GuardedString(), null);
        }
        public void TestStackTraceOfExceptionThrownByConnectorFacade()
        {
            ConnectorFacadeFactory factory = ConnectorFacadeFactory.GetInstance();
            Configuration          config  = new MockConfiguration();
            ConnectorFacade        facade  = factory.NewInstance(
                TestHelpers.CreateTestConfiguration(SafeType <Connector> .Get <SpyConnector>(), config));

            try
            {
                facade.Test();

                Assert.Fail("Exception was not thrown");
            }
            catch (EUTestException eutex)
            {
                ExceptionUtilTestHelpers.AssertStackTrace(eutex, SpyConnector.StackTrace);
            }
        }
Esempio n. 3
0
        private void TestCallPattern(TestOperationPattern pattern,
                                     SafeType <Connector> clazz)
        {
            Configuration          config  = new MockConfiguration(false);
            ConnectorFacadeFactory factory = ConnectorFacadeFactory.GetInstance();
            // **test only**
            APIConfiguration impl = TestHelpers.CreateTestConfiguration(clazz, config);
            ConnectorFacade  facade;

            facade = factory.NewInstance(impl);
            // make the call on the connector facade..
            pattern.MakeCall(facade);
            // check the call structure..
            IList <MockConnector.Call> calls = MockConnector.GetCallPattern();

            // check the call pattern..
            Assert.AreEqual("Init", calls[0].MethodName);
            calls.RemoveAt(0);
            pattern.CheckCalls(calls);
            Assert.AreEqual("Dispose", calls[0].MethodName);
            calls.RemoveAt(0);
            Assert.IsTrue(calls.Count == 0);
        }
Esempio n. 4
0
        public void UpdateMergeTests()
        {
            ConnectorAttribute     expected, actual;
            Configuration          config  = new MockConfiguration(false);
            ConnectorFacadeFactory factory = ConnectorFacadeFactory.GetInstance();
            SafeType <Connector>   clazz   = SafeType <Connector> .Get <MockUpdateConnector>();

            // **test only**
            APIConfiguration impl = TestHelpers.CreateTestConfiguration(clazz, config);

            impl.SetTimeout(SafeType <APIOperation> .Get <GetApiOp>(), APIConstants.NO_TIMEOUT);
            impl.SetTimeout(SafeType <APIOperation> .Get <UpdateApiOp>(), APIConstants.NO_TIMEOUT);
            impl.SetTimeout(SafeType <APIOperation> .Get <SearchApiOp>(), APIConstants.NO_TIMEOUT);
            ConnectorFacade facade = factory.NewInstance(impl);
            // sniff test to make sure we can get an object..
            ConnectorObject obj = facade.GetObject(ObjectClass.ACCOUNT, NewUid(1), null);

            Assert.AreEqual(NewUid(1), obj.Uid);
            // ok lets add an attribute that doesn't exist..
            String ADDED     = "somthing to add to the object";
            String ATTR_NAME = "added";
            ICollection <ConnectorAttribute> addAttrSet;

            addAttrSet = CollectionUtil.NewSet((IEnumerable <ConnectorAttribute>)obj.GetAttributes());
            addAttrSet.Add(ConnectorAttributeBuilder.Build(ATTR_NAME, ADDED));
            Name name = obj.Name;

            addAttrSet.Remove(name);
            Uid uid = facade.AddAttributeValues(ObjectClass.ACCOUNT, obj.Uid, ConnectorAttributeUtil.FilterUid(addAttrSet), null);

            // get back the object and see if there are the same..
            addAttrSet.Add(name);
            ConnectorObject addO = new ConnectorObject(ObjectClass.ACCOUNT, addAttrSet);

            obj = facade.GetObject(ObjectClass.ACCOUNT, NewUid(1), null);
            Assert.AreEqual(addO, obj);
            // attempt to add on to an existing attribute..
            addAttrSet.Remove(name);
            uid = facade.AddAttributeValues(ObjectClass.ACCOUNT, obj.Uid, ConnectorAttributeUtil.FilterUid(addAttrSet), null);
            // get the object back out and check on it..
            obj      = facade.GetObject(ObjectClass.ACCOUNT, uid, null);
            expected = ConnectorAttributeBuilder.Build(ATTR_NAME, ADDED, ADDED);
            actual   = obj.GetAttributeByName(ATTR_NAME);
            Assert.AreEqual(expected, actual);
            // attempt to delete a value from an attribute..
            ICollection <ConnectorAttribute> deleteAttrs = CollectionUtil.NewSet((IEnumerable <ConnectorAttribute>)addO.GetAttributes());

            deleteAttrs.Remove(name);
            uid      = facade.RemoveAttributeValues(ObjectClass.ACCOUNT, addO.Uid, ConnectorAttributeUtil.FilterUid(deleteAttrs), null);
            obj      = facade.GetObject(ObjectClass.ACCOUNT, uid, null);
            expected = ConnectorAttributeBuilder.Build(ATTR_NAME, ADDED);
            actual   = obj.GetAttributeByName(ATTR_NAME);
            Assert.AreEqual(expected, actual);
            // attempt to delete an attribute that doesn't exist..
            ICollection <ConnectorAttribute> nonExist = new HashSet <ConnectorAttribute>();

            nonExist.Add(NewUid(1));
            nonExist.Add(ConnectorAttributeBuilder.Build("does not exist", "asdfe"));
            uid = facade.RemoveAttributeValues(ObjectClass.ACCOUNT, addO.Uid, ConnectorAttributeUtil.FilterUid(nonExist), null);
            obj = facade.GetObject(ObjectClass.ACCOUNT, NewUid(1), null);
            Assert.IsTrue(obj.GetAttributeByName("does not exist") == null);
        }