Esempio n. 1
0
        public IEnumerable <string> GetSurveyModes(string instrumentName, string serverParkName)
        {
            instrumentName.ThrowExceptionIfNullOrEmpty("instrumentName");
            serverParkName.ThrowExceptionIfNullOrEmpty("serverParkName");

            return(_surveyMetaService.GetSurveyModes(_connectionModel, instrumentName, serverParkName));
        }
        public void Given_An_Instrument_Is_Installed_In_Cati_And_Cawi_Mode_When_I_Call_GetSurveyModes_The_Correct_Modes_Are_Returned()
        {
            //arrange
            const string mode1     = "CATI";
            var          mode1Mock = new Mock <IMode>();

            mode1Mock.Setup(m => m.Name).Returns(mode1);

            const string mode2     = "CAWI";
            var          mode2Mock = new Mock <IMode>();

            mode2Mock.Setup(m => m.Name).Returns(mode2);

            var modelList = new List <IMode> {
                mode1Mock.Object, mode2Mock.Object
            };

            var modeCollection = new Mock <IModeCollection>();

            modeCollection.Setup(m => m.GetEnumerator()).Returns(modelList.GetEnumerator());

            var dataModelMock = new Mock <IDatamodel2>();

            dataModelMock.Setup(dm => dm.Modes).Returns(modeCollection.Object);

            _dataModelServiceMock.Setup(dm => dm.GetDataModel(_connectionModel,
                                                              _instrumentName, _serverParkName)).Returns(dataModelMock.Object);

            //act
            var result = _sut.GetSurveyModes(_connectionModel, _instrumentName, _serverParkName).ToList();

            //assert
            Assert.IsNotNull(result);
            Assert.IsNotEmpty(result);
            Assert.AreEqual(2, result.Count);
            Assert.Contains("CAWI", result);
            Assert.Contains("CATI", result);
        }