public void Initialize_PrimitiveCriteria_NoExceptionRaised() { // Arrange bool executed = false; PrimitiveCriteria criteria = new PrimitiveCriteria(1); ApplicationContext applicationContext = _testDIContext.CreateTestApplicationContext(); RevalidatingInterceptor sut = new RevalidatingInterceptor(applicationContext); InterceptArgs args = new InterceptArgs() { ObjectType = typeof(Root), Operation = DataPortalOperations.Update, Parameter = criteria, IsSync = true }; applicationContext.SetExecutionLocation(ApplicationContext.ExecutionLocations.Server); applicationContext.LocalContext["__logicalExecutionLocation"] = ApplicationContext.LogicalExecutionLocations.Server; // Act sut.Initialize(args); executed = true; // Assert Assert.IsTrue(executed); }
public void Initialize_ValidRootObjectWithChild_NoExceptionRaised() { // Arrange bool executed = false; IDataPortal <Root> dataPortal = _testDIContext.CreateDataPortal <Root>(); Root rootObject = dataPortal.Fetch(new Root.Criteria("Test Data")); Child childObject = rootObject.Children.AddNew(); childObject.Data = "Test child data"; ApplicationContext applicationContext = _testDIContext.CreateTestApplicationContext(); RevalidatingInterceptor sut = new RevalidatingInterceptor(applicationContext); InterceptArgs args = new InterceptArgs() { ObjectType = typeof(Root), Operation = DataPortalOperations.Update, Parameter = rootObject, IsSync = true }; applicationContext.SetExecutionLocation(ApplicationContext.ExecutionLocations.Server); applicationContext.LocalContext["__logicalExecutionLocation"] = ApplicationContext.LogicalExecutionLocations.Server; // Act sut.Initialize(args); executed = true; // Assert Assert.IsTrue(executed); }
public void Initialize_InvalidGrandChildObject_ExceptionRaised() { // Arrange IDataPortal <Root> dataPortal = _testDIContext.CreateDataPortal <Root>(); Root rootObject = dataPortal.Create(new Root.Criteria("Test Data")); Child childObject = rootObject.Children.AddNew(); childObject.Data = "Test child data"; GrandChild grandChildObject = childObject.GrandChildren.AddNew(); ApplicationContext applicationContext = _testDIContext.CreateTestApplicationContext(); RevalidatingInterceptor sut = new RevalidatingInterceptor(applicationContext); InterceptArgs args = new InterceptArgs() { ObjectType = typeof(Root), Operation = DataPortalOperations.Update, Parameter = rootObject, IsSync = true }; applicationContext.SetExecutionLocation(ApplicationContext.ExecutionLocations.Server); applicationContext.LocalContext["__logicalExecutionLocation"] = ApplicationContext.LogicalExecutionLocations.Server; // Act and Assert Assert.ThrowsException <Rules.ValidationException>(() => sut.Initialize(args)); }