public override void TestInitialise()
        {
            base.TestInitialise();

            _callsToSaveChangesAsync = 0;

            _requestArgument = new StoreJsonDataRequest
            {
                CipherKey = string.Empty,
                Json      = "{ Contents: [ { Name: \"test\", Contents: [] } ] }"
            };
        }
        public async Task StoreJsonData_WhenRequestArgumentIsNull_ExpectArgumentNullException()
        {
            // Arrange:
            _requestArgument = null;
            Stub();

            try
            {
                // Act:
                await Act();
            }
            catch (ArgumentNullException exception)
            {
                // Assert:
                Assert.AreEqual("request", exception.ParamName);
                AssertCore();
                throw;
            }
        }
예제 #3
0
        /// <summary>
        /// Stores the JSON data.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>A response of the operation.</returns>
        async Task <int> IUploadService.StoreJsonData(StoreJsonDataRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            var nodes = NodeHelpers.ParseJson(request.Json, request.CipherKey);

            var files = nodes
                        .Where(node => node.IsFile)
                        .Select(node => new ArchiveContent
            {
                IsFile = node.IsFile,
                Name   = node.DecryptedName
            });

            await _context.ArchiveItems.AddRangeAsync(files);

            return(await _context.SaveChangesAsync());
        }