public void DeleteDocumentFromDb_ExpectedParametersAndParagraphToDelete_Ok() { Margin margin = new Margin(MarginAlign.HEADER, "aStyleClass"); margin.SetText(new Text()); aDocumentPart.PutTextAtLast(new Text()); document.AddDocumentParagraphAtLast(aDocumentPart); document.SetDocumentMargin(margin.Align, margin); documentDataAccess.Add(document); documentDataAccess.Delete(document.Id); Document obtained = documentDataAccess.Get(document.Id); Paragraph paragraphObtained = paragraphDataAccess.Get(aDocumentPart.Id); ITextDataAccess txtDA = new TextDataAccess(); Text text1 = txtDA.Get(margin.GetText().Id); Text text2 = txtDA.Get(aDocumentPart.GetTextAt(0).Id); Assert.IsNull(obtained); Assert.IsNull(paragraphObtained); Assert.IsNull(text1); Assert.IsNull(text2); }
public void CreateTextBL_WithParameters_Ok() { ITextDataAccess textDataAccess = new TextDataAccess(); IBodyDataAccess bodyDataAccess = new BodyDataAccess(); ITextBusinessLogic textBL = new TextBusinessLogic(textDataAccess); Assert.IsNotNull(textBL); }
public void SaveTextTest() { string filePath = "filepath"; List <string> lines = new List <string>() { "dlkfjwoeitupisposf, ", "sjdlfujrtppqepoiqq", "fccoviuoeqlkjwe" }; List <string> result = TextDataAccess.SaveText(filePath, lines); Assert.Equal(lines, result); }
public void SaveTextTest2() { string filePath = "lskdfjkdjfkdjflkdjlfkdjlskdjfpwierpweurppppppppppppppppppppppppppppppppppppppppppppppp" + "oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" + "oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo"; List <string> lines = new List <string>() { "dlkfjwoeitupisposf, ", "sjdlfujrtppqepoiqq", "fccoviuoeqlkjwe" }; Action testCode = () => { List <string> result = TextDataAccess.SaveText(filePath, lines); }; var ex = Record.Exception(testCode); Assert.IsType <PathTooLongException>(ex); }
public void SaveText_WhenCalled_ShouldExecuteWriteAllText() { FakeWriteText mockWrite = new FakeWriteText(); TextDataAccess textDataAccess = new TextDataAccess(mockWrite); List <string> lines = new List <string> { "First line", "Second line", "Third line" }; string filePath = $"write.txt"; textDataAccess.SaveText(filePath, lines); Assert.True(mockWrite.Done); }
public void IntegrationTest_ExpectedParameters_Ok() { TextDataAccess textDA = new TextDataAccess(); BodyDataAccess bodyDA = new BodyDataAccess(); TextBusinessLogic textBL = new TextBusinessLogic(textDA); Text text1 = Utils.CreateTextForTest(); Text text2 = Utils.CreateTextForTest(); textBL.AddText(text1); textBL.AddText(text2); text2.OwnStyleClass = "Other style"; textBL.ModifyText(text2); textBL.DeleteText(text1.Id); Text text2Obtained = textBL.GetText(text2.Id); IList <Text> textsObtained = textBL.GetTexts(); Assert.IsTrue(!textsObtained.Contains(text1) && textsObtained.Contains(text2Obtained)); }
public void SaveText_Normal() { List <string> lines = new List <string> { "Test one", "Test 2", "Test III" }; string filePath = @"C:\Temp\Test.txt"; string fileName = "Test.txt"; var mock = new Mock <IWriteToText>(); mock.Setup(x => x.WriteToFile(fileName, It.IsAny <List <string> >())).Verifiable(); TextDataAccess dataAccess = new TextDataAccess(); dataAccess.SaveText(filePath, lines, mock.Object); mock.Verify(); }
public void SaveText_ShouldThrowException() { WriteText writeText = new WriteText(); TextDataAccess textDataAccess = new TextDataAccess(writeText); List <string> lines = new List <string> { "First line", "Second line", "Third line" }; string filePath = $"This path is too long with 261 characters" + $"qwertyuiopasdfghjklzxcvbnm1234567890" + $"qwertyuiopasdfghjklzxcvbnm1234567890" + $"qwertyuiopasdfghjklzxcvbnm1234567890" + $"qwertyuiopasdfghjklzxcvbnm1234567890" + $"qwertyuiopasdfghjklzxcvbnm1234567890" + $"qwertyuiopasdfghjklzxcvbnm1234567890"; TestDelegate testDelegate = () => textDataAccess.SaveText(filePath, lines); Assert.Throws <PathTooLongException>(testDelegate); }
public void SaveText_InvalidPathShouldThrowException() { List <string> lines = new List <string> { "Test one", "Test 2", "Test III" }; string filePath = @"C:\Temp\Testendkjnewdjnwekdjnwkendwkjendkjwnedkjwnedkjwnedkjnwekdjnfvnkjtnrtnkrnvkjernvkjwnefnwefnwjenfkjwkjervkjnrkjvnekjrvbkwjenfkjwne jrbfkwrfkjbekrjfbekrbfkerfkebrfberfbehrbktnbmeprnvwnvwnowirnvpwmboientoivnernvoiwrncoiwnvoierpvowpfvbeoubvbeorivnworinvowrinvoiwrnvoiwnrviowrvniowrnvoiwrvwi jwnrfonworivnwoirnvoienrvoineworvneoinvoienvoienvoineorivnowirmfpoqke[fompevineonburbnoeirmgpowgviwnepfomqpeofmcwpoefmotibnoeinvwimcxwmewcwerneoirvnowiernvo iernviernnowirnv.txt" ; string fileName = "Test.txt"; var mock = new Mock <IWriteToText>(); mock.Setup(x => x.WriteToFile(fileName, It.IsAny <List <string> >())).Verifiable(); TextDataAccess dataAccess = new TextDataAccess(); Assert.Throws <PathTooLongException>( () => dataAccess.SaveText(filePath, lines, mock.Object)); }
public TextDataAccessTests() { _fileWriter = new DummyFileWriter(); _textDataAccess = new TextDataAccess(_fileWriter); }