示例#1
0
        public void JsonDeserialization_ThrowsForInvalidVersions(string json)
        {
            var exception = Assert.Throws <ArgumentException>(
                () => JsonSerializationUtilities.Deserialize <GetPackageVersionsResponse>(json));

            Assert.Equal("versions", exception.ParamName);
        }
        public void JsonDeserialization_ThrowsForInvalidPackageSourceRepository(string json, string parameterName)
        {
            var exception = Assert.Throws <ArgumentException>(
                () => JsonSerializationUtilities.Deserialize <GetPackageVersionsRequest>(json));

            Assert.Equal(parameterName, exception.ParamName);
        }
示例#3
0
        public void JsonDeserialization_ReturnsCorrectObject(string json, string message)
        {
            var request = JsonSerializationUtilities.Deserialize <LogRequest>(json);

            Assert.Equal(LogLevel.Warning, request.LogLevel);
            Assert.Equal(message, request.Message);
        }
示例#4
0
        public void JsonDeserialization_ThrowsForInvalidClaimsValue()
        {
            var json = "{\"Claims\":[\"abc\"]}";

            Assert.Throws <JsonSerializationException>(
                () => JsonSerializationUtilities.Deserialize <GetOperationClaimsResponse>(json));
        }
        public void JsonDeserialization_ThrowsForNullOrEmptyStringProperties(string json, string parameterName)
        {
            var exception = Assert.Throws <ArgumentException>(
                () => JsonSerializationUtilities.Deserialize <InitializeRequest>(json));

            Assert.Equal(parameterName, exception.ParamName);
        }
示例#6
0
        public void JsonDeserialization_ThrowsForInvalidVersion(string json)
        {
            var exception = Assert.Throws <ArgumentException>(
                () => JsonSerializationUtilities.Deserialize <HandshakeRequest>(json));

            Assert.Equal("value", exception.ParamName);
        }
        public void JsonDeserialization_ReturnsCorrectObject()
        {
            var json    = $"{{\"ProcessId\":{_processId}}}";
            var request = JsonSerializationUtilities.Deserialize <MonitorNuGetProcessExitRequest>(json);

            Assert.Equal(_processId, request.ProcessId);
        }
示例#8
0
        public void JsonDeserialization_ThrowsForNullVersion(string json, string parameterName)
        {
            var exception = Assert.Throws <ArgumentNullException>(
                () => JsonSerializationUtilities.Deserialize <HandshakeRequest>(json));

            Assert.Equal(parameterName, exception.ParamName);
        }
示例#9
0
        public void Deserialize_ThrowsForEmptyJson()
        {
            var exception = Assert.Throws <ArgumentException>(
                () => JsonSerializationUtilities.Deserialize <A>(json: ""));

            Assert.Equal("json", exception.ParamName);
        }
示例#10
0
        public void JsonDeserialization_ReturnsCorrectObject()
        {
            var json    = "{\"PackageSourceRepository\":\"a\"}";
            var request = JsonSerializationUtilities.Deserialize <GetServiceIndexRequest>(json);

            Assert.Equal("a", request.PackageSourceRepository);
        }
示例#11
0
        public void JsonDeserialization_ThrowsForInvalidProtocolVersion(string json, string parameterName)
        {
            var exception = Assert.Throws <ArgumentException>(
                () => JsonSerializationUtilities.Deserialize <HandshakeResponse>(json));

            Assert.Equal(parameterName, exception.ParamName);
        }
        public void JsonDeserialization_ReturnsCorrectObject(string json, string serviceIndex)
        {
            var request = JsonSerializationUtilities.Deserialize <GetOperationClaimsRequest>(json);

            Assert.Equal("A", request.PackageSourceRepository);
            Assert.Equal(serviceIndex, request.ServiceIndex.ToString(Formatting.None));
        }
