public void SetConfiguration(ITaskConfig config, Dictionary <object, object> properties) { _config = new MockTaskConfig(); _config.Description = config.Description; _config.CustomProperty = properties["customProperty"].ToString(); _config.Config = config.Config; }
public void should_parse_custom_property_using_task() { // given var readerMock = new ConfigFileReaderMock(); readerMock.Yaml = ExampleYaml.MockTest; var registeredTasks = new Dictionary <string, ITask>(); registeredTasks.Add("mock-task", new MockTask()); var yamlParser = new YamlConfigParser(readerMock, registeredTasks, _logger); // when List <ITask> tasks = yamlParser.Parse(new Uri("file://filename")); // then Assert.That(tasks.Count, Is.EqualTo(1)); ITask task = tasks.First(); Assert.That(task, Is.Not.Null); Assert.That(task, Is.TypeOf <MockTask>()); MockTaskConfig config = task.Config as MockTaskConfig; Assert.That(config, Is.Not.Null); Assert.That(config.CustomProperty, Is.EqualTo("ahyeh")); }
public void SetConfiguration_should_set_config_from_properties() { // given var config = new MockTaskConfig(); var task = new InstallChocolateyTask(_powershellMock); var properties = new Dictionary <object, object>(); // when task.SetConfiguration(config, properties); // then Assert.That(task.Config, Is.Not.Null); }
public void TestTaskMockSessionHungStart() { var startup = new MockTaskConfig { HandshakeTimeoutMsec = 50 }; var session = new MockTaskSession(startup); session.HangMsec = 100; // Test a hung start. var startResult = session.Start(); Assert.AreEqual(false, startResult.Success); }
public void TestStartExceptionMode() { // Set the handshake timeout to 50msec. var startup = new MockTaskConfig { HandshakeTimeoutMsec = 50 }; var session = new MockTaskSession(startup); // Set the response hang time to twice that. session.HangMsec = 100; // Set exception mode for any failure, including Start. session.ExceptionMode = true; // Boom. Assert.Throws <X3270ifCommandException>(() => session.Start()); }
public void should_ignore_empty_config_keys() { // given var readerMock = new ConfigFileReaderMock(); readerMock.Yaml = ExampleYaml.EmptyConfigKeys; var registeredTasks = new Dictionary <string, ITask>(); registeredTasks.Add("mock-task", new MockTask()); var yamlParser = new YamlConfigParser(readerMock, registeredTasks, _logger); // when List <ITask> tasks = yamlParser.Parse(new Uri("file://filename")); // then ITask task = tasks.First(); MockTaskConfig config = task.Config as MockTaskConfig; Assert.That(config, Is.Not.Null); Assert.That(config.Config.Count, Is.EqualTo(1)); }
public void should_parse_config_section() { // given var readerMock = new ConfigFileReaderMock(); readerMock.Yaml = ExampleYaml.MockTest; var registeredTasks = new Dictionary <string, ITask>(); registeredTasks.Add("mock-task", new MockTask()); var yamlParser = new YamlConfigParser(readerMock, registeredTasks, _logger); // when List <ITask> tasks = yamlParser.Parse(new Uri("file://filename")); // then ITask task = tasks.First(); MockTaskConfig config = task.Config as MockTaskConfig; Assert.That(config, Is.Not.Null); Assert.That(config.Config["KEY1"], Is.EqualTo("abc")); Assert.That(config.Config["KEY2"], Is.EqualTo("xyz")); }
/// <summary> /// Initializes a new instance of the <see cref="MockTaskSession"/> class. /// Forces the base constructor to crash. /// </summary> /// <param name="config">The configuration.</param> /// <param name="forceChaos">Flag indicating that a crash should be forced</param> public MockTaskSession(MockTaskConfig config, bool forceChaos) : base(config, null) { // Base constructor should have blown up at this point. }
/// <summary> /// Initializes a new instance of the <see cref="MockTaskSession"/> class. /// </summary> /// <param name="config">The configuration.</param> public MockTaskSession(MockTaskConfig config = null) : base(config, new MockBackEnd(config)) { // Remember the back end. this.mockBackEnd = (MockBackEnd)BackEnd; }
/// <summary> /// Initializes a new instance of the <see cref="MockBackEnd"/> class. /// Constructor, which ensures there is a Server object. /// </summary> /// <param name="config">The configuration</param> public MockBackEnd(MockTaskConfig config) { this.config = config ?? new MockTaskConfig(); this.mockServer = new Server(); }