public void UpdateWithIntercept() { TestResults.Reinitialise(); var obj = GetInitializeRoot("abc"); TestResults.Reinitialise(); obj.Name = "xyz"; obj = obj.Save(); Assert.AreEqual("Initialize", TestResults.GetResult("Intercept1+InitializeRoot"), "Initialize should have run"); Assert.AreEqual("Update", TestResults.GetResult("InterceptOp1+InitializeRoot"), "Initialize op should be Update"); Assert.AreEqual("Complete", TestResults.GetResult("Intercept2+InitializeRoot"), "Complete should have run"); Assert.AreEqual("Update", TestResults.GetResult("InterceptOp2+InitializeRoot"), "Complete op should be Update"); Assert.IsFalse(TestResults.ContainsResult("Activate1+InitializeRoot"), "CreateInstance should not have run"); Assert.AreEqual("InitializeInstance", TestResults.GetResult("Activate2+InitializeRoot"), "InitializeInstance should have run"); }
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"); }