示例#13
0
        internal Task StartListeningAsync(CancellationToken cancellationToken)
        {
            var localEndPoint = new IPEndPoint(IPAddress.Loopback, _portNumber);

            using (var listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
            {
                listener.Bind(localEndPoint);
                listener.Listen(10);

                var socket = listener.Accept();

                using (var stream = new NetworkStream(socket, ownsSocket: true))
                    using (var streamReader = new StreamReader(stream))
                    {
                        string text;

                        while ((text = streamReader.ReadLine()) != null)
                        {
                            cancellationToken.ThrowIfCancellationRequested();

                            var response = JsonSerializationUtilities.Deserialize <Response>(text);

                            _responses.Add(response);
                        }
                    }
            }

            return(Task.FromResult(0));
        }
示例#14
0
        public void JsonDeserialization_ThrowsForInvalidClaims(string json)
        {
            var exception = Assert.Throws <ArgumentNullException>(
                () => JsonSerializationUtilities.Deserialize <GetOperationClaimsResponse>(json));

            Assert.Equal("claims", exception.ParamName);
        }
        public void JsonDeserialization_ThrowsForNullOrEmptyMessage(string json)
        {
            var exception = Assert.Throws <ArgumentException>(
                () => JsonSerializationUtilities.Deserialize <Fault>(json));

            Assert.Equal("message", exception.ParamName);
        }
        public void JsonDeserialization_ReturnsCorrectObject()
        {
            var json  = "{\"Message\":\"a\"}";
            var fault = JsonSerializationUtilities.Deserialize <Fault>(json);

            Assert.Equal("a", fault.Message);
        }
        public void JsonDeserialization_ThrowsForInvalidServiceIndex(string json)
        {
            var exception = Assert.Throws <ArgumentNullException>(
                () => JsonSerializationUtilities.Deserialize <GetOperationClaimsRequest>(json));

            Assert.Equal("serviceIndex", exception.ParamName);
        }
        public void JsonDeserialization_ThrowsForInvalidPackageSourceRepository(string json)
        {
            var exception = Assert.Throws <ArgumentException>(
                () => JsonSerializationUtilities.Deserialize <GetCredentialsRequest>(json));

            Assert.Equal("packageSourceRepository", exception.ParamName);
        }
        public void JsonDeserialization_ThrowsForInvalidStringArgument(string json, string parameterName)
        {
            var exception = Assert.Throws <ArgumentException>(
                () => JsonSerializationUtilities.Deserialize <PrefetchPackageRequest>(json));

            Assert.Equal(parameterName, exception.ParamName);
        }
        public void JsonDeserialization_ThrowsForInvalidCopiedFiles(string json)
        {
            var exception = Assert.Throws <ArgumentException>(
                () => JsonSerializationUtilities.Deserialize <GetFilesInPackageResponse>(json));

            Assert.Equal("files", exception.ParamName);
        }
        public void JsonDeserialization_ReturnsCorrectObject()
        {
            var json     = "{\"ResponseCode\":\"Success\"}";
            var response = JsonSerializationUtilities.Deserialize <CopyNupkgFileResponse>(json);

            Assert.Equal(MessageResponseCode.Success, response.ResponseCode);
        }
        public void JsonDeserialization_ThrowsForInvalidRequestTimeoutValue(string json)
        {
            var exception = Assert.Throws <ArgumentOutOfRangeException>(
                () => JsonSerializationUtilities.Deserialize <InitializeRequest>(json));

            Assert.Equal("requestTimeout", exception.ParamName);
        }
        public void JsonDeserialization_ReturnsCorrectObjectForSuccess()
        {
            var json     = "{\"Files\":[\"a\"],\"ResponseCode\":\"Success\"}";
            var response = JsonSerializationUtilities.Deserialize <GetFilesInPackageResponse>(json);

            Assert.Equal(MessageResponseCode.Success, response.ResponseCode);
            Assert.Equal(new[] { "a" }, response.Files);
        }
        public void JsonDeserialization_ReturnsCorrectObject()
        {
            var json    = "{\"PackageSourceRepository\":\"a\",\"StatusCode\":\"Unauthorized\"}";
            var request = JsonSerializationUtilities.Deserialize <GetCredentialsRequest>(json);

            Assert.Equal("a", request.PackageSourceRepository);
            Assert.Equal(HttpStatusCode.Unauthorized, request.StatusCode);
        }
        public void JsonDeserialization_ReturnsCorrectObjectForNotFound()
        {
            var json     = "{\"ResponseCode\":\"NotFound\"}";
            var response = JsonSerializationUtilities.Deserialize <GetFilesInPackageResponse>(json);

            Assert.Equal(MessageResponseCode.NotFound, response.ResponseCode);
            Assert.Null(response.Files);
        }
        public void JsonDeserialization_ReturnsCorrectObjectForSuccess()
        {
            var json     = "{\"ResponseCode\":\"Success\",\"ServiceIndex\":{\"a\":\"b\"}}";
            var response = JsonSerializationUtilities.Deserialize <GetServiceIndexResponse>(json);

            Assert.Equal(MessageResponseCode.Success, response.ResponseCode);
            Assert.Equal("{\"a\":\"b\"}", response.ServiceIndex.ToString(Formatting.None));
        }
        public void JsonDeserialization_ThrowsForMissingStatusCode()
        {
            var json      = "{\"PackageSourceRepository\":\"a\"}";
            var exception = Assert.Throws <ArgumentException>(
                () => JsonSerializationUtilities.Deserialize <GetCredentialsRequest>(json));

            Assert.Equal("statusCode", exception.ParamName);
        }
        public void JsonDeserialization_ReturnsCorrectObject()
        {
            var json = "{\"LogLevel\":\"Error\"}";

            var request = JsonSerializationUtilities.Deserialize <SetLogLevelRequest>(json);

            Assert.NotNull(request);
            Assert.Equal(LogLevel.Error, request.LogLevel);
        }
示例#29
0
        public void JsonDeserialization_ReturnsCorrectObject()
        {
            var json = "{\"ProtocolVersion\":\"2.0.0\",\"MinimumProtocolVersion\":\"1.0.0\"}";

            var request = JsonSerializationUtilities.Deserialize <HandshakeRequest>(json);

            Assert.Equal(_version2_0_0, request.ProtocolVersion);
            Assert.Equal(_version1_0_0, request.MinimumProtocolVersion);
        }
        public void JsonDeserialization_ReturnsCorrectObject()
        {
            var json    = "{\"PackageId\":\"a\",\"PackageSourceRepository\":\"b\",\"PackageVersion\":\"c\"}";
            var request = JsonSerializationUtilities.Deserialize <PrefetchPackageRequest>(json);

            Assert.Equal("a", request.PackageId);
            Assert.Equal("b", request.PackageSourceRepository);
            Assert.Equal("c", request.PackageVersion);
        }