예제 #1
0
        public void TestCommandBase()
        {
            IDataPortal <CommandObject> dataPortal = _testDIContext.CreateDataPortal <CommandObject>();

            TestResults.Reinitialise();
            CommandObject obj = dataPortal.Create();

            obj = dataPortal.Execute(obj);
            Assert.AreEqual("Executed", obj.AProperty);
        }
예제 #2
0
    public static bool Execute(IDataPortal<CommandObject> dataPortal)
    {
      if (!CanExecuteCommand())
        throw new Csla.Security.SecurityException("Not authorized to execute command");

      CommandObject cmd = new CommandObject();
      cmd.BeforeServer();
      cmd = dataPortal.Execute(cmd);
      cmd.AfterServer();
      return cmd.Result;
    }
예제 #3
0
        public static bool Execute(IDataPortal <CommandObjectMissingFactoryMethod> dataPortal)
        {
            if (!CanExecuteCommand())
            {
                throw new Csla.Security.SecurityException("Not authorized to execute command");
            }

            CommandObjectMissingFactoryMethod cmd = dataPortal.Create();

            cmd.BeforeServer();
            cmd = dataPortal.Execute(cmd);
            cmd.AfterServer();
            return(cmd.Result);
        }
예제 #4
0
        public void CommandOverDataPortal()
        {
            TestDIContext customDIContext = TestDIContextFactory.CreateDefaultContext();
            // TODO: Get this custom proxy code included and working
            //TestDIContext customDIContext = TestDIContextFactory.CreateContext(
            //options => options
            //.Services.AddTransient<DataPortalClient.IDataPortalProxy, Csla.Testing.Business.TestProxies.AppDomainProxy>()
            //);
            IDataPortal <TestCommand> dataPortal = customDIContext.CreateDataPortal <TestCommand>();

            var cmd = dataPortal.Create();

            cmd.Name = "test data";

            var result = dataPortal.Execute(cmd);

            Assert.IsFalse(ReferenceEquals(cmd, result), "References should not match");
            Assert.AreEqual(cmd.Name + " server", result.Name);
        }
예제 #5
0
        public void ExecuteCommandWithIntercept()
        {
            IDataPortal <InterceptorCommand> dataPortal = _testDIContext.CreateDataPortal <InterceptorCommand>();

            TestResults.Reinitialise();

            var obj = dataPortal.Create();

            TestResults.Reinitialise();
            obj = dataPortal.Execute(obj);

            Assert.AreEqual("Execute", TestResults.GetResult("InterceptorCommand"), "Execute should have run");
            Assert.AreEqual("Initialize", TestResults.GetResult("Intercept1+InterceptorCommand"), "Initialize should have run");
            Assert.AreEqual("Execute", TestResults.GetResult("InterceptOp1+InterceptorCommand"), "Initialize op should be Execute");
            Assert.AreEqual("Complete", TestResults.GetResult("Intercept2+InterceptorCommand"), "Complete should have run");
            Assert.AreEqual("Execute", TestResults.GetResult("InterceptOp2+InterceptorCommand"), "Complete op should be Execute");
            Assert.IsFalse(TestResults.ContainsResult("Activate1+InterceptorCommand"), "CreateInstance should not have run");
            Assert.AreEqual("InitializeInstance", TestResults.GetResult("Activate2+InterceptorCommand"), "InitializeInstance should have run");
        }