コード例 #1
0
    public Task TestFileControllerSaveWithEmptyResult() {
      var response = new Tuple<HttpStatusCode, IDictionary<string, object>>(HttpStatusCode.Accepted, new Dictionary<string, object>());
      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);
      });
    }
コード例 #2
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);
              });
        }