public void TestErrorDeserialization(
            [CombinatorialValues(Features.LegacyDataResponse, null)] Features?features)
        {
            const string ErrorResponse =
                @"{
                    ""error"": {
                        ""errors"": [
                            {
                                ""domain"": ""global"",
                                ""reason"": ""required"",
                                ""message"": ""Required"",
                                ""locationType"": ""parameter"",
                                ""location"": ""resource.longUrl""
                            }
                        ],
                        ""code"": 400,
                        ""message"": ""Required""
                    }
                }";

            var client = CreateClientService(features);

            using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(ErrorResponse)))
            {
                var response = new HttpResponseMessage {
                    Content = new StreamContent(stream)
                };
                RequestError error = client.DeserializeError(response).Result;
                Assert.Equal(400, error.Code);
                Assert.Equal("Required", error.Message);
                Assert.Equal(1, error.Errors.Count);
            }
        }
        /// <summary>Creates a client service for the given features.</summary>
        private IClientService CreateClientService(Features?features = null)
        {
            var client = new MockClientService();

            if (features.HasValue)
            {
                client.SetFeatures(new[] { Utilities.GetEnumStringValue(features.Value) });
            }

            return(client);
        }
        private CheckFileInfoWopiRequest(File file, string accessToken, Features?features)
            : base(accessToken, isWriteAccessRequired: false, demandsProof: true)
        {
            if (file.IsEmpty)
            {
                throw new ArgumentNullException(nameof(file));
            }

            _file = file;

            _features = features;
        }
Example #4
0
        private CheckFileInfoWopiRequestHandler(AuthenticatedUser authenticatedUser, File file, Features?features)
            : base(true)
        {
            if (authenticatedUser is null)
            {
                throw new ArgumentNullException(nameof(authenticatedUser));
            }
            if (file.IsEmpty)
            {
                throw new ArgumentNullException(nameof(file));
            }

            _file = file;

            _features = features;

            _authenticatedUser = authenticatedUser;
        }
        static void Main(string[] args)
        {
            RenderTitle();
            Features?chosenFeature = null;

            while (chosenFeature != Features.Exit)
            {
                RenderMenu();
                chosenFeature = GetUserMainMenuChoice();

                if (chosenFeature == null)
                {
                    RenderIncorrectChoiceText();
                }
                else if (chosenFeature == Features.Exit)
                {
                    //Do nothing. 'while' will exit.
                }
                else
                {
                    new FeatureExecutor().ExecuteFeature(chosenFeature.Value, _outputFileName);
                }
            }
        }
Example #6
0
 public Settings With(Features?features = null, Formats?format = null, IConverter[] converters = null) =>
 new Settings(features ?? Features, format ?? Format, converters ?? _converters.Values.ToArray());