Example #1
0
        public Task TestFileControllerSave()
        {
            var response = new Tuple <HttpStatusCode, IDictionary <string, object> >(HttpStatusCode.Accepted,
                                                                                     new Dictionary <string, object>()
            {
                { "name", "newBekti.png" },
                { "url", "https://www.parse.com/newBekti.png" }
            });
            var mockRunner = CreateMockRunner(response);
            var state      = new FileState {
                Name     = "bekti.png",
                MimeType = "image/png"
            };

            var controller = new ParseFileController(mockRunner.Object);

            return(controller.SaveAsync(state, dataStream: new MemoryStream(), sessionToken: null, progress: null).ContinueWith(t => {
                Assert.False(t.IsFaulted);
                var newState = t.Result;

                Assert.AreEqual(state.MimeType, newState.MimeType);
                Assert.AreEqual("newBekti.png", newState.Name);
                Assert.AreEqual("https://www.parse.com/newBekti.png", newState.Url.AbsoluteUri);
            }));
        }
Example #2
0
        public Task TestFileControllerSaveWithEmptyResult()
        {
            Tuple <HttpStatusCode, IDictionary <string, object> > response = new Tuple <HttpStatusCode, IDictionary <string, object> >(HttpStatusCode.Accepted, new Dictionary <string, object>());
            Mock <IParseCommandRunner> mockRunner = CreateMockRunner(response);
            FileState state = new FileState
            {
                Name     = "bekti.png",
                MimeType = "image/png"
            };

            ParseFileController controller = new ParseFileController(mockRunner.Object);

            return(controller.SaveAsync(state, dataStream: new MemoryStream(), sessionToken: null, progress: null).ContinueWith(t => Assert.IsTrue(t.IsFaulted)));
        }
Example #3
0
        public Task TestFileControllerSaveWithInvalidResult()
        {
            var response   = new Tuple <HttpStatusCode, IDictionary <string, object> >(HttpStatusCode.Accepted, null);
            var mockRunner = CreateMockRunner(response);
            var state      = new FileState {
                Name     = "bekti.png",
                MimeType = "image/png"
            };

            var controller = new ParseFileController(mockRunner.Object);

            return(controller.SaveAsync(state, dataStream: new MemoryStream(), sessionToken: null, progress: null).ContinueWith(t => {
                Assert.True(t.IsFaulted);
            }));
        }