Ejemplo n.º 1
0
        protected virtual string RenderCell(object value, ColumnType columnType)
        {
            var factory   = new PresenterFactory();
            var presenter = factory.Instantiate(columnType);

            return($"{presenter.Execute(value)}");
        }
Ejemplo n.º 2
0
        protected virtual void RenderCell(object value, ColumnType columnType, JsonWriter writer)
        {
            var factory   = new PresenterFactory();
            var formatter = factory.Instantiate(columnType);

            writer.WriteValue(formatter.Execute(value));
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            TaskScheduler.UnobservedTaskException      += TaskScheduler_UnobservedTaskException;
            AppDomain.CurrentDomain.UnhandledException += (s, e) =>
            {
                Console.WriteLine((e.ExceptionObject as Exception).Message);
            };
            var teamcityConfig = new Rest.TeamCity.ConfigurationProvider();
            var restClient     = new RestClient(
                teamcityConfig.Host,
                teamcityConfig.Login,
                teamcityConfig.Password,
                MediaType.Json);
            var tc               = new TeamCityApi(restClient);
            var gateway          = new Gateway(new[] { tc });
            var presenterFactory = new PresenterFactory();
            var output           = new Output(
                presenterFactory,
                new IOutputStream[] {
                new ConsoleStream(),
                new FileStream("log.txt")
            });
            var cancellationSource = new CancellationTokenSource();

            output.Write("build bot greetings you");
            output.Write("type exit to leave bot");

            var client   = new TelegramBotClient(new ConfigurationProvider().ApiKey);
            var commands = new List <CommandBase>
            {
                new StartCommand(cancellationSource),
                new ExitCommand(cancellationSource),
                new TeamcityGetBuildQueueCommand(gateway.For <ITeamCity>(), cancellationSource),
                new TeamcityGetProjectsCommand(gateway.For <ITeamCity>(), cancellationSource),
                new TeamcityGetProjectCommand(gateway.For <ITeamCity>(), cancellationSource),
                new TeamcityGetBranchesCommand(gateway.For <ITeamCity>(), cancellationSource),
                new TeamcityGetBuildsCommand(gateway.For <ITeamCity>(), cancellationSource),
                new TeamcityGetBuildTypesCommand(gateway.For <ITeamCity>(), cancellationSource),
                new TeamcityGetBuildCommand(gateway.For <ITeamCity>(), cancellationSource),
                new TeamcityGetAgentsCommand(gateway.For <ITeamCity>(), cancellationSource),
                new TeamcityEnqueueBuild(gateway.For <ITeamCity>(), cancellationSource),
                new TeamcityGetRunningBuildsCommand(gateway.For <ITeamCity>(), cancellationSource),
                new TeamcityEnqueueAgentCommand(gateway.For <ITeamCity>(), cancellationSource),
                new TeamcityGetBranchCommand(gateway.For <ITeamCity>(), cancellationSource)
            };
            var help = new HelpCommand(commands, cancellationSource);

            commands.Add(help);
            var commandsExecutor = new CommandsExecutor(commands);
            var inputStream      = new InputPipeline();
            var consoleListener  = new ConsoleCommandProducer(inputStream);
            var runLooper        = new RunLooper(inputStream, commandsExecutor, consoleListener, output, cancellationSource);
            var store            = new MemoryStore();

            using (var botWrapper = new BotWrapper(client, inputStream, presenterFactory, cancellationSource, commandsExecutor, output, store))
            {
                botWrapper.Start();
                runLooper.Run();
            }
        }
Ejemplo n.º 4
0
        public void MyTestInitialize()
        {
            m_Container = StructureMapContainerInit();
            BaseReportTests.InitDBAndLogin();
            using (PresenterFactory.BeginSharedPresenterTransaction(m_Container, new BaseForm()))
            {
                m_LayoutDB = new WinLayout_DB(PresenterFactory.SharedPresenter.SharedModel);
            }
            lock (m_LayoutDB.Connection)
            {
                OpenConnection();
                using (var command = new SqlCommand(GetQueryIdSQL))
                {
                    command.Connection = (SqlConnection)m_LayoutDB.Connection;
                    m_TestQueryId      = (long)command.ExecuteScalar();
                }
                CloseConnection();
            }

            m_PivotDB = new BaseAvrDbService();
            m_LayoutDB.AddLinkedDbService(m_PivotDB, null, RelatedPostOrder.SkipPost);

            m_ChartDB = new BaseAvrDbService();
            m_LayoutDB.AddLinkedDbService(m_ChartDB, null, RelatedPostOrder.SkipPost);

            LookupManager.AddObject("Query", null, AvrQueryLookup.Accessor.Instance(null).GetType(), "_SelectListInternal");
            LookupManager.AddObject("LayoutFolder", null, AvrFolderLookup.Accessor.Instance(null).GetType(), "_SelectListInternal");
            LookupManager.AddObject("Layout", null, AvrLayoutLookup.Accessor.Instance(null).GetType(), "_SelectListInternal");

            m_PresenterTransaction = PresenterFactory.BeginSharedPresenterTransaction(m_Container, new BaseForm());
        }
