示例#1
0
        public void CanReadRecords()
        {
            var fileCollection = new SimpleFileCollection <RecordStub>();
            var records        = fileCollection.ToList();

            records.ShouldNotBeNull();
        }
示例#2
0
        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);
        }
示例#3
0
        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));
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }
示例#6
0
        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);
        }