Example #1
0
        public void RefreshFilesystemInfo_Adds_DriveInfo_Sdcard_Paths()
        {
            // arrange
            SetupFileSystemStorageCardPaths();
            ViewModel.Initialise();

            // act
            ViewModel.RefreshFileSystemInfo();

            // assert
            // there are no errors
            A.CallTo(() => MockCrashReporter.LogNonFatalException(A <Exception> .Ignored)).MustNotHaveHappened();

            // file 1
            A.CallToSet(() => MockDriveVolumeInfoView.Title).To(() => "/storage/SDCARD1").MustHaveHappened(1, Times.Exactly);

            // file 2
            A.CallToSet(() => MockDriveVolumeInfoView.Title).To(() => "/storage/SDCARD2/anotherplace/").MustHaveHappened(1, Times.Exactly);

            // file 3
            A.CallToSet(() => MockDriveVolumeInfoView.Title).To(() => "/storage/SDCARD3").MustHaveHappened(1, Times.Exactly);

            // file 4
            A.CallToSet(() => MockDriveVolumeInfoView.Title).To(() => "/Android/data/").MustHaveHappened(1, Times.Exactly);

            // file 5
            A.CallToSet(() => MockDriveVolumeInfoView.Title).To(() => "/storage/emulated/0").MustHaveHappened(1, Times.Exactly);

            // all
            A.CallTo(() => MockDriveVolumeInfoView.GetView()).MustHaveHappened(5, Times.Exactly);
        }
Example #2
0
        public void RefreshFilesystemInfo_Adds_DriveInfo_Before_An_Error()
        {
            // arrange
            SetupFileSystem();
            ViewModel.Initialise();
            // throw processing the second item
            var testException = new Exception();

            A.CallTo(() => MockFileSystemHelper.GetAvailableFileSystemSizeInBytes(PATH2)).Throws(testException);

            // act
            ViewModel.RefreshFileSystemInfo();

            // assert
            // writes the error to the logs
            A.CallTo(() => MockLogger.LogException(A <ILogger.MessageGenerator> .Ignored, testException)).MustHaveHappened(1, Times.Exactly);
            // writes the error to crshlytics
            A.CallTo(() => MockCrashReporter.LogNonFatalException(A <Exception> .Ignored)).MustHaveHappened(1, Times.Exactly);

            // file 1
            A.CallToSet(() => MockDriveVolumeInfoView.Title).To(() => PATH1).MustHaveHappened(1, Times.Exactly);
            A.CallTo(() => MockDriveVolumeInfoView.SetSpace(100, 200, "100", "MB", "200", "MB")).MustHaveHappened(1, Times.Exactly);
            A.CallTo(() => MockDriveVolumeInfoView.GetView()).MustHaveHappened(1, Times.Exactly);
        }
Example #3
0
        public void RefreshFilesystemInfo_Adds_DriveInfo()
        {
            // arrange
            SetupFileSystem();
            ViewModel.Initialise();

            // act
            ViewModel.RefreshFileSystemInfo();

            // assert
            // there are no errors
            A.CallTo(() => MockCrashReporter.LogNonFatalException(A <Exception> .Ignored)).MustNotHaveHappened();

            // file 1
            A.CallToSet(() => MockDriveVolumeInfoView.Title).To(() => PATH1).MustHaveHappened(1, Times.Exactly);
            A.CallTo(() => MockDriveVolumeInfoView.SetSpace(100, 200, "100", "MB", "200", "MB")).MustHaveHappened(1, Times.Exactly);

            // file 2
            A.CallToSet(() => MockDriveVolumeInfoView.Title).To(() => PATH2).MustHaveHappened(1, Times.Exactly);
            A.CallTo(() => MockDriveVolumeInfoView.SetSpace(2000, 4000, "1.95", "GB", "3.91", "GB")).MustHaveHappened(1, Times.Exactly);

            // both
            A.CallTo(() => MockDriveVolumeInfoView.GetView()).MustHaveHappened(2, Times.Exactly);
        }