Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            GenericHostingEnvironment.Instance = new EPiServerHostingEnvironment();
            InitializationModule.FrameworkInitialization(HostType.TestFramework);
            System.Console.WriteLine("EPiServer initialized");

            Container.GetInstance <IApplication>().Run(); // is set via initialization module

            InitializationModule.FrameworkUninitialize();
            System.Console.WriteLine("EPiServer uninitialized");
        }
Ejemplo n.º 2
0
        protected internal static void Main(string[] arguments)
        {
            Thread.CurrentThread.CurrentCulture   = CultureInfo.GetCultureInfo("en-US");
            Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en");

            try
            {
                InitializationModule.FrameworkInitialization(HostType.WebApplication);

                var eventBroker = ServiceLocator.Current.GetInstance <IEventBroker>();

                if (IsPublishMode(arguments))
                {
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine("Publishing (press \"Enter\", without typing a message, to exit)");
                    Console.WriteLine("*************************************************************");
                    Console.ResetColor();

                    string parameter;

                    while (!string.IsNullOrEmpty(parameter = Console.ReadLine()))
                    {
                        try
                        {
                            eventBroker.RaiseEventAsync(Guid.NewGuid(), parameter);
                            WriteConfirmation(string.Format(CultureInfo.InvariantCulture, "Event with parameter \"{0}\" was raised. Check the log file if you have problems.", parameter));
                        }
                        catch (Exception exception)
                        {
                            WriteException(exception);
                        }
                    }
                }
                else
                {
                    eventBroker.EventMissed   += (sender, e) => { WriteEventMissed(e); };
                    eventBroker.EventReceived += (sender, e) => { WriteEventReceived(e); };

                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine("Subscribing (press any key to exit)");
                    Console.WriteLine("***********************************");
                    Console.ResetColor();

                    Console.ReadKey();
                }
            }
            catch (Exception exception)
            {
                WriteException(exception);
                PressAnyKeyToExit();
            }
        }
Ejemplo n.º 3
0
        public void MyTestInitialize()
        {
            InitializationModule.FrameworkInitialization(HostType.TestFramework);
            // Create a mock repository
            var mockRepository = new Mock <IContentRepository>();
            var mocksynchronizedObjectInstanceCache = new Mock <ISynchronizedObjectInstanceCache>();
            var abc  = new Mock <IEventRegistry>();
            var abc1 = new Mock <IObjectInstanceCache>();

            // Setup the repository to return a start page with a preset property value
            mockRepository.Setup(r => r.Get <HomePageForTest>(ContentReference.StartPage)).Returns(new HomePageForTest {
                CompanyName = "My company name"
            });

            // Create a mock service locator
            var mockLocator = new Mock <IServiceLocator>();

            // Setup the service locator to return our mock repository when an IContentRepository is requested
            mockLocator.Setup(l => l.GetInstance <IContentRepository>()).Returns(mockRepository.Object);
            mockLocator.Setup(c => c.GetInstance <IEventRegistry>()).Returns(abc.Object);
            mockLocator.Setup(c => c.GetInstance <IObjectInstanceCache>("RemoteCacheSynchronization")).Returns(abc1.Object);
            mockLocator.Setup(c => c.GetInstance <ISynchronizedObjectInstanceCache>()).Returns(mocksynchronizedObjectInstanceCache.Object);


            // Make use of our mock objects throughout EPiServer
            ServiceLocator.SetLocator(mockLocator.Object);

            cache                  = DataCacheHandler.Instance;
            cache.ExecTimeOut      = new TimeSpan(0, 0, 0, 0, 100);
            cache.FailCountTimeout = new TimeSpan(0, 0, 0, 0, 100);
            cache.FailCountLimit   = 3;
            var str = rnd.Next().ToString();

            key1      = "key1 " + str;
            key2      = "key2 " + str;
            key3      = "key3 " + str;
            resource  = "resource " + str;
            o1        = "o1 " + key1;
            o2        = "o2 " + key1;
            o3        = "o3 " + key1;
            o4        = "o4 " + key1;
            testStart = DateTime.Now;
        }