Ejemplo n.º 1
0
        public void InvokeGoHome()
        {
            var view      = new MockBrowserView();
            var history   = new MockHistory();
            var favorites = new MockFavorites();
            var config    = new MockConfig();
            var presenter = new BrowserPresenter <MockTabPresenter>(
                view,
                history,
                favorites,
                config,
                new MockFaviconCache(),
                (tab, f, c, favicons, h, tabHistory) => new MockTabPresenter(tab, f, c, favicons, h, tabHistory));

            var url  = Url.FromString("www.myfavorite.com");
            var url2 = Url.FromString("www.myfavorite2.com");

            favorites.GetOrCreate(url);
            favorites.GetOrCreate(url2);
            view.InvokeFavoritesListOpen(0);
            view.InvokeFavoritesListOpen(1);

            view.InvokeFavoritesListOpen(0);

            Assert.AreEqual(history.GetViewModel()[history.GetViewModel().Count - 1].GetUrl(), url);

            view.InvokeGoHome();

            Assert.AreEqual(history.GetViewModel()[history.GetViewModel().Count - 1].GetUrl(), config.Home);
        }
 public MetricUrlBuilderTests()
 {
     _config = new MockConfig
     {
         ApiKey      = "123",
         BaseAddress = "abc"
     };
     _sut = new MetricUrlBuilder(_config);
 }
Ejemplo n.º 3
0
        public void ShouldRequestContinue__Returns_False_If_Playbook_Not_In_Config()
        {
            var configProps = new Dictionary <string, string>();
            var mockConfig  = new MockConfig(configProps);
            var mockShortCircuitImplementation = new GetGlobalActionsShortCircuit(mockConfig);

            var result = mockShortCircuitImplementation.ShouldRequestContinue(mockConfig);

            Assert.AreEqual(result, false);
        }
Ejemplo n.º 4
0
 public TestContext()
 {
     Units = new List <IUnit> {
         new MockUnit()
     };
     Config  = new MockConfig();
     Player  = new MockPlayer();
     Target  = new NullUnit();
     MockAPI = new MockEliteAPI();
     API     = new MockEliteAPIAdapter(MockAPI);
     Memory  = new StateMemory(API);
 }
Ejemplo n.º 5
0
        public OpenWeatherClientTests()
        {
            _config = new MockConfig
            {
                BaseAddress    = "http://api.openweathermap.org/data/2.5/weather",
                ApiKey         = "62ffa8c4c1dfbc438b162198e174c4cb",
                State          = "wa",
                IsoCountryCode = "au"
            };

            _sut = new OpenWeatherClient(new HttpClient(), _config, new MetricUrlBuilder(_config));
        }
Ejemplo n.º 6
0
        public void ShouldRequestContinue__Returns_True_If_Playbook_In_Config()
        {
            var configProps = new Dictionary <string, string>();

            configProps.Add("Microservices:0", "Playbook");
            var mockConfig = new MockConfig(configProps);
            var mockShortCircuitImplementation = new GetEventTypeShortCircuit(mockConfig);

            var result = mockShortCircuitImplementation.ShouldRequestContinue(mockConfig);

            Assert.AreEqual(result, true);
        }
Ejemplo n.º 7
0
        public void SHOULD_set_class_and_method_names()
        {
            //Arrange
            MockConfig.With(x => x.InstrumentationKey, "instrument");
            MockConfig.With(x => x.RoleName, "Mata Hari");

            //Act
            var result = Sut.DecorateTelemetry(new EventTelemetry("event"), "Class Name", "Method Name",
                                               new MockBuilder <IAnalyticsOperation>().Object, new MockBuilder <IAnalyticsSession>().Object, new Dictionary <string, object>());

            //Assert
            Assert.That(result.Properties["Class"], Is.EqualTo("Class Name"));
            Assert.That(result.Properties["Method"], Is.EqualTo("Method Name"));
        }
Ejemplo n.º 8
0
        public void SHOULD_append_config_values()
        {
            //Arrange
            MockConfig.With(x => x.InstrumentationKey, "instrument");
            MockConfig.With(x => x.RoleName, "Mata Hari");

            //Act
            var result = Sut.DecorateTelemetry(new EventTelemetry("event"), "Class Name", "Method Name",
                                               new MockBuilder <IAnalyticsOperation>().Object, new MockBuilder <IAnalyticsSession>().Object, new Dictionary <string, object>());

            //Assert
            Assert.That(result.Context.Cloud.RoleName, Is.EqualTo("Mata Hari"));
            Assert.That(result.Context.InstrumentationKey, Is.EqualTo("instrument"));
        }
Ejemplo n.º 9
0
        public async Task Test1()
        {
            // Arrange
            var mockRepo   = new MockMessagesRepository();
            var mockConfig = new MockConfig();
            var controller = new HomeController(null, null, null, mockConfig, mockRepo);
            var m          = new Message
            {
                Username = "******",
                Text     = "test"
            };
            // Act
            var result = await controller.Create(m);

            // Assert
            var okResult = Assert.IsType <Microsoft.AspNetCore.Mvc.OkResult>(result);
        }
