public ITestProperty SetObject(ITestObject testObject) {
            AssertIsVisible();
            AssertIsModifiable();
            ResetLastMessage();

            Assert.IsFalse(field.ReturnSpec.IsParseable, "Drop(..) not allowed on value target field; use SetValue(..) instead");

            INakedObjectAdapter testNakedObjectAdapter = testObject.NakedObject;

            Assert.IsTrue(testNakedObjectAdapter.Spec.IsOfType(field.ReturnSpec), string.Format("Can't drop a {0} on to the {1} field (which accepts {2})", testObject.NakedObject.Spec.ShortName, Name, field.ReturnSpec));

            INakedObjectAdapter nakedObjectAdapter = owningObject.NakedObject;

            IConsent valid;
            var associationSpec = field as IOneToOneAssociationSpec;
            if (associationSpec != null) {
                valid = associationSpec.IsAssociationValid(nakedObjectAdapter, testNakedObjectAdapter);
            }
            else if (field is IOneToManyAssociationSpec) {
                valid = new Veto("Always disabled");
            }
            else {
                throw new UnknownTypeException(field);
            }

            LastMessage = valid.Reason;
            Assert.IsFalse(valid.IsVetoed, string.Format("Cannot SetObject {0} in the field {1} within {2}: {3}", testNakedObjectAdapter, field, nakedObjectAdapter, valid.Reason));

            var spec = field as IOneToOneAssociationSpec;
            if (spec != null) {
                spec.SetAssociation(nakedObjectAdapter, testNakedObjectAdapter);
            }

            return this;
        }
		public DerivedConstructorDependenciesObject(
			ITestObject spouse1, ITestObject spouse2, IndexedTestObject other, int age, string name)
			: base(spouse1, spouse2, other)
		{
			Age = age;
			Name = name;
		}
Beispiel #3
0
 public void TearDown() {
     CleanupNakedObjectsFramework();
     countPayments = 0;
     payment1 = null;
     customer1 = null;
     payee1 = null;
     key1 = null;
 }
Beispiel #4
0
 public virtual void ObjectWithSimpleToString() {
     rep = GetTestService("Object2s");
     obj = rep.GetAction("New Instance").InvokeReturnObject();
     prop1 = obj.GetPropertyByName("Prop1");
     prop1.SetValue("Bar");
     obj.AssertTitleEquals("Bar");
     obj.Save();
     obj.AssertTitleEquals("Bar");
 }
Beispiel #5
0
 public virtual void ObjectWithTitleAttributeOnString() {
     rep = GetTestService("Object1s");
     obj = rep.GetAction("New Instance").InvokeReturnObject();
     obj.AssertTitleEquals("Untitled Object1");
     prop1 = obj.GetPropertyByName("Prop1");
     prop1.SetValue("Foo");
     obj.AssertTitleEquals("Foo");
     obj.Save();
     obj.AssertTitleEquals("Foo");
 }
Beispiel #6
0
 public virtual void TitleMethod() {
     rep = GetTestService("Object4s");
     obj = rep.GetAction("New Instance").InvokeReturnObject();
     obj.AssertTitleEquals("Untitled Object4");
     prop1 = obj.GetPropertyByName("Prop1");
     prop1.SetValue("Foo");
     obj.AssertTitleEquals("Foo");
     obj.Save();
     obj.AssertTitleEquals("Foo");
 }
Beispiel #7
0
        public void Setup() {
            InitializeNakedObjectsFramework();
            payment1 = CreatePayment();
            customer1 = CreateCustomer("0c1ced04-7016-11e0-9c44-78544824019b");
            customer2 = CreateCustomer("3d9d6ca0-7016-11e0-b12a-9e544824019b");

            supplier1 = CreateSupplier("89bc90ec-7017-11e0-a08c-57564824019b");
            payee1 = payment1.GetPropertyByName("Payee");
            key1 = payment1.GetPropertyByName("Payee Compound Key");
        }
Beispiel #8
0
 public virtual void CMaskOnDecimalProperty() {
     obj = NewTestObject<Object2>();
     prop1 = obj.GetPropertyByName("Prop1");
     prop1.SetValue("32.70");
     var dom = (Object2) obj.GetDomainObject();
     StringAssert.Equals("32.7", dom.Prop1.ToString());
     StringAssert.Equals("32.70", prop1.Content.Title);
     StringAssert.Equals("£32.70", prop1.Title);
     prop1.AssertTitleIsEqual("£32.70");
     prop1.AssertValueIsEqual("32.70");
 }
