public void Read_DataReaderReadTrue() { _dataReaderStrictMock.Expect(mock => mock.Read()).Return(true).Repeat.Once(); _idPropertyStrictMock .Expect(mock => mock.CombineValue(Arg <IColumnValueProvider> .Is.Anything)) .Return(_objectID) .WhenCalled(mi => CheckColumnValueReader((ColumnValueReader)mi.Arguments[0])); ReplayAll(); var result = _reader.Read(_dataReaderStrictMock); VerifyAll(); Assert.That(result, Is.SameAs(_objectID)); }
public void ReadSequence_DataReaderReadTrue_NullIDIsReturned() { _dataReaderStrictMock.Expect(mock => mock.Read()).Return(true).Repeat.Once(); _dataReaderStrictMock.Expect(mock => mock.Read()).Return(false); _idPropertyStrictMock .Expect(mock => mock.CombineValue(Arg <IColumnValueProvider> .Is.Anything)) .Return(null); ReplayAll(); var result = _dataContainerReader.ReadSequence(_dataReaderStrictMock).ToArray(); VerifyAll(); Assert.That(result.Length, Is.EqualTo(1)); Assert.That(result[0], Is.Null); }
public void Read_DataReaderReadTrue_NonNullValue() { _dataReaderStrictMock.Expect(mock => mock.Read()).Return(true).Repeat.Once(); _idPropertyStrictMock .Expect(mock => mock.CombineValue(Arg <IColumnValueProvider> .Is.Anything)) .Return(_fakeObjectIDResult) .WhenCalled(mi => CheckColumnValueReader((ColumnValueReader)mi.Arguments[0])); _timestampStrictMock .Expect(mock => mock.CombineValue(Arg <IColumnValueProvider> .Is.Anything)) .Return(_fakeTimestampResult) .WhenCalled(mi => CheckColumnValueReader((ColumnValueReader)mi.Arguments[0])); ReplayAll(); var result = _reader.Read(_dataReaderStrictMock); VerifyAll(); Assert.That(result, Is.EqualTo(Tuple.Create(_fakeObjectIDResult, _fakeTimestampResult))); }
public void CreateForRelationLookup_TableDefinition_NoSortExpression() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithTable(classType: typeof(Order), storageProviderDefinition: TestDomainStorageProviderDefinition); var relationEndPointDefinition = CreateForeignKeyEndPointDefinition(classDefinition); var oppositeTable = (TableDefinition)relationEndPointDefinition.ClassDefinition.StorageEntityDefinition; _foreignKeyStoragePropertyDefinitionStrictMock.Expect(mock => mock.SplitValueForComparison(_foreignKeyValue)).Return(_fakeComparedColumns); _foreignKeyStoragePropertyDefinitionStrictMock.Replay(); var expectedSelectedColumns = _tableDefinition.GetAllColumns(); _dbCommandBuilderFactoryStrictMock .Expect( stub => stub.CreateForSelect( Arg.Is((TableDefinition)classDefinition.StorageEntityDefinition), Arg <IEnumerable <ColumnDefinition> > .List.Equal(expectedSelectedColumns), Arg.Is(_fakeComparedColumns), Arg <IEnumerable <OrderedColumn> > .List.Equal(new OrderedColumn[0]))) .Return(_dbCommandBuilderStub); _dbCommandBuilderFactoryStrictMock.Replay(); _objectReaderFactoryStrictMock .Expect( mock => mock.CreateDataContainerReader( Arg.Is((IRdbmsStorageEntityDefinition)oppositeTable), Arg <IEnumerable <ColumnDefinition> > .List.Equal(expectedSelectedColumns))) .Return(_dataContainerReaderStub); _objectReaderFactoryStrictMock.Replay(); var result = _factory.CreateForRelationLookup(relationEndPointDefinition, _foreignKeyValue, null); _objectReaderFactoryStrictMock.VerifyAllExpectations(); _foreignKeyStoragePropertyDefinitionStrictMock.VerifyAllExpectations(); _dbCommandBuilderFactoryStrictMock.VerifyAllExpectations(); Assert.That(result, Is.TypeOf(typeof(MultiObjectLoadCommand <DataContainer>))); var dbCommandBuilderTuples = ((MultiObjectLoadCommand <DataContainer>)result).DbCommandBuildersAndReaders; Assert.That(dbCommandBuilderTuples.Length, Is.EqualTo(1)); Assert.That(dbCommandBuilderTuples[0].Item1, Is.SameAs(_dbCommandBuilderStub)); Assert.That(dbCommandBuilderTuples[0].Item2, Is.SameAs(_dataContainerReaderStub)); }
private void ExpectPropertyCombinesForOrderTicket(ObjectID objectID, object timestamp, string fileName, ObjectID order) { _idPropertyStrictMock .Expect(mock => mock.CombineValue(Arg <IColumnValueProvider> .Is.Anything)) .Return(objectID) .WhenCalled(mi => CheckColumnValueReader((ColumnValueReader)mi.Arguments[0])) .Repeat.Once(); _timestampPropertyStrictMock .Expect(mock => mock.CombineValue(Arg <IColumnValueProvider> .Is.Anything)) .Return(timestamp) .WhenCalled(mi => CheckColumnValueReader((ColumnValueReader)mi.Arguments[0])) .Repeat.Once(); _fileNamePropertyStrictMock .Expect(mock => mock.CombineValue(Arg <IColumnValueProvider> .Is.Anything)) .Return(fileName) .WhenCalled(mi => CheckColumnValueReader((ColumnValueReader)mi.Arguments[0])) .Repeat.Once(); _orderPropertyStrictMock .Expect(mock => mock.CombineValue(Arg <IColumnValueProvider> .Is.Anything)) .WhenCalled(mi => CheckColumnValueReader((ColumnValueReader)mi.Arguments[0])) .Return(order) .Repeat.Once(); }