private void CreateCloseCommands() { foreach (var name in closingPanels) { var panel = composer.GetPanel(name); Requires.NotNull(panel, nameof(panel)); if (modesController.TryGetPanelInfo(panel, out var panelInfo) == false) { continue; } ICommand command; if (panelInfo.Mode == Modes.Modal) { command = new CommandClosePanelModal(panel, modesController); } else { command = new CommandClosePanelNone(panel, modesController); } batch.Add(command); } }
public void ShouldAddACommandToTheCommandBatch(Type fixtureType) { var fixture = Activator.CreateInstance(fixtureType) as CommandBatchFixtureBase; var commandBatch = new CommandBatch(fixture.Connector); var commandBuilderFactory = fixture.Connector.GetCommandBuilderFactory(); var tableTypeDescriptor = DescriptorCache.Instance.GetTableTypeDescriptor(typeof(BatchMock)); var valueProvider = new ClassValueProvider(fixture.Connector, new List <object> { fixture.CreateMock(), fixture.CreateMock() }); commandBatch.Add(new CommandBatchStep(commandBuilderFactory.CreateInsertCommandBuilder(tableTypeDescriptor).GetCommand(valueProvider))); commandBatch.Add(new CommandBatchStep(commandBuilderFactory.CreateInsertCommandBuilder(tableTypeDescriptor).GetCommand(valueProvider))); commandBatch.GetCommand().CommandText.Should().Be(fixture.CommandBatchText); }
public void CommandBatch_Execute_Success() { // Arrange Command.Counter = 0; var command1 = new Command(2); var command2 = new Command(1); var command3 = new Command(3); // Act var batch = new CommandBatch(); batch.Add(command3) .Add(command2) .Add(command1) .Execute(); var task = Task.Run(async() => { while (batch.IsDone == false) { await Task.Delay(TimeSpan.FromMilliseconds(20)); } return(1); }); var unused = task.Result; //Assert Assert.AreEqual(1, command2.Count); Assert.AreEqual(2, command1.Count); Assert.AreEqual(3, command3.Count); }