public void DefaultAuditorCalledForNonSpecificTypeUpdate() { MyDefaultAuditor.SetActionCallbacksExpected(); ITestObject bar = GetTestService("Bars").GetAction("New Instance").InvokeReturnObject(); MyDefaultAuditor.SetActionCallbacksUnexpected(); int defaultUpdatedCount = 0; int defaultPersistedCount = 0; string newValue = Guid.NewGuid().ToString(); MyDefaultAuditor.Auditor.objectPersistedCallback = (p, o) => { Assert.AreEqual("sven", p.Identity.Name); Assert.IsNotNull(o); Assert.AreEqual("NakedObjects.SystemTest.Audit.Bar", o.GetType().GetProxiedType().FullName); Assert.IsNull(((Bar)o).Prop1); defaultPersistedCount++; }; bar.Save(); MyDefaultAuditor.Auditor.objectUpdatedCallback = (p, o) => { Assert.AreEqual("sven", p.Identity.Name); Assert.IsNotNull(o); Assert.AreEqual("NakedObjects.SystemTest.Audit.Bar", o.GetType().GetProxiedType().FullName); Assert.AreEqual(newValue, ((Bar)o).Prop1); defaultUpdatedCount++; }; NakedObjectsFramework.TransactionManager.StartTransaction(); bar.GetPropertyByName("Prop1").SetValue(newValue); NakedObjectsFramework.TransactionManager.EndTransaction(); Assert.AreEqual(1, defaultUpdatedCount, "expect default auditor to be called for updates"); Assert.AreEqual(1, defaultPersistedCount, "expect default auditor to be called for persists"); }
public void AuditUsingSpecificTypeAuditorQueryOnlyServiceAction() { MyDefaultAuditor.SetActionCallbacksExpected(); ITestService foo = GetTestService("Foo Service"); MyDefaultAuditor.SetActionCallbacksUnexpected(); int fooCalledCount = 0; FooAuditor.Auditor.serviceActionInvokedCallback = (p, a, s, b, pp) => { Assert.AreEqual("sven", p.Identity.Name); Assert.AreEqual("AQueryOnlyAction", a); Assert.AreEqual("Foo Service", s); Assert.IsTrue(b); Assert.AreEqual(0, pp.Length); fooCalledCount++; }; foo.GetAction("A Query Only Action").InvokeReturnObject(); Assert.AreEqual(1, fooCalledCount, "expect foo auditor to be called"); }
public void DefaultAuditorCalledForNonSpecificTypeAction() { MyDefaultAuditor.SetActionCallbacksExpected(); ITestObject bar = GetTestService(typeof(SimpleRepository <Bar>)).GetAction("New Instance").InvokeReturnObject(); MyDefaultAuditor.SetActionCallbacksUnexpected(); int defaultCalledCount = 0; MyDefaultAuditor.Auditor.actionInvokedCallback = (p, a, o, b, pp) => { Assert.AreEqual("sven", p.Identity.Name); Assert.AreEqual("AnAction", a); Assert.IsNotNull(o); Assert.AreEqual("NakedObjects.SystemTest.Audit.Bar", o.GetType().GetProxiedType().FullName); Assert.IsFalse(b); Assert.AreEqual(0, pp.Length); defaultCalledCount++; }; bar.GetAction("An Action").InvokeReturnObject(); Assert.AreEqual(1, defaultCalledCount, "expect default auditor to be called"); }
public void AuditUsingSpecificTypeAuditorActionQux() { MyDefaultAuditor.SetActionCallbacksExpected(); ITestObject qux = GetTestService("Quxes").GetAction("New Instance").InvokeReturnObject(); MyDefaultAuditor.SetActionCallbacksUnexpected(); int quxCalledCound = 0; QuxAuditor.Auditor.actionInvokedCallback = (p, a, o, b, pp) => { Assert.AreEqual("sven", p.Identity.Name); Assert.AreEqual("AnAction", a); Assert.IsNotNull(o); Assert.AreEqual("NakedObjects.SystemTest.Audit.Qux", o.GetType().FullName); Assert.IsFalse(b); Assert.AreEqual(0, pp.Length); quxCalledCound++; }; qux.GetAction("An Action").InvokeReturnObject(); Assert.AreEqual(1, quxCalledCound, "expect qux auditor to be called"); }
public void AuditUsingSpecificTypeAuditorImplicitQueryOnlyAction() { MyDefaultAuditor.SetActionCallbacksExpected(); ITestObject foo = GetTestService("Foos").GetAction("New Instance").InvokeReturnObject(); MyDefaultAuditor.SetActionCallbacksUnexpected(); int fooCalledCount = 0; FooAuditor.Auditor.actionInvokedCallback = (p, a, o, b, pp) => { Assert.AreEqual("sven", p.Identity.Name); Assert.AreEqual("AnotherQueryOnlyAction", a); Assert.IsNotNull(o); Assert.AreEqual("NakedObjects.SystemTest.Audit.Foo", o.GetType().FullName); Assert.IsTrue(b); Assert.AreEqual(0, pp.Length); fooCalledCount++; }; foo.GetAction("Another Query Only Action").InvokeReturnCollection(); Assert.AreEqual(1, fooCalledCount, "expect foo auditor to be called"); }
public void AuditUsingSpecificTypeAuditorUpdateQux() { MyDefaultAuditor.SetActionCallbacksExpected(); ITestObject qux = GetTestService("Quxes").GetAction("New Instance").InvokeReturnObject(); MyDefaultAuditor.SetActionCallbacksUnexpected(); int quxUpdatedCount = 0; int quxPersistedCount = 0; string newValue = Guid.NewGuid().ToString(); QuxAuditor.Auditor.objectPersistedCallback = (p, o) => { Assert.AreEqual("sven", p.Identity.Name); Assert.IsNotNull(o); Assert.AreEqual("NakedObjects.SystemTest.Audit.Qux", o.GetType().GetProxiedType().FullName); Assert.IsNull(((Qux)o).Prop1); quxPersistedCount++; }; qux.Save(); QuxAuditor.Auditor.objectUpdatedCallback = (p, o) => { Assert.AreEqual("sven", p.Identity.Name); Assert.IsNotNull(o); Assert.AreEqual("NakedObjects.SystemTest.Audit.Qux", o.GetType().GetProxiedType().FullName); Assert.AreEqual(newValue, ((Qux)o).Prop1); quxUpdatedCount++; }; NakedObjectsFramework.TransactionManager.StartTransaction(); qux.GetPropertyByName("Prop1").SetValue(newValue); NakedObjectsFramework.TransactionManager.EndTransaction(); Assert.AreEqual(1, quxUpdatedCount, "expect qux auditor to be called for updates"); Assert.AreEqual(1, quxPersistedCount, "expect qux auditor to be called for persists"); }
public void AuditUsingSpecificTypeAuditorActionWithParm() { MyDefaultAuditor.SetActionCallbacksExpected(); ITestObject foo = GetTestService("Foos").GetAction("New Instance").InvokeReturnObject(); MyDefaultAuditor.SetActionCallbacksUnexpected(); int fooCalledCount = 0; FooAuditor.Auditor.actionInvokedCallback = (p, a, o, b, pp) => { Assert.AreEqual("sven", p.Identity.Name); Assert.AreEqual("AnActionWithParm", a); Assert.IsNotNull(o); Assert.AreEqual("NakedObjects.SystemTest.Audit.Foo", o.GetType().FullName); Assert.IsFalse(b); Assert.AreEqual(1, pp.Count()); Assert.AreEqual(1, pp[0]); fooCalledCount++; }; foo.GetAction("An Action With Parm").InvokeReturnObject(1); Assert.AreEqual(1, fooCalledCount, "expect foo auditor to be called"); }
public void AuditUsingSpecificTypeAuditorServiceActionWithParms() { MyDefaultAuditor.SetActionCallbacksExpected(); ITestService foo = GetTestService("Foo Service"); ITestObject fooObj = GetTestService("Foos").GetAction("New Instance").InvokeReturnObject(); MyDefaultAuditor.SetActionCallbacksUnexpected(); int fooCalledCount = 0; FooAuditor.Auditor.serviceActionInvokedCallback = (p, a, s, b, pp) => { Assert.AreEqual("sven", p.Identity.Name); Assert.AreEqual("AnActionWithParms", a); Assert.AreEqual("Foo Service", s); Assert.IsFalse(b); Assert.AreEqual(2, pp.Length); Assert.AreEqual(1, pp[0]); Assert.AreSame(fooObj.NakedObject.Object, pp[1]); fooCalledCount++; }; foo.GetAction("An Action With Parms").InvokeReturnObject(1, fooObj); Assert.AreEqual(1, fooCalledCount, "expect foo auditor to be called"); }