public void Should_not_be_possible_validate_a_schema_from_a_non_existent_file() { MockRepository mocks = new MockRepository(); var fakeView = MockRepository.GenerateStub <ISchemaView>(); var fakeController = mocks.StrictMock <SchemaController>(new object[] { fakeView }); using (mocks.Record()) { Expect.Call(fakeController.DefinitionsFileExists(null)).IgnoreArguments().Return(false); } mocks.ReplayAll(); var e = new SchemaEventArgs(); e.DefinitionFilename = "sample.xml"; fakeController.view_OnValidateSchema(this, e); mocks.VerifyAll(); Assert.IsFalse(e.Result); Assert.AreEqual(Modulo.Collect.GraphicalConsole.Resource.OVALDefinitionsFileNotFound, e.ShortErrorMessage); Assert.IsNull(e.LongErrorMessage); }
private SchemaEventArgs CreateSchemaTestScenario(string definitionFilename) { var schemaSet = new XmlSchemaSet(); AddSchema(schemaSet, "http://oval.mitre.org/XMLSchema/oval-common-5", "xml.oval-common-schema.xsd"); AddSchema(schemaSet, "http://oval.mitre.org/XMLSchema/oval-definitions-5", "xml.oval-definitions-schema.xsd"); AddSchema(schemaSet, "http://oval.mitre.org/XMLSchema/oval-definitions-5#independent", "xml.independent-definitions-schema.xsd"); AddSchema(schemaSet, "http://www.w3.org/2000/09/xmldsig#", "xml.xmldsig-core-schema.xsd"); var stream = GetResourceStream(definitionFilename); MockRepository mocks = new MockRepository(); var fakeView = MockRepository.GenerateStub <ISchemaView>(); var fakeController = mocks.StrictMock <SchemaController>(new object[] { fakeView }); using (mocks.Record()) { Expect.Call(fakeController.DefinitionsFileExists(null)).IgnoreArguments().Return(true); Expect.Call(fakeController.CreateXmlSchemaSet()).IgnoreArguments().Return(schemaSet); Expect.Call(fakeController.GetStream(null)).IgnoreArguments().Return(stream); } mocks.ReplayAll(); var e = new SchemaEventArgs(); e.DefinitionFilename = definitionFilename; fakeController.view_OnValidateSchema(this, e); mocks.VerifyAll(); return(e); }
private void Controller_OnRelationshipRemoved(object sender, SchemaEventArgs <Connection> e) { Connection connection = e.Entity; connection.RemoveFromSurface(this); OnConnectionRemoved.RaiseEvent(this, new SchemaEventArgs <Connection>(connection)); }
private void Controller_OnConnectionAdded(object sender, SchemaEventArgs <Connection> e) { var connection = e.Entity; ConnectionPointUtility.TidyAllConnections(Controller); connection.AddToSurface(this); OnConnectionAdded.RaiseEvent(this, new SchemaEventArgs <Connection>(connection)); }
/// <summary> /// Raises the given event /// </summary> /// <param name="obj">The object that changed</param> /// <param name="handler">The event to raise</param> protected virtual void RaiseEvent <T>(T obj, EventHandler <SchemaEventArgs <T> > handler) { var e = new SchemaEventArgs <T>(obj); if (handler != null) { handler(this, e); } }
private void Surface_OnShapeAdded(object sender, SchemaEventArgs <DiagramShape> e) { DiagramShape shape = e.Entity; shape.MouseDown += SimpleShape_MouseDown; shape.MouseDoubleClick += SimpleShape_MouseDoubleClick; shape.SizeChanged += SimpleShape_SizeChanged; foreach (ConnectionPoint point in shape.ConnectionPoints) { point.MouseDown += ConnectionPoint_MouseDown; } }
public void Should_be_possible_raising_a_schema_event_on_a_view() { MockRepository mocks = new MockRepository(); var fakeView = mocks.DynamicMock<ISchemaView>(); mocks.ReplayAll(); var controller = new SchemaController(fakeView); var e = new SchemaEventArgs(); fakeView.Raise(x => x.OnValidateSchema += null, this, e); mocks.VerifyAll(); Assert.IsTrue(controller.OnValidadeSchemaCalled); Assert.IsFalse(e.Result); Assert.AreEqual(Modulo.Collect.GraphicalConsole.Resource.EmptyDefinitionFilename, e.ShortErrorMessage); Assert.IsNull(e.LongErrorMessage); }
public void Should_be_possible_raising_a_schema_event_on_a_view() { MockRepository mocks = new MockRepository(); var fakeView = mocks.DynamicMock <ISchemaView>(); mocks.ReplayAll(); var controller = new SchemaController(fakeView); var e = new SchemaEventArgs(); fakeView.Raise(x => x.OnValidateSchema += null, this, e); mocks.VerifyAll(); Assert.IsTrue(controller.OnValidadeSchemaCalled); Assert.IsFalse(e.Result); Assert.AreEqual(Modulo.Collect.GraphicalConsole.Resource.EmptyDefinitionFilename, e.ShortErrorMessage); Assert.IsNull(e.LongErrorMessage); }
static void SchemaInstaller_DropFailed(object sender, SchemaEventArgs e) { _logger.Info(e.Exception, "Dropping DB object failed! See succeeding log records: schema name={0}, object name={1} ", e.SchemaObject == null ? "<SchemaObject is null>" : e.SchemaObject.Name, e.ObjectName); }
void Surface_OnEntitySelected(object sender, SchemaEventArgs<DiagramShape> e) { Controller.ShapeSelected(e.Entity); }
private void Controller_OnTableRemoved(object sender, SchemaEventArgs <DiagramShape> e) { e.Entity.RemoveFromSurface(this); RaiseEvent(e.Entity, OnShapeRemoved); }
private void Surface_OnShapeAdded(object sender, SchemaEventArgs<DiagramShape> e) { DiagramShape shape = e.Entity; shape.MouseDown += SimpleShape_MouseDown; shape.MouseDoubleClick += SimpleShape_MouseDoubleClick; shape.SizeChanged += SimpleShape_SizeChanged; foreach(ConnectionPoint point in shape.ConnectionPoints) point.MouseDown += ConnectionPoint_MouseDown; }
private void Surface_OnShapeRemoved(object sender, SchemaEventArgs<DiagramShape> e) { e.Entity.MouseDown -= SimpleShape_MouseDown; e.Entity.MouseDoubleClick -= SimpleShape_MouseDoubleClick; e.Entity.SizeChanged -= SimpleShape_SizeChanged; }
public void Should_not_be_possible_validate_a_schema_from_a_non_existent_file() { MockRepository mocks = new MockRepository(); var fakeView = MockRepository.GenerateStub<ISchemaView>(); var fakeController = mocks.StrictMock<SchemaController>(new object[] { fakeView }); using (mocks.Record()) { Expect.Call(fakeController.DefinitionsFileExists(null)).IgnoreArguments().Return(false); } mocks.ReplayAll(); var e = new SchemaEventArgs(); e.DefinitionFilename = "sample.xml"; fakeController.view_OnValidateSchema(this, e); mocks.VerifyAll(); Assert.IsFalse(e.Result); Assert.AreEqual(Modulo.Collect.GraphicalConsole.Resource.OVALDefinitionsFileNotFound, e.ShortErrorMessage); Assert.IsNull(e.LongErrorMessage); }
private SchemaEventArgs CreateSchemaTestScenario(string definitionFilename) { var schemaSet = new XmlSchemaSet(); AddSchema(schemaSet, "http://oval.mitre.org/XMLSchema/oval-common-5", "xml.oval-common-schema.xsd"); AddSchema(schemaSet, "http://oval.mitre.org/XMLSchema/oval-definitions-5", "xml.oval-definitions-schema.xsd"); AddSchema(schemaSet, "http://oval.mitre.org/XMLSchema/oval-definitions-5#independent", "xml.independent-definitions-schema.xsd"); AddSchema(schemaSet, "http://www.w3.org/2000/09/xmldsig#", "xml.xmldsig-core-schema.xsd"); var stream = GetResourceStream(definitionFilename); MockRepository mocks = new MockRepository(); var fakeView = MockRepository.GenerateStub<ISchemaView>(); var fakeController = mocks.StrictMock<SchemaController>(new object[] { fakeView }); using (mocks.Record()) { Expect.Call(fakeController.DefinitionsFileExists(null)).IgnoreArguments().Return(true); Expect.Call(fakeController.CreateXmlSchemaSet()).IgnoreArguments().Return(schemaSet); Expect.Call(fakeController.GetStream(null)).IgnoreArguments().Return(stream); } mocks.ReplayAll(); var e = new SchemaEventArgs(); e.DefinitionFilename = definitionFilename; fakeController.view_OnValidateSchema(this, e); mocks.VerifyAll(); return e; }
void Surface_OnConnectionSelected(object sender, SchemaEventArgs<Connection> e) { Controller.ConnectionSelected(e.Entity); }
private void Controller_OnShapeAdded(object sender, SchemaEventArgs <DiagramShape> e) { e.Entity.AddToSurface(this); RaiseEvent(e.Entity, OnShapeAdded); }
void Surface_OnConnectionSelected(object sender, SchemaEventArgs <Connection> e) { Controller.ConnectionSelected(e.Entity); }
void Surface_OnEntityDeselected(object sender, SchemaEventArgs <DiagramShape> e) { Controller.ShapeDeselected(e.Entity); }
private void Surface_OnConnectionRemoved(object sender, SchemaEventArgs <Connection> e) { e.Entity.MouseDown -= Connection_MouseDown; e.Entity.SourceEndPoint.MouseDown -= EndPoint_MouseDown; e.Entity.TargetEndPoint.MouseDown -= EndPoint_MouseDown; }
private void Surface_OnShapeRemoved(object sender, SchemaEventArgs <DiagramShape> e) { e.Entity.MouseDown -= SimpleShape_MouseDown; e.Entity.MouseDoubleClick -= SimpleShape_MouseDoubleClick; e.Entity.SizeChanged -= SimpleShape_SizeChanged; }
static void SchemaInstaller_CreatingObject(object sender, SchemaEventArgs e) { _logger.Info("Creating DB object: schema name={0}, object name={1}, ", e.SchemaObject == null ? "<SchemaObject is null>" : e.SchemaObject.Name, e.ObjectName); }
private void Surface_OnConnectionRemoved(object sender, SchemaEventArgs<Connection> e) { e.Entity.MouseDown -= Connection_MouseDown; e.Entity.SourceEndPoint.MouseDown -= EndPoint_MouseDown; e.Entity.TargetEndPoint.MouseDown -= EndPoint_MouseDown; }