Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 4
0
 private static Func <RecordStub, bool> Matches(RecordStub testRecord)
 {
     return(r => r.Key == testRecord.Key);
 }
Exemplo n.º 5
0
 private static Expression <Func <RecordStub, bool> > Is(RecordStub testRecord)
 {
     return(r =>
            r.Key == testRecord.Key &&
            r.TestValue == testRecord.TestValue);
 }