public void SettingPropertyOfTypeFileBasedDoesNotCreateNewIfItemIsExternal() { var dataDirectoryPath = TestHelper.GetCurrentMethodName() + "_data"; var project = new Project(); var repository = new ProjectFileBasedItemRepository(); repository.Initialize(project, dataDirectoryPath); // add empty data item and set fileBased item to it. var container = new ClassContainingFileBasedProperty(); project.RootFolder.Add(container); IFileBased fileBased; using (mocks.Record()) { fileBased = mocks.Stub <IFileBased>(); fileBased.Path = "some_external_path"; } using (mocks.Playback()) { container.FileBased = fileBased; // <- triggers new Path generation since it is empty } repository.Close(); fileBased.Path .Should("Path does not change if item has external path").Be.EqualTo("some_external_path"); }
public void SettingPropertyOfTypeFileBasedCreateNewPath() { var dataDirectoryPath = TestHelper.GetCurrentMethodName() + "_data"; var project = new Project(); var repository = new ProjectFileBasedItemRepository(); repository.Initialize(project, dataDirectoryPath); // add empty data item and set fileBased item to it. var container = new ClassContainingFileBasedProperty(); project.RootFolder.Add(container); IFileBased fileBased; using (mocks.Record()) { fileBased = mocks.Stub <IFileBased>(); fileBased.Expect(fb => fb.CreateNew(null)).Repeat.Once().IgnoreArguments() .Do(new Action <string>(delegate(string path) { fileBased.Path = path; })); } using (mocks.Playback()) { container.FileBased = fileBased; // <- triggers new Path generation since it is empty } string.IsNullOrEmpty(fileBased.Path) .Should("new path should be generated for an item after it is added to the project").Be.False(); repository.Close(); }