public void RefreshTest() { const string reportsPath = "reportsPath"; const string uploadServiceUrl = "uploadServiceUrl"; var fileList = new List<string> { "File1.trdx", "File2.trdx", "File3.trdx" }; var retriever = new ProcessReportListRetrieverMock(fileList, reportsPath, uploadServiceUrl); var reportListRetriever = Mock.Create<IProcessReportListRetrieverWrapper>(); Mock.Arrange(() => reportListRetriever.GetProcessReportList(Arg.IsAny<EventHandler<DataPortalResult<ProcessReportListRetriever>>>())) .DoInstead<EventHandler<DataPortalResult<ProcessReportListRetriever>>>(callback => callback(null, new DataPortalResult<ProcessReportListRetriever>(retriever, null, null))); var vm = new SelectReportFileViewModel(); var propertiesChanged = new List<string>(); vm.PropertyChanged += (o, e) => propertiesChanged.Add(e.PropertyName); vm.ProcessReportListRetriever = new Lazy<IProcessReportListRetrieverWrapper>(() => reportListRetriever); vm.Refresh(); Mock.Assert(() => reportListRetriever.GetProcessReportList(Arg.IsAny<EventHandler<DataPortalResult<ProcessReportListRetriever>>>()), Occurs.Once()); Assert.AreEqual(reportsPath, vm.TargetPhysicalFolder); Assert.AreEqual(uploadServiceUrl, vm.UploadServiceUrl); Assert.IsTrue(fileList.SequenceEqual(vm.FileList)); Assert.IsTrue(propertiesChanged.Contains("SelectedFile")); }
public void OnUploadFinished_FileListIsRefreshed() { const string reportsPath = "reportsPath"; const string uploadServiceUrl = "uploadServiceUrl"; var fileList = new List<string> { "File1.trdx", "File2.trdx", "File3.trdx" }; var retriever = new ProcessReportListRetrieverMock(); var reportListRetriever = Mock.Create<IProcessReportListRetrieverWrapper>(); Mock.Arrange(() => reportListRetriever.GetProcessReportList(Arg.IsAny<EventHandler<DataPortalResult<ProcessReportListRetriever>>>())) .DoInstead<EventHandler<DataPortalResult<ProcessReportListRetriever>>>(callback => callback(null, new DataPortalResult<ProcessReportListRetriever>(retriever, null, null))); var vm = new SelectReportFileViewModel { ProcessReportListRetriever = new Lazy<IProcessReportListRetrieverWrapper>(() => reportListRetriever) }; vm.Refresh(); retriever = new ProcessReportListRetrieverMock(fileList, reportsPath, uploadServiceUrl); vm.OnUploadFinished(null, null); Mock.Assert(() => reportListRetriever.GetProcessReportList(Arg.IsAny<EventHandler<DataPortalResult<ProcessReportListRetriever>>>()), Occurs.Exactly(2)); Assert.AreEqual(reportsPath, vm.TargetPhysicalFolder); Assert.AreEqual(uploadServiceUrl, vm.UploadServiceUrl); Assert.IsTrue(fileList.SequenceEqual(vm.FileList)); }