Beispiel #1
0
        private void addDatasourceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataSourceController dsController = kernel[typeof(DataSourceController)] as DataSourceController;

            if (dsController.Run())
            {
                controller.DatabaseUpdated();
                //controller.DatasourcesSelected();
                return;
            }
        }
        public SystemController(OverViewDisplayer ovd)
        {
            //目标显示器命令初始化
            antennaControlStateCmd = new OverViewDisplayerAntennaControlCommand(ovd);
            autoWaveGateStateCmd   = new OverViewDisplayerAutoWaveGateCommand(ovd);
            semiAutoWaveGateCmd    = new OverViewDisplayerSemiAutoWaveGateCommand(ovd);
            zoomStateCmd           = new OverViewDisplayerZoomStateCommand(ovd);
            ResetDisplayerCmd      = new OverViewDisplayerResetCommand(ovd);

            delAvtiveTarget = new TargetManagerDeleteActiveTargetCommand();

            dataSourceController = TargetManagerFactory.CreateDataSourceController();

            deleteActiveWaveGatesCmd = new WaveGateDeleteActiveCommand();
        }
Beispiel #3
0
        public void Configure_WithInvalidModel_Returns_BadRequestResult()
        {
            // Arrange
            var dataSourceServiceMock = new Mock <IDataSourceService>();
            var loggerMock            = new Mock <ILogger <DataSourceController> >();

            var controller = new DataSourceController(dataSourceServiceMock.Object, loggerMock.Object);

            controller.ModelState.AddModelError("Error", "Model Error");
            var settingsDTO = new SettingsDTO();

            // Act
            var result = controller.Configure(settingsDTO);

            // Assert
            Assert.IsType <BadRequestObjectResult>(result);
        }
Beispiel #4
0
        public void GetConfiguration_WhenConfigurationSearchError_Returns_NotFound()
        {
            // Arrange
            var dataSourceServiceMock = new Mock <IDataSourceService>();

            dataSourceServiceMock.Setup(service => service
                                        .GetConfiguration())
            .Returns(GetNullSetingsDTO());

            var loggerMock = new Mock <ILogger <DataSourceController> >();

            var controller = new DataSourceController(dataSourceServiceMock.Object, loggerMock.Object);

            // Act
            var result = controller.GetConfiguration();

            // Assert
            Assert.IsType <NotFoundResult>(result);
        }
Beispiel #5
0
        public void Stop_WhenStopSuccessfully_Returns_Ok()
        {
            // Arrange
            var dataSourceServiceMock = new Mock <IDataSourceService>();

            dataSourceServiceMock.Setup(service => service
                                        .Stop())
            .Returns(true);

            var loggerMock = new Mock <ILogger <DataSourceController> >();

            var controller = new DataSourceController(dataSourceServiceMock.Object, loggerMock.Object);

            // Act
            var result = controller.Stop();

            // Assert
            Assert.IsType <OkObjectResult>(result);
        }
Beispiel #6
0
        public void Stop_WhenServiceNotAccessable_Returns_Conflict()
        {
            // Arrange
            var dataSourceServiceMock = new Mock <IDataSourceService>();

            dataSourceServiceMock.Setup(service => service
                                        .Stop())
            .Returns(false);

            var loggerMock = new Mock <ILogger <DataSourceController> >();

            var controller = new DataSourceController(dataSourceServiceMock.Object, loggerMock.Object);

            // Act
            var result = controller.Stop();

            // Assert
            Assert.IsType <ConflictObjectResult>(result);
        }
Beispiel #7
0
        private void editToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            object           selectedObject;
            SelectedNodeType selectedNodeType = GetSelectedNodeObject(out selectedObject);

            switch (selectedNodeType)
            {
            case SelectedNodeType.datasource:
                DataSourceController dsController = kernel[typeof(DataSourceController)] as DataSourceController;
                dsController.DataSourceDef = selectedObject as DsDef;
                dsController.Run();
                return;

            case SelectedNodeType.datasourcearchive:
                ArchiveController archController = kernel[typeof(ArchiveController)] as ArchiveController;
                archController.ArchiveDef = selectedObject as ArcDef;
                archController.Run();
                return;
            }
        }