Ejemplo n.º 5
0
        protected virtual string RenderCell(object value, LookupMatchesViolationData data, ColumnType columnType)
        {
            var factory   = new PresenterFactory();
            var presenter = factory.Instantiate(columnType);

            return(data.IsEqual ? presenter.Execute(value) : $"{presenter.Execute(value)} <> {presenter.Execute(data.Value)}");
        }
Ejemplo n.º 6
0
        public void ContextKeeperInPresenterTest()
        {
            Console.WriteLine(@"ContextKeeperInPresenterTest");

            using (PresenterFactory.BeginSharedPresenterTransaction(StructureMapContainerInit(), new BaseForm()))
            {
                var mocks            = new Mockery();
                var mapView          = mocks.NewMock <IMapView>();
                var layoutDetailView = mocks.NewMock <ILayoutDetailView>();
                Expect.Once.On(mapView).EventAdd("SendCommand", Is.Anything);
                Expect.Once.On(mapView).SetProperty("DBService");

                Expect.Once.On(layoutDetailView).EventAdd("SendCommand", Is.Anything);

                Expect.Once.On(layoutDetailView).SetProperty("DBService");

                var presenter1 =
                    PresenterFactory.SharedPresenter[mapView] as MapPresenter;
                Assert.IsNotNull(presenter1);
                var presenter2 =
                    PresenterFactory.SharedPresenter[layoutDetailView] as LayoutDetailPresenter;
                Assert.IsNotNull(presenter2);

                using (presenter1.SharedPresenter.ContextKeeper.CreateNewContext("ContextName"))
                {
                    Assert.IsTrue(presenter1.SharedPresenter.ContextKeeper.ContainsContext("ContextName"));
                    Assert.IsTrue(presenter2.SharedPresenter.ContextKeeper.ContainsContext("ContextName"));
                }
                Assert.IsFalse(presenter1.SharedPresenter.ContextKeeper.ContainsContext("ContextName"));
                Assert.IsFalse(presenter2.SharedPresenter.ContextKeeper.ContainsContext("ContextName"));
            }
        }
Ejemplo n.º 7
0
        //[TestMethod]
        public void testUpdatePatient()
        {
            Mock <IRepositoryFactory> repositoryFactory = new Mock <IRepositoryFactory>();
            Mock <IPresenterFactory>  presenterFactory  = new Mock <IPresenterFactory>();
            Mock <IQuestionView>      questionView      = new Mock <IQuestionView>();
            Mock <IGpView>            gpView            = new Mock <IGpView>();


            Patient patient = new Patient();

            patient.medicalQuestions = new MedicalQuestions();

            Dictionary <string, string> _questions = new Dictionary <string, string>();

            _questions.Add("Do you have alergy to latex?", "No");

            //questionView.Object.questions = _questions;

            GPPresenter gPPresenter = new PresenterFactory().getGPPresenter(patient,
                                                                            repositoryFactory.Object, presenterFactory.Object);

            // mock
            presenterFactory.Setup(x => x.getGPPresenter(patient, repositoryFactory.Object,
                                                         presenterFactory.Object)).Returns(gPPresenter);

            QuestionnairePresenter questionnairePresenter = new
                                                            QuestionnairePresenter(patient, presenterFactory.Object, repositoryFactory.Object);

            questionnairePresenter.view           = questionView.Object;
            questionnairePresenter.view.questions = _questions;
            questionnairePresenter.updatePatient(gpView.Object);
        }
