Ejemplo n.º 1
0
        public void TestReadAndDeleteFileWithError()
        {
            string fileName = "my_file.txt";
            var    error    = new Dictionary <string, object>();

            error["code"]    = "the code";
            error["message"] = "the message";

            var expectedResult = new Dictionary <string, object>();

            expectedResult["error"] = error;
            string fileContents = @"{""error"": {""code"": ""the code"", ""message"": ""the message""} }";

            CreateFile(fileName, fileContents);

            var downloadLocation = new Uri(fileName, UriKind.RelativeOrAbsolute);
            var observer         = new MockBackgroundUploadResponseHandlerObserver(expectedResult, fileContents);

            var responseHandler =
                new BackgroundUploadResponseHandler(downloadLocation, observer);

            Action result = responseHandler.OnDoWork();

            result.Invoke();

            observer.CheckOnErrorCalledCorrectly();

            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
            {
                Assert.IsFalse(store.FileExists(fileName), "The created file was not deleted");
            }
        }
Ejemplo n.º 2
0
        public void TestOnErrorCalledWithException()
        {
            string    fileName  = "my_file.txt";
            Exception exception = new Exception();

            var downloadLocation = new Uri(fileName, UriKind.RelativeOrAbsolute);
            var observer         = new MockBackgroundUploadResponseHandlerObserver(exception);

            var responseHandler = new BackgroundUploadResponseHandler(downloadLocation, observer);

            responseHandler.OnError(exception);

            observer.CheckOnErrorCalledCorrectly();
        }