public void Test() { object gate = new object(); bool hasCompleted = false; List<byte> bytesRead = new List<byte>(); _target = new RequestStreamWriter( new TestStream( (buffer, offset, count) => { int a = 0; a++; }, (buffer, offset, count) => { lock (gate) { var bytes = new byte[count]; Array.Copy(buffer, offset, bytes, 0, count); bytesRead.AddRange(bytes); hasCompleted = bytesRead.Count >= 28; Monitor.Pulse(gate); } }), command => null, () => { }); object state = new object(); GetCommand getCommand = new GetCommand(3, "key0", state, (status, value, cas, stat) => {}); getCommand.SetVBucketId(17); _target.Send(getCommand); lock (gate) { while (!hasCompleted) { Monitor.Wait(gate); } } var written = bytesRead.ToArray(); Assert.AreEqual(28, written.Length); Assert.AreEqual(MagicBytes.RequestPacket, (MagicBytes)written[0]); Assert.AreEqual(Opcode.Get, (Opcode)written[1]); Assert.AreEqual(4, BitParser.ParseUShort(written, 2)); Assert.AreEqual(0, written[4]); Assert.AreEqual(0, written[5]); Assert.AreEqual(17, BitParser.ParseUShort(written, 6)); Assert.AreEqual(4, BitParser.ParseInt(written, 8)); Assert.AreEqual(3, BitParser.ParseInt(written, 12)); Assert.AreEqual(0, BitParser.ParseLong(written, 16)); Assert.AreEqual("key0", Encoding.UTF8.GetString(written, 24, 4)); }
public void EngineGet_Execute_ReturnsNotFoundMessage() { var command = new GetCommand(_console, LoggerMock.GetLogger <GetCommand>().Object, _engineService.Object) { Name = "Engine02" }; var resultMessage = command.Execute(); Assert.Equal("Engine Engine02 was not found", resultMessage); }
public void ProjectGete_Execute_ReturnsNotFoundMessage() { var command = new GetCommand(_console, LoggerMock.GetLogger <GetCommand>().Object, _projectService.Object) { Name = "Project 2" }; var resultMessage = command.Execute(); Assert.Equal("Project Project 2 was not found", resultMessage); }
public void ProjectGet_Execute_ReturnsSuccessMessage() { var command = new GetCommand(_console, LoggerMock.GetLogger <GetCommand>().Object, _projectService.Object) { Name = "Project 1" }; var resultMessage = command.Execute(); Assert.StartsWith("Project Project 1", resultMessage); }
public void CanUseRelativePaths(string basePath, string packageConfig, int expectedCount) { GetCommand.Arguments.Add(packageConfig); GetCommand.ExcludeVersion = true; GetCommand.Latest = true; GetCommand.BaseDirectory = basePath; GetCommand.ExecuteCommand(); var packageCount = FileSystem.Object.GetDirectories(@"c:\TestSolution\packages").Count(); Assert.AreEqual(expectedCount, packageCount); }
static void Main(string[] args) { if (args.Length == 0) args = Console.ReadLine().ToArgs(); var get = new GetCommand(); var post = new PostCommand(); get.SetNext(post); get.Execute(args); }
private string PerformGet(GetCommand command) { if (_storage.TryGetValue(command.Key, out var value)) { if (value is StringValue) { return(value.Display()); } return($"Type associated with key {command.Key} is not a common type"); } return("Key does not exits"); }
public void ModelGet_Execute_ReturnsNotFoundMessage() { var command = new GetCommand(_console, LoggerMock.GetLogger <GetCommand>().Object, _projectService.Object, _projectModelService.Object) { Project = "Project 1", Name = "Tag" }; var resultMessage = command.Execute(); Assert.Equal("Failed to get model Tag. Make sure the project and model names are correct.", resultMessage); }
public void ModelGet_Execute_ReturnsSuccessMessage() { var command = new GetCommand(_console, LoggerMock.GetLogger <GetCommand>().Object, _projectService.Object, _projectModelService.Object) { Project = "Project 1", Name = "Product" }; var resultMessage = command.Execute(); Assert.StartsWith("Data model Product", resultMessage); }
public void ConfigGet_Execute_ReturnsItem() { var console = new TestConsole(_output); var command = new GetCommand(_cliConfig.Object, console, (new Mock <ILogger <GetCommand> >()).Object) { ConfigName = "config1" }; var message = command.Execute(); Assert.StartsWith("config1: config 1 value", message); }
public void GetCommand_CheckLogic_EmptyList() { var chatMembers = new List <ChatMember>(); var dbProviderMock = GetDbProvider(chatMembers); var parametersParser = GetParametersParser(); var getCommand = new GetCommand(dbProviderMock, null, null, parametersParser); var context = new CommandContext("Reviewer1", "1", null); var result = getCommand.Execute(context); Assert.AreEqual($"Список ревьюверов пуст{Environment.NewLine}{Environment.NewLine}Reviewer1, присоединяйтесь к списку ревьюверов!", result); }
public void Calling_without_any_keys_will_result_in_error() { var stream = new MemoryStream(); var command = new GetCommand(); command.SetContext(stream); command.Init(); string actual = ReadAll(stream); Assert.AreEqual("CLIENT_ERROR At least one key should be specified\r\n", actual); }
public void QueueGet_Execute_ReturnsNotFoundMessage() { var command = new GetCommand(_projectService.Object, _jobQueueService.Object, _console, LoggerMock.GetLogger <GetCommand>().Object) { Project = "Project 1", Number = "2" }; var resultMessage = command.Execute(); Assert.Equal("Failed getting queue 2. Make sure the project name and queue number are correct.", resultMessage); }
public void ServiceGet_Execute_ReturnsSuccessMessage() { var console = new TestConsole(_output, "userPassword"); var command = new GetCommand(console, LoggerMock.GetLogger <GetCommand>().Object, _externalServiceService.Object, _externalServiceTypeService.Object) { Name = "Default-Github" }; var resultMessage = command.Execute(); Assert.StartsWith("External Service Default-Github:", resultMessage); }
public void Execute_PassWordAndVocabularyReturnEmptyResults_ReturnNoSuchWord() { // Arrange var word = "aaa"; var command = new GetCommand(VocabularyStubFactory.Get(word, new string[0])); // Act var result = command.Execute(new [] { word }); // Assert Assert.AreEqual(result, Default.NoSuchWord); }
public void JobGet_Execute_ReturnsSuccessMessage() { var command = new GetCommand(_console, LoggerMock.GetLogger <GetCommand>().Object, _projectService.Object, _jobDefinitionService.Object, _providerService.Object) { Project = "Project 1", Name = "Default" }; var resultMessage = command.Execute(); Assert.StartsWith("Job definition Default", resultMessage); }
public void JobGet_Execute_ReturnsNotFoundMessage() { var command = new GetCommand(_console, LoggerMock.GetLogger <GetCommand>().Object, _projectService.Object, _jobDefinitionService.Object, _providerService.Object) { Project = "Project 2", Name = "Default" }; var resultMessage = command.Execute(); Assert.Equal("Failed to get job definition Default. Make sure the project and job definition names are correct.", resultMessage); }
public void SendCommandsToQueue() { while (MyTcpClient.RunClient) { foreach (string key in FlightSimulatorResources.FullNameToShort.Keys) { Command c = new GetCommand(key); this._queue.Enqueue(c); } Thread.Sleep(1000); } }
public void QueueGet_Execute_ReturnsSuccessMessage() { var command = new GetCommand(_projectService.Object, _jobQueueService.Object, _console, LoggerMock.GetLogger <GetCommand>().Object) { Project = "Project 1", Number = "1" }; var resultMessage = command.Execute(); Assert.StartsWith("Job Queue 1", resultMessage); }
public void ServiceGet_Execute_ReturnsNotFoundMessage() { var console = new TestConsole(_output, "userPassword"); var command = new GetCommand(console, LoggerMock.GetLogger <GetCommand>().Object, _externalServiceService.Object, _externalServiceTypeService.Object) { Name = "Default-VSTS" }; var resultMessage = command.Execute(); Assert.Equal("External Service Default-VSTS was not found", resultMessage); }
public void ConfigGet_Execute_ReturnsEmpty() { var console = new TestConsole(_output); var command = new GetCommand(_engineConfig.Object, console, (new Mock <ILogger <GetCommand> >()).Object) { ConfigName = "config2" }; var message = command.Execute(); Assert.StartsWith("", message); }
public bool TryGetColumn(byte[] key, byte[] columnName, out RawColumn result) { result = null; var getCommand = new GetCommand(keyspaceName, columnFamilyName, key, readConsistencyLevel, columnName); commandExecutor.Execute(getCommand); if (getCommand.Output == null) { return(false); } result = getCommand.Output; return(true); }
public void CreateGetCommandWith_Depth_3() { Storm s = StormDefine(); GetCommand cmd = new GetCommand(s.schema.GetNavigator(), "Appointment"); cmd.With("Contact").With("AssignedUser").With("Contact.OwnerUser"); Assert.Equal("Appointment", cmd.from.root.Entity.ID); Assert.Equal(2, cmd.from.root.children.Count); Assert.Single(cmd.from.root.children.First().children); Assert.Equal("Appointment.Contact.OwnerUser", cmd.from.root.children.First().children.First().FullPath.Path); }
public void CreateGetCommand() { Storm s = StormDefine(); GetCommand cmd = new GetCommand(s.schema.GetNavigator(), "Appointment"); cmd.With("Contact").With("AssignedUser"); Assert.Equal("Appointment", cmd.from.root.Entity.ID); Assert.Equal(2, cmd.from.root.children.Count); Assert.Equal("Contact", cmd.from.root.children[0].Entity.ID); Assert.Equal("User", cmd.from.root.children[1].Entity.ID); }
private void Run(string[] args) { subcommands = new Dictionary <string, Action <List <string> > > () { { "assemble", Assemble }, { "export-html", ExportHtml }, { "export-msxdoc", ExportMSXDoc }, { "help", Help }, { "update", Update }, { "validate", Validate }, }; bool showVersion = false; bool showHelp = false; var p = new OptionSet() { { "version", v => showVersion = v != null }, { "debug", v => debug = v != null }, { "h|?|help", v => showHelp = v != null }, }; List <string> extra = p.Parse(args); if (showVersion) { Console.WriteLine("mdoc 0.1.0"); return; } if (extra.Count == 0) { Help(null); return; } if (showHelp) { extra.Add("--help"); } GetCommand(extra [0]) (extra); }
static void Main(string[] args) { var settings = new JsonSerializerSettings { //TypeNameHandling = TypeNameHandling.Objects, NullValueHandling = NullValueHandling.Ignore, }; var command = new GetCommand("1"); var s = JsonConvert.SerializeObject(command, Formatting.Indented, settings); Console.WriteLine(s); var deserializeObject = JsonConvert.DeserializeObject <Command>(s, settings); }
public void TaskGet_Execute_ReturnsNotFoundMessage() { var command = new GetCommand(_console, LoggerMock.GetLogger <GetCommand>().Object, _projectService.Object, _jobDefinitionService.Object, _providerService.Object) { Project = "Project 1", Job = "Default 2", Name = "Push" }; var resultMessage = command.Execute(); Assert.Equal("Failed to fetch task Push. Make sure the project, job definition, and task names are correct.", resultMessage); }
public void Execute_PassWordAndVocabularyReturnsMeans_ReturnMeansLineByLine() { // Arrange var word = "aaa"; var means = new [] { "bbb", "ccc" }; var command = new GetCommand(VocabularyStubFactory.Get(word, means)); // Act var result = command.Execute(new[] { word }); // Assert Assert.AreEqual(result, $"{means[0]}\r\n{means[1]}\r\n"); }
public async Task <int> Execute(string[] args) { var rootCommand = new RootCommand("Party: A Virt-A-Mate package manager") { HelpCommand.CreateCommand(_renderer, _config, _controllerFactory), SearchCommand.CreateCommand(_renderer, _config, _controllerFactory), GetCommand.CreateCommand(_renderer, _config, _controllerFactory), ShowCommand.CreateCommand(_renderer, _config, _controllerFactory), StatusCommand.CreateCommand(_renderer, _config, _controllerFactory), UpgradeCommand.CreateCommand(_renderer, _config, _controllerFactory), PublishCommand.CreateCommand(_renderer, _config, _controllerFactory), CleanCommand.CreateCommand(_renderer, _config, _controllerFactory), }; // For CoreRT: rootCommand.Name = Path.GetFileName(Environment.GetCommandLineArgs().FirstOrDefault()) ?? "party.exe"; Exception exc = null; var parser = new CommandLineBuilder(rootCommand) .UseVersionOption() .UseHelp() #if DEBUG .UseParseDirective() .UseDebugDirective() #endif .UseSuggestDirective() // .RegisterWithDotnetSuggest() .UseTypoCorrections() .UseParseErrorReporting() .UseExceptionHandler((e, ctx) => exc = e) .CancelOnProcessTermination() .Build(); _renderer.WriteLine("Party, a Virt-A-Mate package manager, is still in it's early stages. Please file any issue or ideas at https://github.com/vam-community/vam-party/issues", ConsoleColor.Green); try { await parser.InvokeAsync(args, _renderer); } catch (Exception e) { exc = e; } if (exc != null) { return(HandleError(exc)); } return(0); }
public async Task <StreamInfoReply> GetStreamInfo() { await Task.Yield(); var command = new GetCommand(Tuner, CommandNames.StreamInfo); var result = await Send(command); if (result is StreamInfoReply streamInfoResult) { return(streamInfoResult); } throw new InvalidReplyException($"Expected StreamInfoReply, got {result.GetType().Name}."); }
public void TaskGet_Execute_ReturnsSuccessMessage() { _providerService.Setup(x => x.GetProviderAdditionalConfigByProviderName(It.IsAny <string>())).ReturnsAsync(new List <ProviderAdditionalConfigDto>()); var command = new GetCommand(_console, LoggerMock.GetLogger <GetCommand>().Object, _projectService.Object, _jobDefinitionService.Object, _providerService.Object) { Project = "Project 1", Job = "Default", Name = "Generate" }; var resultMessage = command.Execute(); Assert.StartsWith("Task Generate in job Default:", resultMessage); }
public void ProviderGet_Execute_ReturnsNotFoundMessage() { _providerService.Setup(s => s.GetProviderByName(It.IsAny <string>())) .ReturnsAsync((TaskProviderDto)null); var command = new GetCommand(_providerService.Object, _console, LoggerMock.GetLogger <GetCommand>().Object) { ProviderName = "AProvider01" }; var message = command.Execute(); Assert.Equal("Task provider AProvider01 was not found.", message); }
public void GetUserProfileTest() { var command = new GetCommand(GetFakeApiController(), GetFakeUserRepository()); Task<Profile> result = command.Execute(); result.Wait(); Assert.IsFalse(result.IsFaulted); Assert.IsNotNull(result.Result); Assert.IsInstanceOfType(result.Result, typeof (Profile)); }