public void OnClickConfirmLogCommandTests_Success() { var testLogId = "test-log-id"; mockLogFileService.Setup(x => x.CreateLogId()).Returns(testLogId); var testZipFileName = "test-zip-file-name"; mockLogFileService.Setup(x => x.CreateZipFileName(testLogId)).Returns(testZipFileName); var testPublicZipFileName = "test-public-zip-file-name"; mockLogFileService.Setup(x => x.CreateZipFile(testZipFileName)).Returns(testPublicZipFileName); var testPublicZipFilePath = "test-public-zip-file-path"; mockLogFileService.Setup(x => x.CopyLogUploadingFileToPublicPath(testZipFileName)).Returns(testPublicZipFilePath); var unitUnderTest = CreateViewModel(); unitUnderTest.Initialize(SendLogConfirmationPage.BuildNavigationParams(testLogId, testPublicZipFilePath)); mockUserDialogs.Invocations.Clear(); mockLogFileService.Invocations.Clear(); Xamarin.Forms.Mocks.MockForms.Init(Device.Android); unitUnderTest.OnClickConfirmLogCommand.Execute(null); }
public void OnClickSendLogCommandTests_DeleteLogFalure() { var testLogId = "test-log-id"; mockLogFileService.Setup(x => x.CreateLogId()).Returns(testLogId); var testZipFileName = "test-zip-file-name"; mockLogFileService.Setup(x => x.CreateZipFileName(testLogId)).Returns(testZipFileName); var testPublicZipFileName = "test-public-zip-file-name"; mockLogFileService.Setup(x => x.CreateZipFile(testZipFileName)).Returns(testPublicZipFileName); var testPublicZipFilePath = "test-public-zip-file-path"; mockLogFileService.Setup(x => x.CopyLogUploadingFileToPublicPath(testZipFileName)).Returns(testPublicZipFilePath); mockLogFileService.Setup(x => x.DeleteAllLogUploadingFiles()).Returns(false); var unitUnderTest = CreateViewModel(); unitUnderTest.Initialize( SendLogConfirmationPage.BuildNavigationParams(testLogId, testPublicZipFilePath) ); mockUserDialogs.Invocations.Clear(); mockLogFileService.Invocations.Clear(); var testResponse = new ApiResponse <LogStorageSas>(200, new LogStorageSas() { SasToken = "test-sas-token" }); mockHttpDataService.Setup(x => x.GetLogStorageSas()).ReturnsAsync(testResponse); mockLogUploadService.Setup(x => x.UploadAsync(testPublicZipFilePath, testResponse.Result.SasToken)).ReturnsAsync(true); unitUnderTest.OnClickSendLogCommand.Execute(null); mockUserDialogs.Verify(x => x.ShowLoading(It.IsAny <string>(), null), Times.Once()); mockUserDialogs.Verify(x => x.HideLoading(), Times.Once()); mockUserDialogs.Verify(x => x.AlertAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), null), Times.Never()); mockLogUploadService.Verify(x => x.UploadAsync(testPublicZipFilePath, testResponse.Result.SasToken), Times.Once()); mockLogFileService.Verify(x => x.DeleteAllLogUploadingFiles(), Times.Once()); var expectedParameters = new NavigationParameters { { "logId", testLogId } }; mockNavigationService.Verify(x => x.NavigateAsync("SendLogCompletePage?useModalNavigation=true/", expectedParameters), Times.Once()); }