public void CreateCollection_MissingName() { var collectionRepo = new Mock <ICollectionRepo>(); ICollectionService service = new CollectionService(collectionRepo.Object); var collection = new Collection() { Name = "" }; Exception ex = Assert.Throws <Exception>(() => service.AddCollection(collection)); Assert.Equal("Collection name is required.", ex.Message); }
public ActionResult AddCollection(string collectionName) { if (collectionService.IsCollectionNameValid(collectionName)) { return(Conflict($"{collectionName} is already created")); } var collection = collectionService.AddCollection(collectionName); if (collection != null) { logger.LogInformation($"Collection created: {collection.Name}"); return(CreatedAtRoute("GetCollection", new { collectionName, withIncludes = true }, collection)); } return(NotFound()); }
/// <summary> /// 添加表数据 /// </summary> /// <param name="entity"></param> /// <returns></returns> public bool AddCollection(Collection entity) { return(cs.AddCollection(entity)); }