Ejemplo n.º 8
0
        public void PublishAndUnpublishTest()
        {
            long layoutId = VirtualLayoutCopierTests.GetFirstlayoutId();

            //   layoutId = 56295660000000;
            if (layoutId > 0)
            {
                var  container = StructureMapContainerInit();
                long copiedId  = VirtualLayoutCopier.CreateLayoutCopyInAvrService(layoutId, "ru", container);

                SharedModel model;
                using (PresenterFactory.BeginSharedPresenterTransaction(container, new EmptyPostableForm()))
                {
                    model = PresenterFactory.SharedPresenter.SharedModel;
                }
                using (var dbService = new WinLayout_DB(model))
                {
                    long publishedId;

                    using (new StopwathTransaction("++ Publish layout " + copiedId))
                    {
                        publishedId = dbService.PublishUnpublish(copiedId, true);
                    }
                    Assert.AreEqual(1, GetLayoutCount(publishedId));

                    using (new StopwathTransaction("++ UnPublish layout " + publishedId))
                    {
                        dbService.PublishUnpublish(copiedId, false);
                    }
                    Assert.AreEqual(0, GetLayoutCount(publishedId));
                }
            }
        }
Ejemplo n.º 9
0
 protected override void RenderWhenModelIsNull(System.Web.UI.HtmlTextWriter writer)
 {
     if (IsEditing || IsPreviewing)
     {
         NullModelHelper.RenderNullModelMessage(writer, ViewPath, DataSource, PresenterFactory.GetPresenter <TModel>().GetType(), typeof(TModel));
     }
 }
Ejemplo n.º 10
0
        public void Execute_BooleanColumnObjectValueForFalse_DisplayIsFalse(object value)
        {
            var factory   = new PresenterFactory();
            var presenter = factory.Instantiate(ColumnType.Boolean);
            var text      = presenter.Execute(value);

            Assert.That(text, Is.EqualTo("False"));
        }
Ejemplo n.º 11
0
        public void Execute_StringNullValue_NullDisplay(ColumnType columnType)
        {
            var factory   = new PresenterFactory();
            var presenter = factory.Instantiate(columnType);
            var text      = presenter.Execute("(null)");

            Assert.That(text, Is.EqualTo("(null)"));
        }
Ejemplo n.º 12
0
        public void Execute_NumericColumnObjectValue_CorrectDisplay(object value, string expected)
        {
            var factory   = new PresenterFactory();
            var presenter = factory.Instantiate(ColumnType.Numeric);
            var text      = presenter.Execute(value);

            Assert.That(text, Is.EqualTo(expected));
        }
Ejemplo n.º 13
0
        protected override void OnApplicationStarted()
        {
            base.OnApplicationStarted();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            PresenterFactory.RegisterPresenters();
        }
Ejemplo n.º 14
0
        public void Execute_NumericDecimal_CorrectDisplay()
        {
            var factory   = new PresenterFactory();
            var presenter = factory.Instantiate(ColumnType.Numeric);
            var text      = presenter.Execute(10.400m);

            Assert.That(text, Is.EqualTo("10.4"));
        }
Ejemplo n.º 15
0
        public void Execute_TextColumnObjectValueCultureSpecific_CorrectDisplay(object value, string expected, string culture)
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(culture);
            var factory   = new PresenterFactory();
            var presenter = factory.Instantiate(ColumnType.Text);
            var text      = presenter.Execute(value);

            Assert.That(text, Is.EqualTo(expected));
        }
Ejemplo n.º 16
0
        private static UITouchBlockPresenter CreateTouchBlockPresenter(ICanvas canvas,
                                                                       string touchBlockWindowPrefabPath)
        {
            var touchBlockPrefabParams = PrefabGenParamsFactory.Create(canvas, touchBlockWindowPrefabPath);
            var touchBlockPresenter    =
                PresenterFactory <UITouchBlockPresenter, UITouchBlockWindow> .Create(touchBlockPrefabParams);

            return(touchBlockPresenter);
        }
Ejemplo n.º 17
0
        public void TestPresenterFactory()
        {
            ITestPresenter presenter = PresenterFactory.Create().GetPresenter <ITestPresenter>(new TestView());

            Assert.IsNotNull(presenter);

            ITestGenericPresentor <Entities.Address> presenter2 = PresenterFactory.Create().GetPresenter <ITestGenericPresentor <Entities.Address> >(new TestView());

            Assert.IsNotNull(presenter2);
        }
Ejemplo n.º 18
0
 public VirtualChart(IContainer container)
 {
     using (PresenterFactory.BeginSharedPresenterTransaction(container, new EmptyPostableForm()))
     {
         m_SharedPresenter = PresenterFactory.SharedPresenter;
         // any size
         m_ChartDetail = new ChartDetailForm {
             Size = new Size(1000, 1000)
         };
     }
 }
