Exemplo n.º 1
0
        public void GetContextResourceNames()
        {
            moq::Mock <Contexts.ContextsClient> mockGrpcClient = new moq::Mock <Contexts.ContextsClient>(moq::MockBehavior.Strict);
            GetContextRequest request = new GetContextRequest
            {
                ContextName = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]"),
            };
            Context expectedResponse = new Context
            {
                ContextName   = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]"),
                LifespanCount = -2034952532,
                Parameters    = new wkt::Struct(),
            };

            mockGrpcClient.Setup(x => x.GetContext(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            ContextsClient client   = new ContextsClientImpl(mockGrpcClient.Object, null);
            Context        response = client.GetContext(request.ContextName);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 2
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (ContextName.Length != 0)
            {
                hash ^= ContextName.GetHashCode();
            }
            if (ParallelIterations != 0)
            {
                hash ^= ParallelIterations.GetHashCode();
            }
            if (BackProp != false)
            {
                hash ^= BackProp.GetHashCode();
            }
            if (SwapMemory != false)
            {
                hash ^= SwapMemory.GetHashCode();
            }
            if (PivotName.Length != 0)
            {
                hash ^= PivotName.GetHashCode();
            }
            if (PivotForPredName.Length != 0)
            {
                hash ^= PivotForPredName.GetHashCode();
            }
            if (PivotForBodyName.Length != 0)
            {
                hash ^= PivotForBodyName.GetHashCode();
            }
            hash ^= loopExitNames_.GetHashCode();
            hash ^= loopEnterNames_.GetHashCode();
            if (valuesDef_ != null)
            {
                hash ^= ValuesDef.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 3
0
        public async Task GetContextAsync()
        {
            Mock <Contexts.ContextsClient> mockGrpcClient = new Mock <Contexts.ContextsClient>(MockBehavior.Strict);
            GetContextRequest expectedRequest             = new GetContextRequest
            {
                ContextName = new ContextName("[PROJECT]", "[SESSION]", "[CONTEXT]"),
            };
            Context expectedResponse = new Context
            {
                ContextName   = new ContextName("[PROJECT]", "[SESSION]", "[CONTEXT]"),
                LifespanCount = 1178775510,
            };

            mockGrpcClient.Setup(x => x.GetContextAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <Context>(Task.FromResult(expectedResponse), null, null, null, null));
            ContextsClient client   = new ContextsClientImpl(mockGrpcClient.Object, null);
            ContextName    name     = new ContextName("[PROJECT]", "[SESSION]", "[CONTEXT]");
            Context        response = await client.GetContextAsync(name);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 4
0
        public void GetContext()
        {
            Mock <Contexts.ContextsClient> mockGrpcClient = new Mock <Contexts.ContextsClient>(MockBehavior.Strict);
            GetContextRequest expectedRequest             = new GetContextRequest
            {
                ContextName = new ContextName("[PROJECT]", "[SESSION]", "[CONTEXT]"),
            };
            Context expectedResponse = new Context
            {
                ContextName   = new ContextName("[PROJECT]", "[SESSION]", "[CONTEXT]"),
                LifespanCount = 1178775510,
            };

            mockGrpcClient.Setup(x => x.GetContext(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            ContextsClient client   = new ContextsClientImpl(mockGrpcClient.Object, null);
            ContextName    name     = new ContextName("[PROJECT]", "[SESSION]", "[CONTEXT]");
            Context        response = client.GetContext(name);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 5
0
        public async stt::Task GetContextRequestObjectAsync()
        {
            moq::Mock <Contexts.ContextsClient> mockGrpcClient = new moq::Mock <Contexts.ContextsClient>(moq::MockBehavior.Strict);
            GetContextRequest request = new GetContextRequest
            {
                ContextName = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]"),
            };
            Context expectedResponse = new Context
            {
                ContextName   = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]"),
                LifespanCount = -2034952532,
                Parameters    = new wkt::Struct(),
            };

            mockGrpcClient.Setup(x => x.GetContextAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Context>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            ContextsClient client = new ContextsClientImpl(mockGrpcClient.Object, null);
            Context        responseCallSettings = await client.GetContextAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Context responseCancellationToken = await client.GetContextAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 6
0
        private void FindUpdates(SynchronizationContext synchronizationContext)
        {
            try
            {
                var context           = new ContextName(_env.ContextName, _env.Experimental);
                var installedPackages = PackageRegistry.GetInstalledPackages(context);

                var packages = NuGetQuerier.GetUpdates(
                    context,
                    _env.NuGetSite,
                    PackageStability.StableOnly,
                    installedPackages.Packages
                    );

                synchronizationContext.Post(
                    p => CreateNotifications(packages),
                    null
                    );
            }
            catch (Exception ex)
            {
                Log.Warn("Could not find updates", ex);
            }
        }
        public string GenerateServiceClientImports()
        {
            TSBuilder builder = new TSBuilder();

            if (MethodTemplateModels.Any() || OptionalParameterTypeForClientConstructor == ServiceClientOptions)
            {
                builder.ImportAllAs("msRest", "ms-rest-js");
            }
            builder.ImportAllAs("Models", "./models");
            builder.ImportAllAs("Mappers", "./models/mappers");

            if (HasMappableParameters)
            {
                builder.ImportAllAs("Parameters", "./models/parameters");
            }

            if (MethodGroupModels.Any())
            {
                builder.ImportAllAs("operations", "./operations");
            }
            builder.Import(new string[] { ContextName }, $"./{ContextName.ToCamelCase()}");

            return(builder.ToString());
        }
Exemplo n.º 8
0
        public static int Main(string[] args)
        {
            Console.WriteLine("Net IDE Package Registration");

            string package      = null;
            string contextName  = null;
            bool   experimental = false;
            bool   uninstall    = false;

            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i].ToLowerInvariant())
                {
                case "/context":
                case "/c":
                    if (++i < args.Length)
                    {
                        contextName = args[i];
                    }
                    break;

                case "/uninstall":
                case "/u":
                    uninstall = true;
                    break;

                case "/experimental":
                    experimental = true;
                    break;

                default:
                    package = args[i];
                    break;
                }
            }

            if (package == null || contextName == null)
            {
                Console.Error.WriteLine("Usage: niinstall.exe /context|c <context> [/uninstall|u] [/experimental] <package>");
                return(1);
            }

            var context = new ContextName(contextName, experimental);

            if (!uninstall && !File.Exists(package))
            {
                Console.Error.WriteLine("Package not found");
                return(3);
            }

            try
            {
                if (uninstall)
                {
                    new PackageUninstaller(context, package).Execute();
                }
                else
                {
                    new PackageInstaller(context, package).Execute();
                }

                return(0);
            }
            catch (PackageInstallationException ex)
            {
                Console.WriteLine(ex.Message);

                return(ex.ExitCode + 10);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("Package could not be installed: " + ex.Message);

                if (ex.StackTrace != null)
                {
                    Console.Error.WriteLine(ex.StackTrace);
                }

                return(2);
            }
        }
Exemplo n.º 9
0
 public override int GetHashCode()
 {
     unchecked { return(((_values != null ? _values.GetHashCode() : 0) * 397) ^ (ContextName != null ? ContextName.GetHashCode() : 0)); }
 }