Beispiel #1
0
        public async Task UpdateMetadata_ValidResponse_ValidMetadata()
        {
            /*** Arrange ***/
            var responseString = "{\"$id\":\"c79896a0-a33f-11e3-a5e2-0800200c9a66\",\"$type\": \"properties\",\"$parent\": \"file_552345101\",\"client_number\": \"820183\",\"client_name\": \"Biomedical Corp\",\"case_reference\": \"A83JAA\",\"case_type\": \"Employment Litigation\",\"assigned_attorney\": \"Eugene Huang\",\"retention_length\": \"7_years\"}";

            _handler.Setup(h => h.ExecuteAsync <BoxMetadata>(It.IsAny <IBoxRequest>()))
            .Returns(Task.FromResult <IBoxResponse <BoxMetadata> >(new BoxResponse <BoxMetadata>()
            {
                Status        = ResponseStatus.Success,
                ContentString = responseString
            }));

            var mdReq = new BoxMetadataRequest[]
            {
                new BoxMetadataRequest()
                {
                    Op = BoxMetadataOperations.Test, Path = "/assigned_attorney", Value = "Francis Burke"
                },
                new BoxMetadataRequest()
                {
                    Op = BoxMetadataOperations.Replace, Path = "/assigned_attorney", Value = "Eugene Huang"
                },
                new BoxMetadataRequest()
                {
                    Op = BoxMetadataOperations.Test, Path = "/case_status", Value = "in-progress"
                },
                new BoxMetadataRequest()
                {
                    Op = BoxMetadataOperations.Remove, Path = "/case_status", Value = "Francis Burke"
                },
                new BoxMetadataRequest()
                {
                    Op = BoxMetadataOperations.Add, Path = "/retention_length", Value = "7_years"
                }
            };

            /*** Act ***/
            BoxMetadata md = await _metadataManager.UpdateMetadata("fakeId", mdReq);

            /*** Assert ***/

            Assert.AreEqual("c79896a0-a33f-11e3-a5e2-0800200c9a66", md.Id);
            Assert.AreEqual("properties", md.Type);
            Assert.AreEqual("file_552345101", md.Parent);
            Assert.AreEqual("820183", md["client_number"]);
            Assert.AreEqual("Biomedical Corp", md["client_name"]);
            Assert.AreEqual("A83JAA", md["case_reference"]);
            Assert.AreEqual("Employment Litigation", md["case_type"]);
            Assert.AreEqual("Eugene Huang", md["assigned_attorney"]);
            Assert.AreEqual("7_years", md["retention_length"]);
        }
        public async Task UpdateMetadata_LiveSession_ValidResponse()
        {
            /*** Arrange ***/
            var mdReq = new BoxMetadataRequest[]
            {
                new BoxMetadataRequest()
                {
                    Op = BoxMetadataOperations.Test, Path = "assigned_attorney", Value = "Francis Burke"
                },
                new BoxMetadataRequest()
                {
                    Op = BoxMetadataOperations.Replace, Path = "assigned_attorney", Value = "Eugene Huang"
                },
                new BoxMetadataRequest()
                {
                    Op = BoxMetadataOperations.Test, Path = "case_status", Value = "in-progress"
                },
                new BoxMetadataRequest()
                {
                    Op = BoxMetadataOperations.Remove, Path = "case_status", Value = "Francis Burke"
                },
                new BoxMetadataRequest()
                {
                    Op = BoxMetadataOperations.Add, Path = "retention_length", Value = "7_years"
                }
            };

            /*** Act ***/
            BoxMetadata md = await _client.ResourcePlugins.Get <BoxMetadataManager>().UpdateMetadata(TestFileId, mdReq);

            /*** Assert ***/

            Assert.IsNotNull(md.Id);
            Assert.AreEqual("properties", md.Type);
            Assert.AreEqual(string.Format("file_{0}", TestFileId), md.Parent);
            Assert.AreEqual("820183", md["client_number"]);
            Assert.AreEqual("Biomedical Corp", md["client_name"]);
            Assert.AreEqual("A83JAA", md["case_reference"]);
            Assert.AreEqual("Employment Litigation", md["case_type"]);
            Assert.AreEqual("Eugene Huang", md["assigned_attorney"]);
            Assert.AreEqual("7_years", md["retention_length"]);
        }