Beispiel #8
0
        public void Configure_WithValidModel_Returns_AcceptedResult()
        {
            // Arrange
            var dataSourceServiceMock = new Mock <IDataSourceService>();

            dataSourceServiceMock.Setup(service => service
                                        .Configure(It.IsAny <SettingsDTO>()))
            .Returns(true);

            var loggerMock = new Mock <ILogger <DataSourceController> >();

            var controller  = new DataSourceController(dataSourceServiceMock.Object, loggerMock.Object);
            var settingsDTO = new SettingsDTO();

            // Act
            var result = controller.Configure(settingsDTO);

            // Assert
            Assert.IsType <AcceptedResult>(result);
        }
Beispiel #9
0
        public void GetConfiguration_WhenFound_Returns_Configuration()
        {
            // Arrange
            var dataSourceServiceMock = new Mock <IDataSourceService>();

            dataSourceServiceMock.Setup(service => service
                                        .GetConfiguration())
            .Returns(GetSettingsDTO());

            var loggerMock = new Mock <ILogger <DataSourceController> >();

            var controller = new DataSourceController(dataSourceServiceMock.Object, loggerMock.Object);

            // Act
            var result = controller.GetConfiguration();

            // Assert
            var okObjectResult = Assert.IsType <OkObjectResult>(result);

            Assert.IsAssignableFrom <SettingsDTO>(okObjectResult.Value);
        }
Beispiel #10
0
        public void Configure_WithValidExistingModel_Returns_ConflictResult()
        {
            // Arrange
            var dataSourceServiceMock = new Mock <IDataSourceService>();

            dataSourceServiceMock.Setup(service => service
                                        .Configure(It.IsAny <SettingsDTO>()))
            .Returns(false);

            var loggerMock = new Mock <ILogger <DataSourceController> >();

            var controller  = new DataSourceController(dataSourceServiceMock.Object, loggerMock.Object);
            var settingsDTO = new SettingsDTO();

            // Act
            var result = controller.Configure(settingsDTO);

            // Assert
            var conflictObjectResult = Assert.IsType <ConflictObjectResult>(result);

            Assert.IsAssignableFrom <string>(conflictObjectResult.Value);
        }
Beispiel #11
0
        private void modifyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            object nodeData;

            SelectedNodeType nodeType = GetSelectedNodeObject(out nodeData);

            if (nodeType == SelectedNodeType.datasource)
            {
                DataSourceController dsController = kernel[typeof(DataSourceController)] as DataSourceController;
                dsController.DataSourceDef = nodeData as DsDef;
                DatabaseData srcDatabaseData = GetSrcDatabase();
                controller.StartEditDatabase(srcDatabaseData);
                dsController.SrcDatabase = srcDatabaseData;
                if (dsController.Run())
                {
                    controller.DatabaseUpdated(srcDatabaseData);
                }
                return;
            }
            if (nodeType == SelectedNodeType.datasourcearchive)
            {
                ArchiveController archController = kernel[typeof(ArchiveController)] as ArchiveController;
                archController.ArchiveDef = nodeData as ArcDef;
                if (archController.Run())
                {
                    controller.DatabaseUpdated(GetSrcDatabase());
                }
                return;
            }

            if (nodeType == SelectedNodeType.database)
            {
                if (!CheckIfUnsaved())
                {
                    return;
                }
                controller.StartEditDatabase(nodeData as DatabaseData);
            }
        }
Beispiel #12
0
    protected void Debug()
    {
        Console.WriteLine("Setting cursor DataSource count: " + DataSourceController.Count);
        IObserveable observer = null;

        for (int i = 0; i < DataSourceController.Count; i++)
        {
            observer = DataSourceController.GetInfo(i);
            if (observer != null)
            {
                //Console.WriteLine (observer);
                if (observer is System.Data.Bindings.DataSourceInfo)
                {
                    DataSourceInfo DS = (observer as System.Data.Bindings.DataSourceInfo);
                    //Console.WriteLine ((observer as System.Data.Bindings.DataSourceInfo).Target);
                    if (DS.Target is Person)
                    {
                        Person p = (Person)(observer as System.Data.Bindings.DataSourceInfo).Target;
                        Console.WriteLine(p.Name + " " + p.Surname + " RefCount:" + DS.RefCount);
                    }
                }
            }
        }
    }
Beispiel #13
0
 public UnitTestDataSourceController()
 {
     _dataSourceController = new DataSourceController(new LibraryManager("..\\bin"));
 }
Beispiel #14
0
 public static DataSourceController CreateDataSourceController() => _dataSourcController ?? (_dataSourcController = new DataSourceController());