public void CanReadRecords() { var fileCollection = new SimpleFileCollection <RecordStub>(); var records = fileCollection.ToList(); records.ShouldNotBeNull(); }
public void IncrementsKey() { var fileCollection = new SimpleFileCollection <RecordStub>(); var testRecord1 = new RecordStub(); var testRecord2 = new RecordStub(); fileCollection.Add(testRecord1); fileCollection.Add(testRecord2); testRecord1.Key.ShouldBe(0); testRecord2.Key.ShouldBe(1); }
public void CanAddRecord() { var fileCollection = new SimpleFileCollection <RecordStub>(); var testRecord = new RecordStub { TestValue = "This is a test" }; fileCollection.Add(testRecord); var records = fileCollection.ToList(); records.ShouldContain(Is(testRecord)); }
protected override void BeginProcessing() { if (!string.IsNullOrEmpty(Path)) Path = GetUnresolvedProviderPathFromPSPath(Path); FileCollection collection; if (Simple) collection = new SimpleFileCollection(Path, FileFormat); else collection = new NormalFileCollection(Path, FileFormat); collection.Read(NewCollection); SessionState.PSVariable.Set(CollectionVariable ?? Actor.CollectionVariable, collection); }
public void CanUpdateRecord() { const string previousValue = "Test 1"; const string newValue = "Test 2"; var fileCollection = new SimpleFileCollection <RecordStub>(); var testRecord = new RecordStub { TestValue = previousValue }; fileCollection.Add(testRecord); var addedRecord = fileCollection.SingleOrDefault(Matches(testRecord)); addedRecord.TestValue.ShouldBe(previousValue); testRecord.TestValue = newValue; fileCollection.Update(testRecord); var updatedRecord = fileCollection.SingleOrDefault(Matches(testRecord)); updatedRecord.TestValue.ShouldBe(newValue); }
protected override void BeginProcessing() { if (!string.IsNullOrEmpty(Path)) { Path = GetUnresolvedProviderPathFromPSPath(Path); } FileCollection collection; if (Simple) { collection = new SimpleFileCollection(Path, FileFormat); } else { collection = new NormalFileCollection(Path, FileFormat); } collection.Read(NewCollection); SessionState.PSVariable.Set(CollectionVariable ?? Actor.CollectionVariable, collection); }