Ejemplo n.º 19
0
        protected TPresenter CreatePresenter <TPresenter, TView>(ICanvas canvas, string prefabPath)
            where TPresenter : PresenterBase <TView>
            where TView : ViewBase
        {
            var prefabGenParams = PrefabGenParamsFactory.Create(canvas, prefabPath);
            var presenter       = PresenterFactory <TPresenter, TView> .Create(prefabGenParams);

            _presenters.Add(presenter);

            return(presenter);
        }
Ejemplo n.º 20
0
        public void Start <TMainPresenter, TMainView>(IUnityContainer container, PresenterFactory presenterFactory, string viewKey, object input = null)
            where TMainPresenter : Presenter <TMainView>
            where TMainView : class, IView
        {
            if (!container.IsRegistered(presenterFactory.GetType()))
            {
                container.RegisterInstance(presenterFactory);
            }

            presenterFactory.Show <TMainPresenter, TMainView>(viewKey, input);
        }
Ejemplo n.º 21
0
        public override void MyTestInitialize()
        {
            base.MyTestInitialize();

            m_PresenterTransaction = PresenterFactory.BeginSharedPresenterTransaction(m_Container, new BaseForm());

            PresenterFactory.SharedPresenter.SharedModel.ExportStrategy = new FakeExportDialogStrategy();

            m_ChartForm      = new ChartDetailPanel();
            m_ChartPresenter = new ChartPresenter(PresenterFactory.SharedPresenter, m_ChartForm);
        }
Ejemplo n.º 22
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            RadiantDentalPracticeForm mainView = new RadiantDentalPracticeForm();

            IRepositoryFactory repositoryFactory = new RepositoryFactory();
            IPresenterFactory  presenterFactory  = new PresenterFactory();

            mainView.radiantDentalPracticePresenter = new RadiantDentalPracticePresenter(presenterFactory, repositoryFactory);
            Application.Run(mainView);
        }
Ejemplo n.º 23
0
        protected string GetCompareText(List <ColumnType> columnTypes, DataRow dataRow, int i)
        {
            if (string.IsNullOrEmpty(dataRow.GetColumnError(i)))
            {
                return(string.Empty);
            }

            var factory   = new PresenterFactory();
            var formatter = factory.Instantiate(columnTypes[i]);

            return(formatter.Execute(dataRow.GetColumnError(i)));
        }
Ejemplo n.º 24
0
        public VirtualPivot(IContainer container)
        {
            DevXLocalizer.Init();
            m_Container        = container;
            m_PivotPlaceHolder = new VirtualPivotPlaceHolder();

            using (PresenterFactory.BeginSharedPresenterTransaction(m_Container, m_PivotPlaceHolder))
            {
                m_SharedPresenter = PresenterFactory.SharedPresenter;
                m_DBService       = new WinLayout_DB(m_SharedPresenter.SharedModel);
                m_AvrPivot        = new AvrPivotGrid();
                m_PivotPlaceHolder.Controls.Add(m_AvrPivot);
            }
        }
Ejemplo n.º 25
0
        protected virtual void RenderCell(object value, LookupMatchesViolationData data, ColumnType columnType, JsonWriter writer)
        {
            var factory   = new PresenterFactory();
            var formatter = factory.Instantiate(columnType);

            writer.WriteStartObject();
            writer.WritePropertyName("value");
            writer.WriteValue(formatter.Execute(value));
            if (!data.IsEqual)
            {
                writer.WritePropertyName("expectation");
                writer.WriteValue(formatter.Execute(data.Value));
            }
            writer.WriteEndObject();
        }
Ejemplo n.º 26
0
        protected string GetText(List <ColumnType> columnTypes, DataRow dataRow, int i)
        {
            var factory   = new PresenterFactory();
            var formatter = factory.Instantiate(columnTypes[i]);

            var text = string.Empty;

            if (dataRow.IsNull(i))
            {
                text = formatter.Execute(DBNull.Value);
            }
            else
            {
                text = formatter.Execute(dataRow.ItemArray[i]);
            }
            return(text);
        }
