コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        private void Controller_OnRelationshipRemoved(object sender, SchemaEventArgs <Connection> e)
        {
            Connection connection = e.Entity;

            connection.RemoveFromSurface(this);
            OnConnectionRemoved.RaiseEvent(this, new SchemaEventArgs <Connection>(connection));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        /// <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);
            }
        }
コード例 #6
0
        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;
            }
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
 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);
 }
コード例 #10
0
 void Surface_OnEntitySelected(object sender, SchemaEventArgs<DiagramShape> e)
 {
     Controller.ShapeSelected(e.Entity);
 }
コード例 #11
0
 private void Controller_OnTableRemoved(object sender, SchemaEventArgs <DiagramShape> e)
 {
     e.Entity.RemoveFromSurface(this);
     RaiseEvent(e.Entity, OnShapeRemoved);
 }
コード例 #12
0
        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;
        }
コード例 #13
0
 private void Surface_OnShapeRemoved(object sender, SchemaEventArgs<DiagramShape> e)
 {
     e.Entity.MouseDown -= SimpleShape_MouseDown;
     e.Entity.MouseDoubleClick -= SimpleShape_MouseDoubleClick;
     e.Entity.SizeChanged -= SimpleShape_SizeChanged;
 }
コード例 #14
0
        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);
        }
コード例 #15
0
        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;
        }
コード例 #16
0
 void Surface_OnConnectionSelected(object sender, SchemaEventArgs<Connection> e)
 {
     Controller.ConnectionSelected(e.Entity);
 }
コード例 #17
0
        private void Controller_OnShapeAdded(object sender, SchemaEventArgs <DiagramShape> e)
        {
            e.Entity.AddToSurface(this);

            RaiseEvent(e.Entity, OnShapeAdded);
        }
コード例 #18
0
 void Surface_OnConnectionSelected(object sender, SchemaEventArgs <Connection> e)
 {
     Controller.ConnectionSelected(e.Entity);
 }
コード例 #19
0
 void Surface_OnEntityDeselected(object sender, SchemaEventArgs <DiagramShape> e)
 {
     Controller.ShapeDeselected(e.Entity);
 }
コード例 #20
0
 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;
 }
コード例 #21
0
 private void Surface_OnShapeRemoved(object sender, SchemaEventArgs <DiagramShape> e)
 {
     e.Entity.MouseDown        -= SimpleShape_MouseDown;
     e.Entity.MouseDoubleClick -= SimpleShape_MouseDoubleClick;
     e.Entity.SizeChanged      -= SimpleShape_SizeChanged;
 }
コード例 #22
0
 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);
 }
コード例 #23
0
 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;
 }