Ejemplo n.º 10
0
        public void InvokeGoHomeTest()
        {
            var config     = new MockConfig();
            var tabHistory = new MockTabHistory();

            var view      = new MockTabView();
            var presenter = new TabPresenter(
                view,
                new MockFavorites(),
                config,
                new MockFaviconCache(),
                new MockHistory(),
                tabHistory);

            view.InvokeGoHome();
            Assert.AreEqual(config.Home, tabHistory.Current().Url);
        }
        public void IF_configured_min_logSeverity_is_higher_than_message_SHOULD_not_trace_to_server()
        {
            //Arrange
            CurrentBuildConfig = BuildConfig.Debug;
            var properties = new Dictionary <string, object>();

            MockConfig.With(x => x.MinimumLogToServerSeverity, new Dictionary <IBuildConfig, LogSeverity>
            {
                { BuildConfig.Debug, LogSeverity.Information }
            });

            //Act
            Sut.Trace(this, "Trace message", LogSeverity.Verbose, properties);

            //Assert
            MockConsoleLogger.Mock.Verify(x => x.LogTrace("Trace message", LogSeverity.Verbose, It.IsAny <Dictionary <string, string> >()));
            MockTelemetryClient.Mock.Verify(x => x.TrackTrace(It.IsAny <TraceTelemetry>()), Times.Never);
        }
Ejemplo n.º 12
0
 public MockKapturePlugin(int langCode = 0)
 {
     PluginName    = "Kapture";
     Localization  = new Localization(this);
     Configuration = new MockConfig
     {
         AddEnabled      = true,
         CastEnabled     = true,
         CraftEnabled    = true,
         DesynthEnabled  = true,
         DiscardEnabled  = true,
         GatherEnabled   = true,
         GreedEnabled    = true,
         LostEnabled     = true,
         NeedEnabled     = true,
         ObtainEnabled   = true,
         PurchaseEnabled = true,
         SearchEnabled   = true,
         SellEnabled     = true,
         UseEnabled      = true
     };
     RollMonitor = new RollMonitor(this);
     if (langCode == 0)
     {
         LootProcessor = new ENLootProcessor(this);
     }
     else if (langCode == 1)
     {
         LootProcessor = new ENLootProcessor(this);
     }
     else if (langCode == 2)
     {
         LootProcessor = new DELootProcessor(this);
     }
     else if (langCode == 3)
     {
         LootProcessor = new ENLootProcessor(this);
     }
     else if (langCode == 4)
     {
         LootProcessor = new ZHLootProcessor(this);
     }
 }
Ejemplo n.º 13
0
        public void InvokeHistoryListSave()
        {
            var view      = new MockBrowserView();
            var history   = new MockHistory();
            var config    = new MockConfig();
            var presenter = new BrowserPresenter <MockTabPresenter>(
                view,
                history,
                new MockFavorites(),
                config,
                new MockFaviconCache(),
                (tab, favorites, c, favicons, h, tabHistory) => new MockTabPresenter(tab, favorites, c, favicons, h, tabHistory));

            // save mock.com to favorites
            view.InvokeHistoryListSave(0);

            // open mock.com from favorites
            view.InvokeFavoritesListOpen(0);

            Assert.AreEqual(config.Home, history.GetViewModel()[history.GetViewModel().Count - 1].GetUrl());
        }
Ejemplo n.º 14
0
        public void InvokeFavoritesListOpen()
        {
            var config    = new MockConfig();
            var favorites = new MockFavorites();
            var view      = new MockBrowserView();
            var presenter = new BrowserPresenter <MockTabPresenter>(
                view,
                new MockHistory(),
                favorites,
                config,
                new MockFaviconCache(),
                (tab, f, c, favicons, history, tabHistory) => new MockTabPresenter(tab, f, c, favicons, history, tabHistory));

            favorites.GetOrCreate(Url.FromString("www.myfavorite.com"));
            view.InvokeFavoritesListOpen(0);

            // easiest way to check if the url has changed
            var oldHome = config.Home;

            view.InvokeHomeChanged();
            Assert.AreNotEqual(oldHome, config.Home);
        }
Ejemplo n.º 15
0
        public void InvokeHistoryListOpen()
        {
            var config    = new MockConfig();
            var favorites = new MockFavorites();
            var view      = new MockBrowserView();
            var presenter = new BrowserPresenter <MockTabPresenter>(
                view,
                new MockHistory(),
                favorites,
                config,
                new MockFaviconCache(),
                (tab, f, c, favicons, history, tabHistory) => new MockTabPresenter(tab, f, c, favicons, history, tabHistory));

            var url  = Url.FromString("www.myfavorite.com");
            var url2 = Url.FromString("www.myfavorite2.com");

            favorites.GetOrCreate(url);
            favorites.GetOrCreate(url2);
            view.InvokeFavoritesListOpen(0);
            view.InvokeFavoritesListOpen(1);

            // 0 - mock.com
            // 1 - url
            // 2 - url2

            view.InvokeHistoryListOpen(1);

            // easiest way to check if the url has changed
            view.InvokeHomeChanged();
            Assert.AreEqual(url, config.Home);

            view.InvokeHistoryListOpen(2);

            // easiest way to check if the url has changed
            view.InvokeHomeChanged();
            Assert.AreEqual(url2, config.Home);
        }
Ejemplo n.º 16
0
        public void ReturnsNullWithMockConfig()
        {
            MockConfig mc = new MockConfig();

            Assert.IsNull(DataBaseFactory.getDatabase(mc));
        }