Ejemplo n.º 27
0
        private void InitPresentersAndViews()
        {
            using (PresenterFactory.BeginSharedPresenterTransaction(StructureMapContainerInit(), new BaseForm()))
            {
                var mocks = new Mockery();

                var chartView = DataHelper.GetView <IChartView>(mocks);

                m_ChartPresenter = DataHelper.GetPresenter <ChartPresenter>(chartView);
                Assert.IsNotNull(m_ChartPresenter);

                IPivotDetailView pivotView = PivotPresenterReportTests.GetPivotView(mocks);
                m_PivotDetailPresenter = DataHelper.GetPresenter <PivotDetailPresenter>(pivotView);
                Assert.IsNotNull(m_PivotDetailPresenter);

                var mapView = DataHelper.GetView <IMapView>(mocks);
                m_MapPresenter = DataHelper.GetPresenter <MapPresenter>(mapView);
                Assert.IsNotNull(m_MapPresenter);

                var layoutInfoView = DataHelper.GetView <IPivotInfoDetailView>(mocks);
                m_PivotInfoPresenter = DataHelper.GetPresenter <PivotInfoPresenter>(layoutInfoView);
                Assert.IsNotNull(m_PivotInfoPresenter);

                var viewDetailView = DataHelper.GetView <IViewDetailView>(mocks);
                m_ViewDetailPresenter = DataHelper.GetPresenter <ViewDetailPresenter>(viewDetailView);
                Assert.IsNotNull(m_ViewDetailPresenter);



                var layoutDetailView = DataHelper.GetView <ILayoutDetailView>(mocks);

                m_LayoutDetailPresenter = DataHelper.GetPresenter <LayoutDetailPresenter>(layoutDetailView);
                Assert.IsNotNull(m_LayoutDetailPresenter);

                var pivotGridView = mocks.NewMock <IAvrPivotGridView>();
                Expect.Once.On(pivotGridView).EventAdd("SendCommand", Is.Anything);
                m_PivotGridPresenter = PresenterFactory.SharedPresenter[pivotGridView] as AvrPivotGridPresenter;
                Assert.IsNotNull(m_PivotGridPresenter);


                mocks.VerifyAllExpectationsHaveBeenMet();
            }
        }
Ejemplo n.º 28
0
        public void ZlibLayoutTest()
        {
            string streamXml;

            using (PresenterFactory.BeginSharedPresenterTransaction(m_Container, new BaseForm()))
            {
                using (var pivotGrid = new AvrPivotGrid())
                {
                    var dataTable = new AvrDataTable(DataHelper.GenerateTestTable());
                    pivotGrid.SetDataSourceAndCreateFields(dataTable);

                    streamXml = ViewReportTests.GetLayoutXml(pivotGrid);
                }
            }

            byte[] bytes = BinaryCompressor.ZipString(streamXml);

            string uncompressed = BinaryCompressor.UnzipString(bytes);

            Assert.AreEqual(streamXml, uncompressed);
        }
        public void registerPatientPositiveCase()
        {
            Mock <IQuestionView> questionview = new Mock <IQuestionView>();
            Mock <IPatientView>  view         = new Mock <IPatientView>();

            IPresenterFactory  presenterFactory  = new PresenterFactory();
            IRepositoryFactory repositoryFactory = new RepositoryFactory();

            PatientPresenter patientpresenter = new PatientPresenter(
                presenterFactory, repositoryFactory);

            patientpresenter.view             = view.Object;
            patientpresenter.view.city        = "newcastle";
            patientpresenter.view.country     = "UK";
            patientpresenter.view.postcode    = "ne48as";
            patientpresenter.view.email       = "*****@*****.**";
            patientpresenter.view.name        = "priyanka";
            patientpresenter.view.phoneNumber = "1234567890";
            patientpresenter.view.dob         = DateTime.Now;
            patientpresenter.RegisterPatient(questionview.Object);
            //patientpresenter.validate();
        }
Ejemplo n.º 30
0
        private static void Main()
        {
            Application.SetHighDpiMode(HighDpiMode.SystemAware);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var host = Host.CreateDefaultBuilder()
                       .ConfigureServices((services) =>
            {
                services.AddTransient <IPresenter <MainFormView>, MainFormPresenter <MainFormView> >();
                services.AddTransient <IOfficeAppProvider, OfficeAppProvider>();
                services.AddSingleton <IMainFormView, MainFormView>();
                services.AddSingleton <IProcessWatcher, ProcessWatcher>();
            })
                       .Build();

            VaultLocationConfig.ConfigureVault();
            PresenterFactory.SetHost(host);
            var app = ActivatorUtilities.GetServiceOrCreateInstance <MainFormView>(host.Services);

            Application.Run(app);
        }
Ejemplo n.º 31
0
 public void SetUp()
 {
     kernel = new StandardKernel(new DefaultModule(), new FrameworkDictionaryModule(10));
     target = new PresenterFactory(kernel);
 }
Ejemplo n.º 32
0
 public CompressionView(PresenterFactory presenterFactory)
 {
     presenter = presenterFactory.CreateCompressionPresenter(this);
 }