Beispiel #9
0
 public void Setup() {
     InitializeNakedObjectsFramework();
     payment1 = CreatePayment();
     customer1 = CreateCustomer();
     customer2 = CreateCustomer();
     supplier1 = CreateSupplier();
     payee1 = payment1.GetPropertyByName("Payee");
     key1 = payment1.GetPropertyByName("Payee Compound Key");
     emp1 = CreateEmployee("foo");
     emp2 = CreateEmployee("bar");
 }
Beispiel #10
0
 public virtual void TitleMethodTakesPrecedenceOverToString() {
     rep = GetTestService("Object5s");
     obj = rep.GetAction("New Instance").InvokeReturnObject();
     StringAssert.Equals("Bar", obj.GetDomainObject().ToString());
     obj.AssertTitleEquals("Untitled Object5");
     ITestProperty prop1 = obj.GetPropertyByName("Prop1");
     prop1.SetValue("Foo");
     obj.AssertTitleEquals("Foo");
     obj.Save();
     obj.AssertTitleEquals("Foo");
 }
Beispiel #11
0
 public void Initialize() {
     InitializeNakedObjectsFramework();
     payment1 = CreatePayment();
     customer1 = CreateCustomerOnes();
     customer2a = CreateCustomerTwos();
     customer2b = CreateCustomerTwos();
     customer3 = CreateCustomerThrees();
     supplier1 = CreateSupplier();
     payee1 = payment1.GetPropertyByName("Payee");
     key1 = payment1.GetPropertyByName("Payee Compound Key");
     emp1 = CreateEmployee("foo");
 }
        public void ExecuteSpelAction()
        {
            string executeHandlerText =
                "on exception name ArithmeticException execute Oragon.Spring.Aspects.Exceptions.ExceptionHandlerAspectIntegrationTests.Executed(true)";
            ITestObject to = CreateTestObjectProxy(executeHandlerText);

            try
            {
                to.Exceptional(new ArithmeticException());
            }
            catch (ArithmeticException)
            {
                Assert.IsTrue(spelActionExecuted);
            }
        }
        public void ReturnWithString()
        {
            string      returnHandlerText = "on exception name ArithmeticException return 12";
            ITestObject to = CreateTestObjectProxy(returnHandlerText);

            try
            {
                int retVal = to.ExceptionalWithReturnValue(new ArithmeticException("Bad Math"));
                Assert.AreEqual(12, retVal);
            }
            catch (Exception)
            {
                Assert.Fail("Should not have thrown exception");
            }
        }
Beispiel #14
0
        public static UIACondition GetCondition(ITestObject testObject)
        {
            if (testObject == null)
            {
                return(null);
            }

            UIACondition condition = testObject.GetContext <UIACondition>();

            if (condition == null)
            {
                condition = new UIACondition(testObject);
            }
            return(condition);
        }
        public void VirtualControlHelper_LoadVirtualControls()
        {
            string   appModelPath = "UnitTestVirtualControl.json";
            AppModel virtualModel = AppModelManager.Load(appModelPath);

            Assert.AreEqual(1, virtualModel.Items.Count);

            ITestObject testObject = virtualModel.Items[0];

            Assert.AreEqual(3, testObject.Children.Count);

            VirtualTestObject[] controls = VirtualControlHelper.GetVirtualControls(testObject);

            VirtualControlHelper.DumpVirtualControls(controls);
        }
Beispiel #16
0
        private void CallGetObject()
        {
            ProxyFactoryObject proxyFactory = (ProxyFactoryObject)this.factory.GetObject("&concurrentPrototype");

            ITestObject prevTestObject = null;

            for (int i = 0; i < 20; i++)
            {
                ITestObject o = proxyFactory.GetObject() as ITestObject;
                Assert.IsNotNull(o);
                Assert.AreNotSame(prevTestObject, o);
                prevTestObject = o;
                Thread.Sleep(0);
            }
        }
