public void CanNot_Add_Already_Existed_NoteCatalog_To_DataSource() { // Arrange CatalogRepository.Add(new NoteCatalog { Name = "GasLog", Render = _render, Schema = "TestSchema", IsDefault = true, Description = "testing note", }); var cat = new NoteCatalog { Name = "GasLog", Render = _render, Schema = "TestSchema", IsDefault = false, Description = "testing note", }; // Act var savedRec = CatalogRepository.Add(cat); // Assert Assert.Null(savedRec); Assert.True(cat.Id <= 0, "cat.Id <=0"); Assert.False(CatalogRepository.ProcessMessage.Success); Assert.Single(CatalogRepository.ProcessMessage.MessageList); }
public void Cannot_Delete_NoteRender_With_CatalogAssociated() { // Arrange var render = new NoteRender { Name = "DefaultRender", Namespace = "NameSpace", IsDefault = true, Description = "Description" }; var savedRender = RenderRepository.Add(render); var catalog = new NoteCatalog { Name = "GasLog", Render = savedRender, Schema = "Scheme", IsDefault = true, Description = "testing Catalog" }; CatalogRepository.Add(catalog); // Act var result = RenderRepository.Delete(render); // Assert Assert.False(result, "Error: deleted render with catalog attached to it"); Assert.False(RenderRepository.ProcessMessage.Success); Assert.Single(RenderRepository.ProcessMessage.MessageList); }
public void Cannot_Update_Catalog_With_Duplicated_Name() { // Arrange var catalog = new NoteCatalog { Name = "GasLog", Render = _render, Schema = "TestSchema", IsDefault = true, Description = "testing note" }; CatalogRepository.Add(catalog); var catalog2 = new NoteCatalog { Name = "GasLog2", Render = _render, Schema = "TestSchema", IsDefault = false, Description = "testing note2" }; CatalogRepository.Add(catalog2); catalog.Name = catalog2.Name; // Act var result = CatalogRepository.Update(catalog); // Assert Assert.Null(result); Assert.False(CatalogRepository.ProcessMessage.Success); Assert.Single(CatalogRepository.ProcessMessage.MessageList); }
public void Can_Update_Catalog() { // Arrange - update name var catalog = new NoteCatalog { Name = "GasLog", Render = _render, Schema = "TestSchema", IsDefault = true, Description = "testing note" }; CatalogRepository.Add(catalog); catalog.Name = "GasLog2"; // Act var result = CatalogRepository.Update(catalog); // Assert Assert.NotNull(result); Assert.Equal("GasLog2", result.Name); // Arrange - update description catalog.Description = "new testing note"; // Act result = CatalogRepository.Update(catalog); // Assert Assert.NotNull(result); Assert.Equal("new testing note", result.Description); }
public void Cannot_Delete_Catalog_With_Note_Associated() { // Arrange var catalog = new NoteCatalog { Name = "GasLog", Render = _render, Schema = "TestSchema", IsDefault = true, Description = "testing note" }; var savedCatalog = CatalogRepository.Add(catalog); var note = new HmmNote { Subject = "Testing subject", Content = "Testing content", CreateDate = DateTime.Now, LastModifiedDate = DateTime.Now, Author = _author, Catalog = savedCatalog }; NoteRepository.Add(note); // Act var result = CatalogRepository.Delete(catalog); // Assert Assert.False(result, "Error: deleted catalog with note attached to it"); Assert.False(CatalogRepository.ProcessMessage.Success); Assert.Single(CatalogRepository.ProcessMessage.MessageList); }
public void Cannot_Delete_NonExists_Catalog_From_DataSource() { // Arrange var catalog = new NoteCatalog { Name = "GasLog", Render = _render, Schema = "TestSchema", IsDefault = true, Description = "testing note" }; CatalogRepository.Add(catalog); var catalog2 = new NoteCatalog { Name = "GasLog2", Render = _render, Schema = "TestSchema", IsDefault = false, Description = "testing note" }; // Act var result = CatalogRepository.Delete(catalog2); // Assert Assert.False(result); Assert.False(CatalogRepository.ProcessMessage.Success); Assert.Single(CatalogRepository.ProcessMessage.MessageList); }
public async Task <IActionResult> PostCatalog([FromBody] CatalogDTO catalogDTO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var catalog = await catalogRepository.Add(catalogDTO); if (catalog == null) { return(BadRequest()); } CatalogDTO dto = new CatalogDTO(); dto.CatalogId = catalog.CatalogId; dto.Date = catalog.Date; dto.CatalogDescription = catalog.CatalogDescription; dto.CatalogName = catalog.CatalogName; dto.products = new List <ProductDTO>(); foreach (CatalogProduct cp in catalog.CatalogProducts) { ProductDTO pdto = productToDTO(cp.Product); dto.products.Add(pdto); } return(CreatedAtAction("PostCatalog", dto)); }
public void Cannot_Delete_Author_With_Note_Associated() { // Arrange var render = new NoteRender { Name = "DefaultRender", Namespace = "NameSpace", IsDefault = true, Description = "Description" }; var savedRender = RenderRepository.Add(render); var catalog = new NoteCatalog { Name = "DefaultCatalog", Render = savedRender, Schema = "testScheme", IsDefault = false, Description = "Description" }; var savedCatalog = CatalogRepository.Add(catalog); var author = new Author { AccountName = "glog", Description = "testing user", IsActivated = true }; var savedUser = AuthorRepository.Add(author); var note = new HmmNote { Subject = string.Empty, Content = string.Empty, CreateDate = DateTime.Now, LastModifiedDate = DateTime.Now, Author = savedUser, Catalog = savedCatalog }; NoteRepository.Add(note); // Act var result = AuthorRepository.Delete(author); // Assert Assert.False(result, "Error: deleted user with note"); Assert.False(AuthorRepository.ProcessMessage.Success); Assert.Single(AuthorRepository.ProcessMessage.MessageList); }
public void CreateCatalog(Model.Local.Catalog parent) { Model.Local.Catalog local = new Model.Local.Catalog() { Name = "Nouveau catalogue", Cat_Level = (parent == null) ? 2 : parent.Cat_Level + 1, Cat_Parent = (parent == null) ? 0 : parent.Cat_Id, Cat_Date = DateTime.Now, Sag_Id = 0, Pre_Id = null, }; CatalogRepository.Add(local); this.LoadCatalogs(); }
protected void CreateFullGraphCatalog(string catalogId, ref Item[] items) { var catalogBuilder = CatalogBuilder.BuildCatalog(catalogId).WithCategory("category").WithProducts(10); var catalog = catalogBuilder.GetCatalog(); items = catalogBuilder.GetItems(); CatalogRepository.Add(catalog); foreach (var item in items) { CatalogRepository.Add(item); } CatalogRepository.UnitOfWork.Commit(); }
public void Can_Add_NoteCatalog_To_DataSource() { // Arrange var catalog = new NoteCatalog { Name = "GasLog", Render = _render, Schema = "TestSchema", Description = "testing note", }; // Act var savedRec = CatalogRepository.Add(catalog); // Assert Assert.NotNull(savedRec); Assert.True(savedRec.Id > 0, "savedRec.Id > 0"); Assert.True(catalog.Id == savedRec.Id, "cat.Id == savedRec.Id"); Assert.True(CatalogRepository.ProcessMessage.Success); }
public bool Add(Catalog catalog) { return(_catalogRepository.Add(catalog)); }