public void TestGetContent() { //Arrange FakeContentRepo repo = new FakeContentRepo(); Content testContent = new Content(); testContent.ContentID = "Test"; testContent.CurrentText = "This is a test statement."; //Act repo.AddContent(testContent); //Arrange Assert.AreSame(testContent.ContentID, repo.GetContent(testContent.ContentID).ContentID); Assert.AreSame(testContent.CurrentText, repo.GetContent(testContent.ContentID).CurrentText); }
public void TestUpdateContent() { //Arrange FakeContentRepo repo = new FakeContentRepo(); Content testContent1 = new Content(); testContent1.ContentID = "Test1"; testContent1.CurrentText = "This text was originally for TestContent1"; Content testContent2 = new Content(); testContent2.ContentID = "Test2"; testContent2.CurrentText = "This text was originally for TestContent2"; testContent2.NewText = testContent1.CurrentText; //Act repo.AddContent(testContent1); repo.AddContent(testContent2); testContent2.UpdateSection(); //Assert Assert.AreSame(testContent1.CurrentText, testContent2.CurrentText); }
//The function to do the updating public void UpdateSection(/*string contentID, string newSectionInfo*/) { //Commented out for testing! Please uncomment the next two lines later for the real DB. //ContentRepository contentRepo = new ContentRepository(); //contentRepo.SaveContent(this); FakeContentRepo contentRepo = new FakeContentRepo(); contentRepo.SaveContent(this, contentRepo); /*Psuedo-code for possible update method: * Get Section to Update (passed in as function parameter above) * If NewSectionInfo is < 750 characters * { * If Section is found in database * { * Replace entry in Database with the NewSectionInfo parameter * } * Else return an appropriate error message and do nothing. * } */ }