public bool FieldExists(ConnectionModel connectionModel, string instrumentName, string serverParkName, FieldNameType fieldNameType)
        {
            var dataModel       = _dataModelService.GetDataModel(connectionModel, instrumentName, serverParkName);
            var definitionScope = (IDefinitionScope2)dataModel;

            return(definitionScope.FieldExists(fieldNameType.FullName()));
        }
Beispiel #2
0
        public void Given_A_DataRecord_When_I_Call_FieldExists_Then_The_Correct_Value_Is_Returned(FieldNameType fieldNameType, bool fieldExists)
        {
            //arrange
            var dataRecord2Mock     = new Mock <IDataRecord2>();
            var fieldCollectionMock = new Mock <IFieldCollection>();

            var iFieldMock = new Mock <IField>();

            if (fieldExists)
            {
                iFieldMock.Setup(f => f.FullName).Returns(fieldNameType.FullName());
            }
            else
            {
                iFieldMock.Setup(f => f.FullName).Returns("Does Not Exist");
            }
            var fields = new List <IField> {
                iFieldMock.Object
            };

            fieldCollectionMock.Setup(f => f.GetEnumerator())
            .Returns(fields.GetEnumerator());

            dataRecord2Mock.Setup(d => d.Fields).Returns(fieldCollectionMock.Object);

            //act
            var result = _sut.FieldExists(dataRecord2Mock.Object, fieldNameType);

            //assert
            Assert.NotNull(result);
            Assert.AreEqual(fieldExists, result);
        }
        public bool FieldExists(IDataRecord dataRecord, FieldNameType fieldNameType)
        {
            var dataRecord2 = (IDataRecord2)dataRecord;
            var dataFields  = dataRecord2.GetDataFields();

            return(dataFields.Any(f =>
                                  f.FullName.Equals(fieldNameType.FullName(), StringComparison.InvariantCultureIgnoreCase)));
        }
Beispiel #4
0
        public void iven_A_FieldNameType_When_I_Call_GetField_Then_The_Correct_Field_Is_Returned(FieldNameType fieldNameType)
        {
            //arrange
            var fieldMock = new Mock <IField>();

            var dataRecordMock = new Mock <IDataRecord>();

            dataRecordMock.Setup(d => d.GetField(fieldNameType.FullName())).Returns(fieldMock.Object);

            //act
            var result = _sut.GetField(dataRecordMock.Object, fieldNameType);

            //assert
            Assert.AreEqual(fieldMock.Object, result);
        }
 public IField GetField(IDataRecord dataRecord, FieldNameType fieldNameType)
 {
     return(dataRecord.GetField(fieldNameType.FullName()));
 }
        public bool FieldExists(IDataRecord dataRecord, FieldNameType fieldNameType)
        {
            var dataRecord2 = (IDataRecord2)dataRecord;

            return(dataRecord2.Fields.Any(f => f.FullName == fieldNameType.FullName()));
        }