public void ImportAsync_WhenImportIsCancelled_LogCreated() { // Arrange SetupShims(true); CreateTestObject(DummyString, true); // Act _testObj.ImportAsync(); // Assert var dSMResult = (ResourceImportResult)_privateObj.GetFieldOrProperty(DSMResultProperty); this.ShouldSatisfyAllConditions( () => dSMResult.Log.InfoCount.ShouldBe(1), () => dSMResult.Log.WarningCount.ShouldBe(0), () => dSMResult.Log.ErrorCount.ShouldBe(0), () => dSMResult.Log.Messages.Count.ShouldBe(1), () => dSMResult.Log.Messages[0].Message.ShouldBe(ImportCancelledMessage)); }
// Public Methods (1) /// <summary> /// Executes the import job. /// </summary> /// <param name="site">The site.</param> /// <param name="web">The web.</param> /// <param name="data">The data.</param> public void execute(SPSite site, SPWeb web, string data) { try { _done = false; totalCount = 2; resourceImporter = new ResourceImporter(web, data, false); resourceImporter.ImportCompleted += ResourceImportCompleted; resourceImporter.ImportProgressChanged += ResourceImportProgressChanged; resourceImporter.ImportAsync(); while (!_done) { Thread.Sleep(1000); } } catch (Exception ex) { throw ex; } finally { if (web != null) { web.Dispose(); } if (site != null) { site.Dispose(); } data = null; } }