protected override void GivenThat() { base.GivenThat(); PortableDeviceHelper.Stub( helper => helper.GetChildObjectIds(PortableDeviceContent, PortableDeviceConstants.WPD_DEVICE_OBJECT_ID)) .Return(new[] { "Dummy1", "InternalStorageID", "Dummy2" }); PortableDeviceHelper.Stub( helper => helper.GetChildObjectIds(PortableDeviceContent, "InternalStorageID")) .Return(new[] { "Dummy3", "Dummy4", "fooId" }); PortableDeviceHelper.Stub( helper => helper.GetChildObjectIds(PortableDeviceContent, "fooId")) .Return(new[] { "Dummy5", "Dummy6", "barId" }); PortableDeviceHelper .Stub(propertyHelper => propertyHelper.GetObjectFileName( PortableDeviceContent, "InternalStorageID")) .Return("Internal Storage"); PortableDeviceHelper .Stub(propertyHelper => propertyHelper.GetObjectFileName( PortableDeviceContent, "fooId")) .Return("foo"); PortableDeviceHelper .Stub(propertyHelper => propertyHelper.GetObjectFileName( PortableDeviceContent, "barId")) .Return("bar"); }
protected override void GivenThat() { base.GivenThat(); PortableDeviceHelper.Stub( helper => helper.GetChildObjectIds(PortableDeviceContent, PortableDeviceConstants.WPD_DEVICE_OBJECT_ID)) .Return(new[] { "InternalStorageID" }); PortableDeviceHelper.Stub( helper => helper.GetChildObjectIds(PortableDeviceContent, "InternalStorageID")) .Return(new[] { "fooId", "xId" }); PortableDeviceHelper .Stub(propertyHelper => propertyHelper.GetObjectFileName( PortableDeviceContent, "InternalStorageID")) .Return("Internal Storage"); PortableDeviceHelper .Stub(propertyHelper => propertyHelper.GetObjectFileName( PortableDeviceContent, "xId")) .Return("x"); PortableDeviceHelper .Stub(propertyHelper => propertyHelper.GetObjectFileName( PortableDeviceContent, "fooId")) .Return("foo.mp3"); UnderlyingStream = GenerateMock <IStream>(); DeviceStream = GeneratePartialMock <Stream>(); }
protected override void GivenThat() { base.GivenThat(); PortableDeviceHelper.Stub( helper => helper.GetChildObjectIds(PortableDeviceContent, PortableDeviceConstants.WPD_DEVICE_OBJECT_ID)) .Return(new[] { "Dummy1", "xId", "Dummy2" }); PortableDeviceHelper.Stub( helper => helper.GetChildObjectIds(PortableDeviceContent, "xId")) .Return(new[] { "Dummy3", "yId", "Dummy4" }); PortableDeviceHelper.Stub( helper => helper.GetChildObjectIds(PortableDeviceContent, "yId")) .Return(new[] { "Dummy5", "InternalStorageId", "Dummy6" }); StubObjectFilenameAndContentType("xId", "x", PortableDeviceConstants.WPD_CONTENT_TYPE_FOLDER); StubObjectFilenameAndContentType("yId", "y", PortableDeviceConstants.WPD_CONTENT_TYPE_FOLDER); StubObjectFilenameAndContentType("InternalStorageId", "Internal Storage", PortableDeviceConstants.WPD_CONTENT_TYPE_FUNCTIONAL_OBJECT); PortableDeviceHelper.Stub( propertyHelper => propertyHelper.GetGuidProperty( PortableDeviceContent, "InternalStorageId", PortableDevicePropertyKeys.WPD_FUNCTIONAL_OBJECT_CATEGORY)) .Return(PortableDeviceConstants.WPD_FUNCTIONAL_CATEGORY_STORAGE); }
void UploadUploadCommandComplete(object sender, EventArgs e) { _currentNumber++; if (_currentNumber < _vm.Vehicles.Count) { _vm.Vehicles[_currentNumber].Upload.Execute(null); } else { _vm.ResultMessage = "The uploading process has finished."; _isEnable = false; _vm.IsEnableSync = false; EmailHelpers.SendEmailByWcfService(_vm.Vehicles, ((App)Application.Current).Dealer); if (_vm.IsPortableDevice) { PortableDeviceHelper.DeleteFromWpdToHardDrive(); const string backupPortablePath = @"C:\\VincaptureTemporary"; if (Directory.Exists(backupPortablePath)) { FileHelper.DeleteFilesAndFoldersRecursively(backupPortablePath); } } else { if (!String.IsNullOrEmpty(_vm.DealerFolder) && Directory.Exists(_vm.DealerFolder)) { FileHelper.DeleteFilesAndFoldersRecursively(_vm.DealerFolder); } } } }
public void ItShouldCreateTheCorrectFolder() { PortableDeviceHelper.AssertWasCalled( helper => helper.CreateFolderObject( Arg <IPortableDeviceContent> .Is.Equal(PortableDeviceContent), Arg <string> .Is.Equal("fooId"), Arg <string> .Is.Anything)); }
protected override void GivenThat() { base.GivenThat(); PortableDeviceHelper .Stub(propertyHelper => propertyHelper.GetObjectFileName( PortableDeviceContent, PortableDeviceConstants.WPD_DEVICE_OBJECT_ID)) .Return("The device name"); }
protected override void GivenThat() { base.GivenThat(); PortableDeviceHelper.Stub( helper => helper.OpenResourceStream(PortableDeviceContent, "fooId", StreamConstants.STGM_READ)) .Return(UnderlyingStream); DeviceStreamFactory.Stub(factory => factory.CreateStream(UnderlyingStream)) .Return(DeviceStream); }
protected override void GivenThat() { base.GivenThat(); PortableDeviceHelper.Stub( helper => helper.CreateResourceStream(PortableDeviceContent, "InternalStorageID", "foo.mp3", 2345)) .Return(UnderlyingStream); DeviceStreamFactory.Stub(factory => factory.CreateStream(UnderlyingStream)) .Return(DeviceStream); }
protected override void GivenThat() { base.GivenThat(); // Root parent is Device PortableDeviceHelper.Stub( helper => helper.CreateResourceStream(PortableDeviceContent, PortableDeviceConstants.WPD_DEVICE_OBJECT_ID, "new.mp3", 3456)) .Return(UnderlyingStream); DeviceStreamFactory.Stub(factory => factory.CreateStream(UnderlyingStream)) .Return(DeviceStream); }
private void StubObjectFilenameAndContentType(string objectId, string fileName, Guid contentType) { PortableDeviceHelper .Stub(propertyHelper => propertyHelper.GetObjectFileName( PortableDeviceContent, objectId)) .Return(fileName); PortableDeviceHelper.Stub( propertyHelper => propertyHelper.GetObjectContentType(PortableDeviceContent, objectId)) .Return(contentType); }
protected override void GivenThat() { base.GivenThat(); PortableDeviceHelper.Stub( helper => helper.CreateFolderObject(PortableDeviceContent, "xId", "y")) .Return("yId"); PortableDeviceHelper.Stub( helper => helper.GetChildObjectIds(PortableDeviceContent, "xId")) .Return(new string[0]); PortableDeviceHelper.Stub( helper => helper.CreateResourceStream(PortableDeviceContent, "yId", "new.mp3", 4567)) .Return(UnderlyingStream); DeviceStreamFactory.Stub(factory => factory.CreateStream(UnderlyingStream)) .Return(DeviceStream); }
private void workerThread_DoWork(object sender, DoWorkEventArgs e) { const string backupPortablePath = @"C:\\VincaptureTemporary"; const string backupStoragePath = @"C:\\VincaptureImageBackup"; if (_portable == false) { var folder = new DirectoryInfo(_path); var vinCaptureFolder = folder.GetDirectories().FirstOrDefault(i => i.Name.Equals("VinCapture")); if (!Directory.Exists(backupStoragePath)) { Directory.CreateDirectory(backupStoragePath); } CopyAll(vinCaptureFolder, new DirectoryInfo(backupStoragePath)); } else { if (Directory.Exists(backupPortablePath)) { FileHelper.DeleteFilesAndFoldersRecursively(backupPortablePath); } PortableDeviceHelper.TransferFilesFromWpdToHardDrive(backupPortablePath); var folder = new DirectoryInfo(backupPortablePath); var vinCaptureFolder = folder.GetDirectories().FirstOrDefault(i => i.Name.Equals("VinCapture")); if (vinCaptureFolder != null) { CopyAll(vinCaptureFolder, new DirectoryInfo(backupStoragePath)); } } }
public void ItShouldCreateParentFolderObject() { PortableDeviceHelper.AssertWasCalled( helper => helper.CreateFolderObject(PortableDeviceContent, "xId", "y")); }
public void ItShouldDeleteOriginalObject() { PortableDeviceHelper.AssertWasCalled(helper => helper.DeleteObject(PortableDeviceContent, "fooId")); }