Пример #1
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);
        }
Пример #2
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));
        }
Пример #3
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);
        }
Пример #4
0
 private static Func <RecordStub, bool> Matches(RecordStub testRecord)
 {
     return(r => r.Key == testRecord.Key);
 }
Пример #5
0
 private static Expression <Func <RecordStub, bool> > Is(RecordStub testRecord)
 {
     return(r =>
            r.Key == testRecord.Key &&
            r.TestValue == testRecord.TestValue);
 }