Beispiel #17
0
        public static ITestObject LoadData(string name, ITestObject parentTestObject)
        {
            ITestObject testObject = null;

            if (parentTestObject == null)
            {
                testObject = model.FindFirst(ControlKeys.Name, name);
            }
            else
            {
                parentTestObject.Find(ControlKeys.Name, name);
            }

            return(testObject);
        }
        public void Initialize()
        {
            InitializeNakedObjectsFrameworkOnce();
            StartTest();

            payment1 = GetTestService("Payments").GetAction("All Instances").InvokeReturnCollection().ElementAt(0);
            payee1   = payment1.GetPropertyByName("Payee");
            key1     = payment1.GetPropertyByName("Payee Compound Key");

            var customers = GetTestService("Customers").GetAction("All Instances").InvokeReturnCollection();

            customer1 = customers.ElementAt(0);
            customer2 = customers.ElementAt(1);
            supplier1 = GetTestService("Suppliers").GetAction("All Instances").InvokeReturnCollection().ElementAt(0);
        }
        public virtual void TestEnumDefault()
        {
            ITestObject obj = NewTestObject <Object1>();

            ITestAction a1 = obj.GetAction("Do Something Else");

            ITestParameter p1 = a1.Parameters.First();
            ITestParameter p2 = a1.Parameters.Last();

            ITestNaked def1 = p1.GetDefault();
            ITestNaked def2 = p2.GetDefault();

            Assert.AreEqual(TestEnum.Value2, def1.NakedObject.Object);
            Assert.AreEqual(null, def2);
        }
Beispiel #20
0
 public void CleanUp() {
     CleanupNakedObjectsFramework();
     countPayments = 0;
     countCustomerTwos = 0;
     countSuppliers = 0;
     countEmployees = 0;
     payment1 = null;
     customer1 = null;
     customer2a = null;
     customer2b = null;
     customer3 = null;
     payee1 = null;
     key1 = null;
     emp1 = null;
 }
        public void ProxyPerformanceTests()
        {
            int       runs  = 5000000;
            StopWatch watch = new StopWatch();

            ITestObject testObject = new ChainableTestObject(null);

            using (watch.Start("Naked Duration: {0}"))
            {
                for (int i = 0; i < runs; i++)
                {
                    object result = testObject.DoSomething(this);
                }
            }

            ITestObject hardcodedWrapper = new ChainableTestObject(testObject);

            using (watch.Start("Hardcoded Wrapper Duration: {0}"))
            {
                for (int i = 0; i < runs; i++)
                {
                    object result = hardcodedWrapper.DoSomething(this);
                }
            }

            PeformanceTestAopContextInterceptor interceptor = new PeformanceTestAopContextInterceptor();
            ITestObject proxy = CreateProxy(testObject, interceptor, false);

            using (watch.Start("Proxy Duration ('ExposeProxy'==false): {0}"))
            {
                for (int i = 0; i < runs; i++)
                {
                    object result = proxy.DoSomething(this);
                }
            }
            Assert.AreEqual(runs, interceptor.Calls);

            interceptor = new PeformanceTestAopContextInterceptor();
            proxy       = CreateProxy(testObject, interceptor, true);
            using (watch.Start("Proxy Duration ('ExposeProxy'==true): {0}"))
            {
                for (int i = 0; i < runs; i++)
                {
                    object result = proxy.DoSomething(this);
                }
            }
            Assert.AreEqual(runs, interceptor.Calls);
        }
        public void ProxyObjectWithInterface()
        {
            DefaultListableObjectFactory of = new DefaultListableObjectFactory();

            of.RegisterObjectDefinition("bar", new RootObjectDefinition(typeof(ObjectWithInterface)));

            TestAutoProxyCreator apc = new TestAutoProxyCreator(of);

            of.AddObjectPostProcessor(apc);

            ITestObject o = of.GetObject("bar") as ITestObject;

            Assert.IsTrue(AopUtils.IsAopProxy(o));
            o.Foo();
            Assert.AreEqual(1, apc.NopInterceptor.Count);
        }
        public static double RunTest(ITestObject obj)
        {
            long startTime = 0;
            long stopTime  = 0;

            QueryPerformanceCounter(out startTime);
            for (int i = 0; i < 10000000; i++)
            {
                obj.DoubleValue = 5;
                double v = obj.DoubleValue;
            }
            QueryPerformanceCounter(out stopTime);
            double duration = (double)(stopTime - startTime) / (double)freq;

            return(duration);
        }
