public void Create_when_schema_is_externaldata_will_save_in_schema_definition_in_repository() { //arrange var schematoAdd = new DataSetSchema() { Id = 10, Title = "sampletitle", IsExternalData = true }; var sut = new DataSetSchemaService(_repositoryDataSetSchema, _dataSetSchemaDefinitionService, _repositoryDataSetDetail, _sqlTableUtility); //act sut.Create(schematoAdd); var result = _repositoryDataSetSchema.GetQuery().FirstOrDefault(x => x.Id == 10); //assert Assert.AreEqual("sampletitle", result.Title); //cleanup _repositoryDataSetSchema.Delete(schematoAdd); }
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; }
public void Create_when_datasetschema_title_exists_will_throw_exception_a_schema_already_exist() { //arrange var schema1 = new DataSetSchema() { Id = 1, Title = "sampletitle" }; _repositoryDataSetSchema.Add(schema1); var schematoAdd = new DataSetSchema() { Title = "sampletitle" }; var sut = new DataSetSchemaService(_repositoryDataSetSchema, _dataSetSchemaDefinitionService, _repositoryDataSetDetail, _sqlTableUtility); //act sut.Create(schematoAdd); //assert - no need as throwing exception //cleanup _repositoryDataSetSchema.Delete(schema1); }
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; }