public void DataPortalExecute_OnCommandObjectWithLocalProxy_CallsFactoryExecute() { TestDIContext testDIContext = TestDIContextFactory.CreateDefaultContext(); IDataPortal <CommandObject> dataPortal = testDIContext.CreateDataPortal <CommandObject>(); TestResults.Reinitialise(); var test = CommandObject.Execute(dataPortal); // return value is set in Execute method in CommandObjectFactory Assert.IsTrue(test); }
public void FetchLoadProperty() { TestDIContext testDIContext = TestDIContextFactory.CreateDefaultContext(); // TODO: Not sure how to have a generic factory loader now an ApplicationContext is required on the class :-( //TestDIContext testDIContext = TestDIContextFactory.CreateContext( // options => options.DataPortal( // dp => dp.AddServerSideDataPortal(cfg => cfg.RegisterObjectFactoryLoader<ObjectFactoryLoader<RootFactory3>>())) // ); IDataPortal <Root> dataPortal = testDIContext.CreateDataPortal <Root>(); var root = dataPortal.Fetch(); Assert.AreEqual("Fetch", root.Data, "Data should match"); Assert.IsFalse(root.IsNew, "Should not be new"); Assert.IsFalse(root.IsDirty, "Should not be dirty"); }
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); }
public void DataPortalExecute_OnCommandObjectWithFalseExecuteMethod_ThrowsExeptionMehodNotFound() { TestDIContext testDIContext = TestDIContextFactory.CreateDefaultContext(); IDataPortal <CommandObjectMissingFactoryMethod> dataPortal = testDIContext.CreateDataPortal <CommandObjectMissingFactoryMethod>(); try { TestResults.Reinitialise(); var test = CommandObjectMissingFactoryMethod.Execute(dataPortal); } catch (DataPortalException ex) { // inner exception should be System.NotImplementedException and mesaage should contain methodname Assert.AreEqual(typeof(System.NotImplementedException), ex.InnerException.GetType()); Assert.IsTrue(ex.InnerException.Message.Contains("ExecuteMissingMethod")); // rethrow exception throw; } Assert.Fail("Should throw exception"); }
public static void ClassInitialize(TestContext testContext) { _testDIContext = TestDIContextFactory.CreateDefaultContext(); }
public static void ClassInitialize(TestContext context) { _testDIContext = TestDIContextFactory.CreateDefaultContext(); _noCloneOnUpdateDIContext = TestDIContextFactory.CreateContext(opt => opt.DataPortal(cfg => cfg.AutoCloneOnUpdate(false))); }