Beispiel #24
0
        //Constructor for collecting all data.
        public RecoveryScenarios(DataSet recoverDataset, DataSet recoverData, DataSet orData, ITestObject objTest)
        {
            _recoverData = recoverDataset;
            _datasetRecoverBrowser = recoverData;
            _datasetOr = orData;
            _objTestObject = objTest;
            try
            {
                if(recoverData.Tables.Count>0)
                _noOfTimes = new int[recoverData.Tables[0].Rows.Count];
            }
            catch (IndexOutOfRangeException)
            {

            }
        }
Beispiel #25
0
 public virtual void DMaskOnDateProperty() {
     obj = NewTestObject<Object1>();
     prop1 = obj.GetPropertyByName("Prop1");
     prop1.SetValue("23/09/2009 11:34:50");
     prop2 = obj.GetPropertyByName("Prop2");
     prop2.SetValue("23/09/2009 11:34:50");
     var dom = (Object1) obj.GetDomainObject();
     StringAssert.Equals("23/09/2009 11:34:50", dom.Prop1.ToString());
     StringAssert.Equals("23/09/2009 11:34:50", prop1.Content.Title);
     StringAssert.Equals("23/09/2009 11:34:50", dom.Prop2.ToString());
     StringAssert.Equals("23/09/2009", prop2.Content.Title);
     prop1.AssertTitleIsEqual("23/09/2009 11:34:50");
     prop1.AssertValueIsEqual("23/09/2009 11:34:50");
     prop2.AssertTitleIsEqual("23/09/2009");
     prop2.AssertValueIsEqual("23/09/2009 11:34:50");
 }
Beispiel #26
0
        public void CreateInstanceWithAutofacCreatesRegisteredType()
        {
            ContainerBuilder builder = new ContainerBuilder();

            builder.RegisterType <TestObject>().AsImplementedInterfaces();
            builder.RegisterType <TestChild>().AsImplementedInterfaces();
            IContainer container = builder.Build();

            string serializeResult = this.Serialize(container, new TestObject());

            ITestObject deserializeResult = this.Deserialize(container, serializeResult);

            Assert.IsNotNull(deserializeResult);

            Assert.IsNotNull(deserializeResult.TestChild);
        }
        public virtual void EnumPropertyBasic()
        {
            ITestObject foo = NewTestObject <Foo>();

            ITestProperty sex1 = foo.GetPropertyByName("Sex1");

            ITestNaked[] values = sex1.GetChoices();
            Assert.AreEqual(4, values.Count());
            Assert.AreEqual("Female", values.ElementAt(0).NakedObject.TitleString());
            Assert.AreEqual("Male", values.ElementAt(1).NakedObject.TitleString());
            Assert.AreEqual("Not Specified", values.ElementAt(2).NakedObject.TitleString());
            Assert.AreEqual("Unknown", values.ElementAt(3).NakedObject.TitleString());

            sex1.AssertFieldEntryIsValid("Male");
            sex1.AssertFieldEntryInvalid("Man");
        }
        public void InstantiateWithExplicitCtor()
        {
            SimpleInstantiationStrategy strategy = new SimpleInstantiationStrategy();
            object obj = strategy.Instantiate(
                SingletonDefinition, null, Factory,
                SingletonDefinition.ObjectType.GetConstructor(
                    new Type[] { typeof(string), typeof(int) }),
                new object[] { "Rick", 19 });

            Assert.IsNotNull(obj);
            Assert.IsTrue(obj is ITestObject);
            ITestObject actual = (ITestObject)obj;

            Assert.AreEqual("Rick", actual.Name);
            Assert.AreEqual(19, actual.Age);
        }
Beispiel #29
0
        public void TargetThrowsInvalidCastException()
        {
            Exception   expectedException = new InvalidCastException();
            ITestObject test1             = (ITestObject)factory.GetObject("test1");

            try
            {
                test1.Exceptional(expectedException);
                Assert.Fail("Should have thrown exception raised by target");
            }
            catch (Exception ex)
            {
                Assert.AreEqual(expectedException, ex, "exception matches");
                Assert.AreEqual(1, test1.ExceptionMethodCallCount);
            }
        }
        public void TestInitialize()
        {
            InitializeNakedObjectsFrameworkOnce();
            StartTest();
            ITestObject cust1To = NewTestObject <Customer>();

            cust1    = (Customer)cust1To.GetDomainObject();
            cust1.Id = 1;
            cust1To.Save();

            ITestObject cust2To = NewTestObject <Customer>();

            cust2    = (Customer)cust2To.GetDomainObject();
            cust2.Id = 2;
            cust2To.Save();
        }
