public void MergeRaisesSynchronizedEvent() { MockHost.MockJson(); MockHost.JsonFactory.Setup(f => f.Create <SynchronizedData>()) .Returns(new SynchronizedData()); TrelloConfiguration.RefreshThrottle = TimeSpan.FromDays(1); var counter = 0; var target = new SynchronizedObject { NewData = new SynchronizedData { Test = "one" } }; target.PublicSynchronized += properties => counter++; target.Merge(new SynchronizedData { Test = "two" }); counter.Should().Be(1); target.Data.Test.Should().Be("two"); }
public async Task NoRefreshThrottleAllowsCalls() { var currentThrottle = TrelloConfiguration.RefreshThrottle; try { MockHost.MockJson(); MockHost.JsonFactory.Setup(f => f.Create <SynchronizedData>()) .Returns(new SynchronizedData()); TrelloConfiguration.RefreshThrottle = TimeSpan.Zero; var target = new SynchronizedObject(); await target.Synchronize(false, CancellationToken.None); await target.Synchronize(false, CancellationToken.None); target.RetrievalCount.Should().Be(2); } finally { TrelloConfiguration.RefreshThrottle = currentThrottle; } }
public async Task ForcedRefreshOverridesThrottle() { var currentThrottle = TrelloConfiguration.RefreshThrottle; try { MockHost.MockJson(); MockHost.JsonFactory.Setup(f => f.Create <SynchronizedData>()) .Returns(new SynchronizedData()); TrelloConfiguration.RefreshThrottle = TimeSpan.FromDays(1); var target = new SynchronizedObject(); await target.Synchronize(true, CancellationToken.None); await target.Synchronize(true, CancellationToken.None); target.RetrievalCount.Should().Be(2); } finally { TrelloConfiguration.RefreshThrottle = currentThrottle; } }
public async Task SynchronizeRaisesSynchronizedEvent() { var currentThrottle = TrelloConfiguration.RefreshThrottle; try { MockHost.MockJson(); MockHost.JsonFactory.Setup(f => f.Create <SynchronizedData>()) .Returns(new SynchronizedData()); TrelloConfiguration.RefreshThrottle = TimeSpan.FromDays(1); var counter = 0; var target = new SynchronizedObject { NewData = new SynchronizedData { Test = "one" } }; target.PublicSynchronized += properties => counter++; await target.Synchronize(false, CancellationToken.None); counter.Should().Be(1); } finally { TrelloConfiguration.RefreshThrottle = currentThrottle; } }
public TestHarness(int taskId = 42) { MockHost = Mocks.Create <PSHost>(); MockUI = Mocks.Create <PSHostUserInterface>(MockBehavior.Loose); MockHost .SetupGet(h => h.UI) .Returns(MockUI.Object); TaskHost = new TaskHost(MockHost.Object, new ConsoleState(), taskId); }
/// <summary> /// Instantiate and Initialize a new loggingService. /// This is used by the test setup method to create /// a new logging service before each test. /// </summary> private void InitializeLoggingService() { BuildParameters parameters = new BuildParameters(); parameters.MaxNodeCount = 2; MockHost mockHost = new MockHost(parameters); IBuildComponent logServiceComponent = (IBuildComponent)LoggingService.CreateLoggingService(LoggerMode.Synchronous, 1); logServiceComponent.InitializeComponent(mockHost); _initializedService = logServiceComponent as LoggingService; }
public void GetValueDoesNotRetrieve() { MockHost.MockJson(); MockHost.JsonFactory.Setup(f => f.Create <SynchronizedData>()) .Returns(new SynchronizedData()); var target = new SynchronizedObject(); var value = target.GetValue <string>(nameof(SynchronizedData.Test)); value.Should().Be("default"); target.RetrievalCount.Should().Be(0); }
public async Task UnsupportedUpdateSkipsSubmission() { MockHost.MockJson(); MockHost.JsonFactory.Setup(f => f.Create <SynchronizedData>()) .Returns(new SynchronizedData()); var target = new SynchronizedObject { SupportsUpdates = false }; await target.Synchronize(false, CancellationToken.None); target.SubmissionCount.Should().Be(0); }
public async Task SettingDataMergesRequests() { MockHost.MockJson(); MockHost.JsonFactory.Setup(f => f.Create <SynchronizedData>()) .Returns(new SynchronizedData()); TrelloConfiguration.ChangeSubmissionTime = TimeSpan.FromMilliseconds(100); var target = new SynchronizedObject(); await target.SetValue(nameof(SynchronizedData.Test), "one", CancellationToken.None); await target.SetValue(nameof(SynchronizedData.Test), "two", CancellationToken.None); await Task.Delay(150); target.SubmissionCount.Should().Be(1); }
private void RunFormTest(Func <MockHost, Task> testDriverAsync) { UITest.RunForm( () => { _form = new MockHost(_referenceRepository.Module) { Size = new(800, 400) }; _settingsPage = SettingsPageBase.Create <BuildServerIntegrationSettingsPage>(_form); _settingsPage.Dock = DockStyle.Fill; _form.Controls.Add(_settingsPage); _form.ShowDialog(owner: null); }, testDriverAsync); }
public void InitializeComponent() { IBuildComponent logServiceComponent = (IBuildComponent)LoggingService.CreateLoggingService(LoggerMode.Synchronous, 1); BuildParameters parameters = new BuildParameters(); parameters.MaxNodeCount = 4; parameters.OnlyLogCriticalEvents = true; IBuildComponentHost loggingHost = new MockHost(parameters); // Make sure we are in the Instantiated state before initializing Assert.Equal(((LoggingService)logServiceComponent).ServiceState, LoggingServiceState.Instantiated); logServiceComponent.InitializeComponent(loggingHost); // Makesure that the parameters in the host are set in the logging service LoggingService service = (LoggingService)logServiceComponent; Assert.Equal(service.ServiceState, LoggingServiceState.Initialized); Assert.Equal(4, service.MaxCPUCount); Assert.True(service.OnlyLogCriticalEvents); }
public void TearDown() { MockHost.ResetRest(); }
public void Setup() { MockHost.MockRest <SynchronizedData>(); TrelloAuthorization.Default.AppKey = "test"; }