public void GivenThereAreXNotes() { int project_id = ProjectRepo.All()[0].ProjectId; NoteRepo.Add(new Note("This project needs css work", project_id)); NoteRepo.Add(new Note("This project needs js work", project_id)); Assert.AreEqual(2, NoteRepo.GetAllByProjectId(project_id).Count); }
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 CanAddNoteWithNonExistCatalogDefaultCatalogApplied(NoteCatalog catalog) { // Arrange - null catalog for note var xmlDoc = new XmlDocument(); xmlDoc.LoadXml("<?xml version=\"1.0\" encoding=\"utf-16\"?><root><time>2017-08-01</time></root>"); var note = new HmmNote { Author = _author, Catalog = catalog, CreateDate = DateTime.Now, LastModifiedDate = DateTime.Now, Subject = "testing note is here", Content = xmlDoc.InnerXml }; // Act var savedRec = NoteRepository.Add(note); // Assert Assert.NotNull(savedRec); Assert.True(savedRec.Id > 0, "savedRec.Id>0"); Assert.True(savedRec.Id == note.Id, "savedRec.Id==note.Id"); Assert.NotNull(savedRec.Catalog); Assert.Equal("DefaultNoteCatalog", savedRec.Catalog.Name); }
public void Cannot_Add_Note_With_NonExist_Author(Author author) { // Arrange - null author for note var xmlDoc = new XmlDocument(); xmlDoc.LoadXml("<?xml version=\"1.0\" encoding=\"utf-16\"?><root><time>2017-08-01</time></root>"); var note = new HmmNote { Author = author, Catalog = _catalog, Description = "testing note", CreateDate = DateTime.Now, LastModifiedDate = DateTime.Now, Subject = "testing note is here", Content = xmlDoc.InnerXml }; // Act var savedRec = NoteRepository.Add(note); // Assert Assert.Null(savedRec); Assert.False(NoteRepository.GetEntities().Any()); Assert.False(NoteRepository.ProcessMessage.Success); Assert.Single(NoteRepository.ProcessMessage.MessageList); }
public void Can_Delete_Note() { // Arrange var xmlDoc = new XmlDocument(); xmlDoc.LoadXml("<?xml version=\"1.0\" encoding=\"utf-16\"?><root><time>2017-08-01</time></root>"); var note = new HmmNote { Author = _author, Catalog = _catalog, Description = "testing note", Subject = "testing note is here", Content = xmlDoc.InnerXml, }; NoteRepository.Add(note); Assert.True(NoteRepository.ProcessMessage.Success); // Act var result = NoteRepository.Delete(note); // Assert Assert.True(NoteRepository.ProcessMessage.Success); Assert.True(result); Assert.False(NoteRepository.GetEntities().Any()); }
public void Cannot_Delete_NonExists_Note() { // Arrange var xmlDoc = new XmlDocument(); xmlDoc.LoadXml("<?xml version=\"1.0\" encoding=\"utf-16\"?><root><time>2017-08-01</time></root>"); var note = new HmmNote { Author = _author, Catalog = _catalog, Description = "testing note", Subject = "testing note is here", Content = xmlDoc.InnerXml, }; NoteRepository.Add(note); Assert.True(NoteRepository.ProcessMessage.Success); // change the note id to create a new note var orgId = note.Id; note.Id = 2; // Act var result = NoteRepository.Delete(note); // Assert Assert.False(NoteRepository.ProcessMessage.Success); Assert.False(result); // do this just to make clear up code pass note.Id = orgId; }
public void Post([FromBody] Note note) { if (ModelState.IsValid) { noteRepository.Add(note); } }
public async Task <ActionResult <NoteItem> > Post(NoteItem note) { noteRepository.UserEmail = currentUserService.GetCurrentUserEmail(); await noteRepository.Add(note); return(CreatedAtAction("Get", new { id = note.Id }, note)); }
public void Can_Update_Note_Catalog() { // Arrange var xmlDoc = new XmlDocument(); xmlDoc.LoadXml("<?xml version=\"1.0\" encoding=\"utf-16\"?><root><time>2017-08-01</time></root>"); var note = new HmmNote { Author = _author, Catalog = _catalog, Description = "testing note", CreateDate = DateTime.Now, LastModifiedDate = DateTime.Now, Subject = "testing note is here", Content = xmlDoc.InnerXml }; NoteRepository.Add(note); Assert.True(NoteRepository.ProcessMessage.Success); // changed the note catalog note.Catalog = CatalogRepository.GetEntities().FirstOrDefault(cat => !cat.IsDefault); // Act var savedRec = NoteRepository.Update(note); // Assert Assert.NotNull(savedRec); Assert.NotNull(savedRec.Catalog); Assert.NotNull(note.Catalog); Assert.Equal("Gas Log", savedRec.Catalog.Name); Assert.Equal("Gas Log", note.Catalog.Name); }
public void Can_Update_Note_Content() { // Arrange var xmlDoc = new XmlDocument(); xmlDoc.LoadXml("<?xml version=\"1.0\" encoding=\"utf-16\"?><root><time>2017-08-01</time></root>"); var note = new HmmNote { Author = _author, Catalog = _catalog, Description = "testing note", Subject = "testing note is here", Content = xmlDoc.InnerXml, }; NoteRepository.Add(note); Assert.True(NoteRepository.ProcessMessage.Success); // Act var newXml = new XmlDocument(); newXml.LoadXml("<?xml version=\"1.0\" encoding=\"utf-16\"?><GasLog></GasLog>"); note.Content = newXml.InnerXml; var savedRec = NoteRepository.Update(note); // Assert Assert.NotNull(savedRec); Assert.True(savedRec.Id >= 1, "savedRec.Id >=1"); Assert.True(savedRec.Id == note.Id, "savedRec.Id == note.Id"); Assert.Equal(newXml.InnerXml, savedRec.Content); Assert.NotEqual(xmlDoc.InnerXml, savedRec.Content); }
public void Add(SNote note) { var dNote = SNote.StoD(note); NoteRepository.Add(dNote); note.Id = dNote.Id; }
/// <summary> /// 저장 버튼 클릭스 해당 정보를 Note 객채로 변환해 DB에 저장 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnWrite_Click(object sender, EventArgs e) { if (IsImageTextCorrect()) { UploadProcess(); // 파일 업로드 프로세스 구현 Note note = new Note(); note.Name = txtName.Text; note.Email = HtmlUtility.Encode(txtEmail.Text); note.Homepage = txtHomepage.Text; note.Title = txtTitle.Text; note.Content = HtmlUtility.Encode(txtContent.Text); note.FileName = _FileName; note.FileSize = _FileSize; note.Password = txtPassword.Text; note.PostIp = Request.UserHostAddress; note.Encoding = rdoEncoding.SelectedValue; NoteRepository repo = new NoteRepository(); repo.Add(note); Response.Redirect("BoardList.aspx"); } else { lblError.Text = "보안코드가 틀립니다. 다시 입력하세요."; } }
private void Add_New_Note(object sender, RoutedEventArgs e) { string note = Modal_Note.Text; note_repo.Add(new Note(note, projectId)); DialogResult = true; return; }
public IActionResult Note(Note note) { var currentUser = GetCurrentUser(); note.UserId = currentUser.Id; _noteRepository.Add(note); return(CreatedAtAction(nameof(GetNotesByUser), new { id = note.Id }, note)); }
public IActionResult Post(Note note) { var currentUser = GetCurrentUserProfile(); note.UserProfileId = currentUser.Id; _noteRepository.Add(note); return(CreatedAtAction("Get", new { id = note.Id }, note)); }
public void Cannot_Add_Null_Note() { // Arrange HmmNote note = null; // Act // Asset // ReSharper disable once ExpressionIsAlwaysNull Assert.Throws <ArgumentNullException>(() => NoteRepository.Add(note)); }
public void EntityIsSavedInSessionWhenAddIsCalled() { var mockSession = new Mock<ISession>(); NoteRepository noteRepository = new NoteRepository(mockSession.Object); Entities.Note note = new Entities.Note(); noteRepository.Add(note); mockSession.Verify(x => x.Save(note), Times.Once()); }
public HttpResponseMessage PostNote(Note note) { //TODO: rever este metodo note.Id = repository.Add(note); var response = Request.CreateResponse <int>(HttpStatusCode.Created, note.Id); string uri = Url.Link("DefaultApi", new { id = note.Id }); response.Headers.Location = new Uri(uri); return(response); }
public IActionResult Post(Note note) { var currentUser = GetCurrentUserProfile(); var category = _categoryRepository.GetById((int)note.CategoryId); if (category.UserId != currentUser.Id) { return(BadRequest()); } note.UserId = currentUser.Id; _noteRepository.Add(note); return(CreatedAtAction("Get", new { id = note.Id }, note)); }
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); }
protected void btnWrite_Click(object sender, EventArgs e) { if (IsImageTextCorrect()) { UploadProcess(); Note note = new Note(); note.Id = Convert.ToInt32(_Id); // 없으면 0 note.Name = txtName.Text; note.Email = txtEmail.Text; note.Title = txtTitle.Text; note.Homepage = txtHomepage.Text; note.Content = txtContent.Text; note.FileName = _FileName; note.FileSize = _FileSize; note.Password = txtPassword.Text; note.PostIp = Request.UserHostAddress; note.Encoding = rdoEncoding.SelectedValue; // Text Html Mixed NoteRepository repo = new NoteRepository(); switch (FormType) { case BoardWriteFormType.Write: repo.Add(note); Response.Redirect("BoardList.aspx"); break; case BoardWriteFormType.Modify: break; case BoardWriteFormType.Reply: break; default: break; } } else { lblError.Text = "보안코드가 틀립니다. 다시 입력하세요."; } }
public void Cannot_Update_NonExits_Note() { // Arrange - non exists id var xmlDoc = new XmlDocument(); xmlDoc.LoadXml("<?xml version=\"1.0\" encoding=\"utf-16\"?><root><time>2017-08-01</time></root>"); var note = new HmmNote { Author = _author, Catalog = _catalog, Description = "testing note2", Subject = "testing note is here", Content = xmlDoc.InnerXml, }; NoteRepository.Add(note); // Act var orgId = note.Id; note.Id = 2; var savedRec = NoteRepository.Update(note); // Assert Assert.False(NoteRepository.ProcessMessage.Success); Assert.Null(savedRec); // Arrange - invalid id note.Id = 0; // Act savedRec = NoteRepository.Update(note); // Assert Assert.False(NoteRepository.ProcessMessage.Success); Assert.Null(savedRec); // do this to make clear up code pass note.Id = orgId; }
public void Can_Update_NoteCatalog_To_Catalog_With_Invalid_Id_DefaultCatalog_Applied() { // Arrange - none exists catalog var catalog = new NoteCatalog { Id = -1, Name = "Gas Log", Description = "Testing catalog" }; var initialCatalog = CatalogRepository.GetEntities().FirstOrDefault(cat => !cat.IsDefault); var xmlDoc = new XmlDocument(); xmlDoc.LoadXml("<?xml version=\"1.0\" encoding=\"utf-16\"?><root><time>2017-08-01</time></root>"); var note = new HmmNote { Author = _author, Catalog = initialCatalog, Description = "testing note", CreateDate = DateTime.Now, LastModifiedDate = DateTime.Now, Subject = "testing note is here", Content = xmlDoc.InnerXml }; NoteRepository.Add(note); Assert.True(NoteRepository.ProcessMessage.Success); note.Catalog = catalog; // Act var savedRec = NoteRepository.Update(note); // Assert Assert.True(NoteRepository.ProcessMessage.Success); Assert.NotNull(savedRec); Assert.NotNull(savedRec.Catalog); Assert.Equal("DefaultNoteCatalog", savedRec.Catalog.Name); }
public void Can_Add_Note_To_DataSource() { // Arrange var xmlDocument = new XmlDocument(); xmlDocument.LoadXml("<?xml version=\"1.0\" encoding=\"utf-16\"?><root><time>2017-08-01</time></root>"); var note = new HmmNote { Author = _author, Catalog = _catalog, Description = "testing note", Subject = "testing note is here", Content = xmlDocument.InnerXml }; // Act var savedRec = NoteRepository.Add(note); // Assert Assert.NotNull(savedRec); Assert.True(savedRec.Id >= 1, "savedRec.Id>=1"); Assert.True(savedRec.Id == note.Id, "savedRec.Id==note.Id"); }
protected void btnWrite_Click(object sender, EventArgs e) { //보안 문자를 정확히 입력햇거나, 로그인이 된 상태라면... if (IsImageTextCorrect()) { UploadProcess(); //파일 업로드 관련 코드 분리 Note note = new Note(); note.Id = Convert.ToInt32(_Id); note.Name = txtName.Text; note.Email = HtmlUtility.Encode(txtEmail.Text); note.Homepage = txtHomepage.Text; note.Title = HtmlUtility.Encode(txtTitle.Text); note.Content = txtContent.Text; note.FileName = _FileName; note.FileSize = _FileSize; note.Password = txtPassword.Text; note.PostIp = Request.UserHostAddress; note.Encoding = rdoEncoding.SelectedValue; NoteRepository repository = new NoteRepository(); switch (FormType) { case BoardWriteFormType.Write: repository.Add(note); Response.Redirect("BoardList.aspx"); break; case BoardWriteFormType.Modify: note.ModifyIp = Request.UserHostAddress; note.FileName = ViewState["FileName"].ToString(); note.FileSize = Convert.ToInt32(ViewState["FileSize"]); int r = repository.UpdateNote(note); if (r > 0) //업데이트 완료 { Response.Redirect($"BoardView.aspx?Id={_Id}"); } else { lblError.Text = "업데이트가 되지 않았습니다. 암호를 확인하세요."; } break; case BoardWriteFormType.Reply: note.ParentNum = Convert.ToInt32(_Id); repository.ReplyNote(note); Response.Redirect("BoardList.aspx"); break; default: repository.Add(note); Response.Redirect("BoardList.aspx"); break; } } else { lblError.Text = "보안코드가 틀립니다. 다시 입력하세요."; } }
public Note Post([FromBody] Note value) { return(repo.Add(value)); }
public void AddNote(Note newNote) { _noteRepository.Add(newNote); }
public void TestAddNoteMethod() { var projects = project_repo.All(); Assert.AreEqual(projects.Count, 2); int project_id = projects[0].ProjectId; note_repo.Add(new Note("this is a test note", project_id)); Assert.AreEqual(note_repo.GetCount(), 1); }