Beispiel #31
0
        public void Initialize()
        {
            StartTest();
            payment1 = GetAllInstances(typeof(SimpleRepository <Payment>), 0);
            payee1   = payment1.GetPropertyByName("Payee");
            key1     = payment1.GetPropertyByName("Payee Compound Key");

            customer1  = GetAllInstances(typeof(SimpleRepository <CustomerOne>), 0);
            customer2a = GetAllInstances(typeof(SimpleRepository <CustomerTwo>), 0);
            customer2b = GetAllInstances(typeof(SimpleRepository <CustomerTwo>), 1);
            customer3  = GetAllInstances(typeof(SimpleRepository <CustomerThree>), 0);
            customer4  = GetAllInstances(typeof(SimpleRepository <CustomerFour>), 0);
            customer4a = GetAllInstances(typeof(SimpleRepository <CustomerFour>), 1);
            supplier1  = GetAllInstances(typeof(SimpleRepository <Supplier>), 0);
            emp1       = GetAllInstances(typeof(SimpleRepository <Employee>), 0);
        }
Beispiel #32
0
        public static AutomationElement GetCalculatorButton1Element()
        {
            ObjectDescriptor windowDescriptor = ObjectDescriptor.FromJson(@"
                {ntype:""uia"",identifyProperties: {name: ""Calculator""}}
                ");

            ObjectDescriptor buttonDescriptor = ObjectDescriptor.FromJson(@"
                {ntype:""uia"",identifyProperties: {name: ""1""}}
                ", windowDescriptor);

            ITestObject       windowObject = windowDescriptor.GetObject();
            UIATestObject     uiaObject    = (UIATestObject)windowObject.Children[0];
            AutomationElement element      = uiaObject.AutomationElement;

            return(element);
        }
        public bool? LeftRightLocator(UIACondition selfCondition, out AutomationElement element)
        {
            AutomationElement leftElement = null, rightElement = null;
            //check if the left or right condtion exist            
            //get the left and right element            
            if (selfCondition.Right != "")
            {
                ITestObject rightTO;
                
                if (selfCondition.Right.IndexOf(DescriptionString.LeftRightQtpString) >= 0)
                {
                    //format Right==something
                    rightTO = UIAHelper.ConvertStringToTestObject(selfCondition.Right); 
                }
                else
                {
                    //selfCondition.Right is the name, then use the name to extract descriptor
                    rightTO = UIAJsonPersister.LoadData(selfCondition.Right, selfCondition.ParentCondition.TestObject);
                }

                UIACondition rightCondition = new UIACondition(rightTO);

                rightCondition.ParentCondition = selfCondition.ParentCondition;
                rightElement = Find(rightCondition);
            }

            if (selfCondition.Left != "")
            {
                ITestObject leftDescriptor = null;
                if (selfCondition.Left.IndexOf(DescriptionString.LeftRightQtpString) >= 0)
                {
                    leftDescriptor = UIAHelper.ConvertStringToTestObject(selfCondition.Left);
                }
                else
                {
                    leftDescriptor = UIAJsonPersister.LoadData(selfCondition.Left, selfCondition.ParentCondition.TestObject);
                }
                UIACondition leftCondition = new UIACondition(leftDescriptor);
                leftCondition.ParentCondition = selfCondition.ParentCondition;
                leftElement = Find(leftCondition);
            }

            int sameCount = 0;
            bool? found = LeftRightCheck(selfCondition, leftElement, rightElement, element);

            return found;
        }
Beispiel #34
0
        public virtual void TestGetActionById()
        {
            ITestObject obj = NewTestObject <Object1>();

            var a1 = obj.GetActionById("ActionNumber1");
            var a2 = obj.GetActionById("ActionNumber2");

            try {
                a1 = obj.GetActionById("Action Number1");
                Assert.Fail("Shouldn't get to here!");
            } catch (Exception e) {
                Assert.AreEqual("Assert.Fail failed. No Action named 'Action Number1' (as method name)", e.Message);
            }

            //Now with params
            var a3 = obj.GetActionById("ActionNumber3", typeof(string), typeof(int));

            a3 = obj.GetActionById("ActionNumber3"); //Params not necessary

            //And with wrong param types
            try {
                a3 = obj.GetActionById("ActionNumber3", typeof(int), typeof(string)); //wrong way round!
                Assert.Fail("Shouldn't get to here!");
            } catch (Exception e) {
                Assert.AreEqual("Assert.Fail failed. No Action named 'ActionNumber3' (as method name & with specified parameters)", e.Message);
            }

            //Now from sub-menu, with & without params
            obj.GetActionById("ActionNumber4", "Sub1");
            obj.GetActionById("ActionNumber4", "Sub1", typeof(string), typeof(int));
            obj.GetActionById("ActionNumber4"); //works without specifying sub-menu
            obj.GetActionById("ActionNumber4", typeof(string), typeof(int));
            //With wrong sub-menu
            try {
                obj.GetActionById("ActionNumber4", "Sub2", typeof(string), typeof(int));
                Assert.Fail("Shouldn't get to here!");
            } catch (Exception e) {
                Assert.AreEqual("Assert.IsNotNull failed. No menu item with name: Sub2", e.Message);
            }
            //With right sub-menu & wrong params
            try {
                obj.GetActionById("ActionNumber4", "Sub1", typeof(int), typeof(string));
                Assert.Fail("Shouldn't get to here!");
            } catch (Exception e) {
                Assert.AreEqual("Assert.IsTrue failed. Parameter Types do not match for action with method name: ActionNumber4", e.Message);
            }
        }
Beispiel #35
0
        public void MethodPointcuts()
        {
            ITestObject tb = (ITestObject)factory.GetObject("pointcuts");

            PointcutForVoid.Reset();
            Assert.IsTrue((PointcutForVoid.methodNames.Count == 0), "No methods intercepted");
            object o = tb.Age;

            Assert.IsTrue((PointcutForVoid.methodNames.Count == 0), "Not void: shouldn't have intercepted");
            tb.Age  = 1;
            o       = tb.Age;
            tb.Name = "Tristan";
            tb.ToString();
            Assert.AreEqual(2, PointcutForVoid.methodNames.Count, "Recorded wrong number of invocations");
            Assert.AreEqual("set_Age", PointcutForVoid.methodNames[0]);
            Assert.AreEqual("set_Name", PointcutForVoid.methodNames[1]);
        }
 private static void AssertTranslation(ITestObject to)
 {
     try
     {
         to.Exceptional(new ArithmeticException("Bad Math"));
         Assert.Fail("Should have thrown exception");
     }
     catch (InvalidOperationException e)
     {
         Assert.That(e.InnerException, Is.InstanceOf(typeof(ArithmeticException)), "Inner exception.");
         Assert.AreEqual("My Message, Method Name Exceptional", e.Message);
     }
     catch (Exception e)
     {
         Assert.That(e, Is.InstanceOf(typeof(InvalidOperationException)), "wrong exception type thrown.");
     }
 }
Beispiel #37
0
        public static void MergeVirtualControls(ITestObject testObject, VirtualTestObject[] virtualObjects)
        {
            //Remove existing virtual objects
            foreach (ITestObject childObject in testObject.Children)
            {
                if (childObject is VirtualTestObject)
                {
                    testObject.RemoveChild(childObject);
                }
            }

            //Add new virtualObjects
            foreach (VirtualTestObject virtualObject in virtualObjects)
            {
                testObject.AddChild(virtualObject);
            }
        }
        public void InterceptorInclusionMethods()
        {
            NopInterceptor di       = new NopInterceptor();
            NopInterceptor diUnused = new NopInterceptor(1); // // make instance unique (see SPRNET-847)
            ProxyFactory   factory  = new ProxyFactory(new TestObject());

            factory.AddAdvice(0, di);
            ITestObject tb = (ITestObject)factory.GetProxy();

            Assert.IsTrue(factory.AdviceIncluded(di));
            Assert.IsTrue(!factory.AdviceIncluded(diUnused));
            Assert.IsTrue(factory.CountAdviceOfType(typeof(NopInterceptor)) == 1);

            factory.AddAdvice(0, diUnused);
            Assert.IsTrue(factory.AdviceIncluded(diUnused));
            Assert.IsTrue(factory.CountAdviceOfType(typeof(NopInterceptor)) == 2);
        }
        public void AdvisorAdapterRegistrationManagerPresentInContext()
        {
            string configLocation   = ReadOnlyXmlTestResource.GetFilePath("withBPPContext.xml", typeof(AdvisorAdapterRegistrationTests));
            IApplicationContext ctx = new XmlApplicationContext(configLocation);
            ITestObject         to  = (ITestObject)ctx.GetObject("testObject");

            // just invoke any method to see if advice fired
            try
            {
                to.ReturnsThis();
                Assert.AreEqual(1, GetAdviceImpl(to).InvocationCounter);
            }
            catch (UnknownAdviceTypeException)
            {
                Assert.Fail("Should not throw UnknownAdviceTypeException");
            }
        }
Beispiel #40
0
 //Constructor for collecting all data.
 public RecoveryScenarios(DataSet recoverDataset, DataSet recoverData, DataSet orData, ITestObject objTest)
 {
     _recoverData           = recoverDataset;
     _datasetRecoverBrowser = recoverData;
     _datasetOr             = orData;
     _objTestObject         = objTest;
     try
     {
         if (recoverData.Tables.Count > 0)
         {
             _noOfTimes = new int[recoverData.Tables[0].Rows.Count];
         }
     }
     catch (IndexOutOfRangeException)
     {
     }
 }
Beispiel #41
0
        public void CanSetTransparentProxy()
        {
            PropertyOrFieldNode pofNode = new PropertyOrFieldNode();

            pofNode.Text = "ObjectProp";

            BaseClass ouc = new BaseClass();
            TestTransparentProxyFactory tpf = new TestTransparentProxyFactory(null, typeof(ITestObject), null);
            object tpo = tpf.GetTransparentProxy();

            Assert.IsTrue(tpo is ITestObject);
            ITestObject itpo = tpo as ITestObject;

            Assert.IsNotNull(itpo);
            pofNode.SetValue(ouc, null, itpo);
            Assert.AreSame(tpo, ouc.ObjectProp);
        }
 public CalculatorWindowNode(ITestObject parent, AppModelBase applicationModel) : base(parent, applicationModel)
 {
     OnButton       = new OnButtonNode(this, applicationModel);
     OffButton      = new OffButtonNode(this, applicationModel);
     OneButton      = new OneButtonNode(this, applicationModel);
     SixButton      = new SixButtonNode(this, applicationModel);
     AddButton      = new AddButtonNode(this, applicationModel);
     ClearButton    = new ClearButtonNode(this, applicationModel);
     OutputField    = new OutputFieldNode(this, applicationModel);
     CalcButton     = new CalcButtonNode(this, applicationModel);
     MultiplyButton = new MultiplyButtonNode(this, applicationModel);
     TwoButton      = new TwoButtonNode(this, applicationModel);
     ThreeButton    = new ThreeButtonNode(this, applicationModel);
     MinusButton    = new MinusButtonNode(this, applicationModel);
     NineButton     = new NineButtonNode(this, applicationModel);
     SettingsButton = new SettingsButtonNode(this, applicationModel);
     DisplayName    = @"Calculator";
 }
        public void CreateProxyFactoryWithoutTargetThenSetTarget()
        {
            TestObject target = new TestObject();

            target.Name = "Adam";
            NopInterceptor       nopInterceptor       = new NopInterceptor();
            CountingBeforeAdvice countingBeforeAdvice = new CountingBeforeAdvice();
            ProxyFactory         pf = new ProxyFactory();

            pf.Target = target;
            pf.AddAdvice(nopInterceptor);
            pf.AddAdvisor(new DefaultPointcutAdvisor(countingBeforeAdvice));
            object      proxy = pf.GetProxy();
            ITestObject to    = (ITestObject)proxy;

            Assert.AreEqual("Adam", to.Name);
            Assert.AreEqual(1, countingBeforeAdvice.GetCalls());
        }
        private void DecoratorProxyAssertions(ITestObject testObject)
        {
            CountingBeforeAdvice cba = (CountingBeforeAdvice)ctx.GetObject("countingBeforeAdvice");
            NopInterceptor       nop = (NopInterceptor)ctx.GetObject("nopInterceptor");

            Assert.AreEqual(0, cba.GetCalls());
            Assert.AreEqual(0, nop.Count);
            Assert.IsTrue(AopUtils.IsDecoratorAopProxy(testObject), testObject + " is not an AOP Proxy");
            //extra advice calls are due to test IsDecoratorAopProxy and call to .GetType in impl
            Assert.AreEqual(1, nop.Count);
            Assert.AreEqual(1, cba.GetCalls());
            int age = 5;

            testObject.Age = age;
            Assert.AreEqual(age, testObject.Age);
            Assert.AreEqual(3, nop.Count);
            Assert.AreEqual(3, cba.GetCalls());
        }
        public ITestProperty RemoveFromCollection(ITestObject testObject) {
            AssertIsVisible();
            AssertIsModifiable();
            ResetLastMessage();

            Assert.IsTrue(field is IOneToManyAssociationSpec, "Cannot remove from non collection");

            INakedObjectAdapter testNakedObjectAdapter = testObject.NakedObject;

            Assert.IsTrue(testNakedObjectAdapter.Spec.IsOfType(field.ReturnSpec),
                string.Format("Can't clear a {0} from the {1} field (which accepts {2})", testObject.NakedObject.Spec.ShortName, Name, field.ReturnSpec));

            INakedObjectAdapter nakedObjectAdapter = owningObject.NakedObject;

            if (!(field is IOneToManyAssociationSpec)) {
                throw new UnknownTypeException(field);
            }
            IConsent valid = new Veto("Always disabled");

            Assert.IsFalse(valid.IsVetoed, string.Format("Can't remove {0} from the field {1} within {2}: {3}", testNakedObjectAdapter, field, nakedObjectAdapter, valid.Reason));
            return this;
        }
Beispiel #46
0
 public ChainableTestObject(ITestObject next)
 {
     this.next = next;
 }
 public void Diddly (ITestObject three) 
 {
 }
Beispiel #48
0
            public virtual void TitleAttributeTakesPrecedenceOverTitleMethod() {
                rep = GetTestService("Object6s");
                obj = rep.GetAction("New Instance").InvokeReturnObject();
                var dom = (Object6) obj.GetDomainObject();
                StringAssert.Equals("Bar", dom.ToString());
                StringAssert.Equals("Hex", dom.Title());
                obj.AssertTitleEquals("Untitled Object6");
                prop1 = obj.GetPropertyByName("Prop1");
                prop1.SetValue("Foo");
                obj.AssertTitleEquals("Foo");
                obj.Save();
                obj.AssertTitleEquals("Foo");

           
            }
 public OptionalDependencyTestClass(ITestObject obj)
 {
     internalTestObject = obj;
 }
Beispiel #50
0
 public TestObject(ITestObject spouse)
 {
     this.spouse = spouse;
 }
		public DerivedConstructorDependenciesObject(
			ITestObject spouse1, ITestObject spouse2, IndexedTestObject other, int age, int otherAge)
			: base(spouse1, spouse2, other)
		{
		}
 public ITestProperty TestField(ITestObject expected) {
     SetObject(expected);
     Assert.AreEqual(expected.NakedObject, Content.NakedObject);
     return this;
 }
 public ITestProperty AssertSetObjectInvalid(ITestObject testObject) {
     try {
         AssertSetObjectIsValid(testObject);
     }
     catch (AssertFailedException) {
         // expected 
         return this;
     }
     Assert.Fail("Object {0} was allowed in field {1} : expected it to be invalid", testObject, field);
     return this;
 }
 public NamedOptionalConstParameterClass([OptionalDependency("test")] ITestObject test)
 {
     TestObject = test;
 }
		public ConstructorDependenciesObject(ITestObject spouse1)
		{
			this.spouse1 = spouse1;
		}
		private SimpleBeforeAdviceImpl GetAdviceImpl(ITestObject to) 
		{
			IAdvised advised = (IAdvised) to;
			IAdvisor advisor = advised.Advisors[0];
			return (SimpleBeforeAdviceImpl) advisor.Advice;
		}
		public DerivedConstructorDependenciesObject(
			ITestObject spouse1, object spouse2, IndexedTestObject other)
			: base(spouse1, null, other)
		{
		}
		public ConstructorDependenciesObject(ITestObject spouse1, ITestObject spouse2)
		{
			this.spouse1 = spouse1;
			this.spouse2 = spouse2;
		}
 public void AfterPropertiesSet()
 {
     testObject = new TestObject();
     initialized = true;
 }
		public ConstructorDependenciesObject(ITestObject spouse1, ITestObject spouse2, IndexedTestObject other)
		{
			this.spouse1 = spouse1;
			this.spouse2 = spouse2;
			this.other = other;
		}