Ejemplo n.º 1
0
 public DataSetSchemaService(IRepository <DataSetSchema> repository,
                             IDataSetSchemaDefinitionService dataSetSchemaDefinitionService
                             , IRepository <DataSetDetail> repositoryDataSetDetail
                             , ISqlTableUtility sqlTableUtility
                             )
 {
     _dataSetSchemaDefinitionService = dataSetSchemaDefinitionService;
     _repository = repository;
     _repositoryDataSetDetail = repositoryDataSetDetail;
     _sqlTableUtility         = sqlTableUtility;
 }
        Create_when_SqlTableExists_with_the_tablename_throws_an_exception_a_table_named_already_exist_in_the_database
            ()
        {
            //arrange
            var mock = new Mock <IDataSetSchemaDefinitionService>();

            mock.Setup(x => x.SqlTableExists("DS_sampletitle2")).Returns(true);
            _dataSetSchemaDefinitionService = mock.Object;
            var sut = new DataSetSchemaService(_repositoryDataSetSchema, _dataSetSchemaDefinitionService,
                                               _repositoryDataSetDetail, _sqlTableUtility);
            var schematoAdd = new DataSetSchema()
            {
                Id = 11, Title = "sampletitle2"
            };

            //act
            sut.Create(schematoAdd);
            //assert
            //cleanup
            _dataSetSchemaDefinitionService = null;
        }
        Create_when_no_errors_will_add_schema_with_new_schemadefinition_with_tablename
            ()
        {
            //arrange
            var mock = new Mock <IDataSetSchemaDefinitionService>();

            mock.Setup(x => x.SqlTableExists("DS_sampletitle2")).Returns(false);
            _dataSetSchemaDefinitionService = mock.Object;
            var sut = new DataSetSchemaService(_repositoryDataSetSchema, _dataSetSchemaDefinitionService,
                                               _repositoryDataSetDetail, _sqlTableUtility);
            var schematoAdd = new DataSetSchema()
            {
                Id = 11, Title = "sampletitle2"
            };

            //act
            sut.Create(schematoAdd);
            var result = _repositoryDataSetSchema.GetQuery().FirstOrDefault(x => x.Id == 11);

            //assert
            Assert.AreEqual("DS_sampletitle2", result.Definition.TableName);
            //cleanup
            _dataSetSchemaDefinitionService = null;
        }