Beispiel #1
0
        private IReadWriteControlFile SetupRealControlFile(Android.Net.Uri uri)
        {
            FileSystemHelper helper = new FileSystemHelper(MainActivity.MainContext, MockLogger);
            XmlDocument      xml    = helper.LoadXmlFromAssetFile("xml/testcontrolfile1.xml");

            A.CallTo(() => MockFileSystemHelper.LoadXmlFromContentUri(uri)).Returns(xml);
            IReadWriteControlFile control = new ReadWriteControlFile(xml);

            A.CallTo(() => MockApplicationControlFileFactory.CreateControlFile(xml)).Returns(control);
            return(control);
        }
Beispiel #2
0
        public void LoadControlFile_HandlesErrors()
        {
            // arrange
            Android.Net.Uri uri     = Android.Net.Uri.Parse("content://com.android.externalstorage.documents/document/primary%3APodcastUtilities%2FDerekPodcastsSmall2.xml");
            var             control = SetupRealControlFile(uri);

            ViewModel.Initialise();
            var testException = new Exception();

            A.CallTo(() => MockApplicationControlFileFactory.CreateControlFile(A <XmlDocument> .Ignored)).Throws(testException);

            // act
            ViewModel.LoadContolFile(uri);

            // assert
            A.CallTo(() => MockCrashReporter.LogNonFatalException(testException)).MustHaveHappened(1, Times.Exactly);
            Assert.AreEqual("Mocked control file error", ObservedResults.LastToastMessage);
        }