public void AssumeDocCreated() { var manager = new DocumentsRepository(); var document = manager.Create("doc1", "user1"); Assert.IsTrue(document.State == State.Created); Assert.IsTrue(document.Success); }
public void AssertReadSameText() { var manager = new DocumentsRepository(); manager.Create("doc1", "user1"); var result = manager.Delete("doc1", "user1"); Assert.IsTrue(result.Success); Assert.IsTrue(result.State == State.Deleted); result = manager.Open("doc1", "user1"); Assert.IsFalse(result.Success); Assert.IsTrue(result.State == State.Deleted); }
public void AssumeDocumentListCorrect() { var repo = new DocumentsRepository(); repo.Create("doc1", "user1"); repo.Create("doc2", "user1"); repo.Create("doc3", "user1"); repo.Create("doc4", "user1"); var docs = repo.AvailableDocuments(); Assert.IsTrue(docs.Length == 4); Assert.IsTrue(docs[0].Name == "doc1"); Assert.IsTrue(docs[1].Name == "doc2"); Assert.IsTrue(docs[2].Name == "doc3"); Assert.IsTrue(docs[3].Name == "doc4"); }
public void AssumeOpenedAnotheruserWontClose() { // create var manager = new DocumentsRepository(); var document = manager.Create("doc1", "user1"); Assert.IsTrue(document.State == State.Created); Assert.IsTrue(document.Success); // open var result = manager.Open("doc1", "user1"); Assert.IsTrue(result.Success); Assert.IsTrue(result.State == State.Opened); // close while opened. result = manager.Close("doc1", "user2"); Assert.IsFalse(result.Success); Assert.IsTrue(result.State == State.Opened); }
public void AssumeOpenedWillCloseAndDelete() { // create var manager = new DocumentsRepository(); var document = manager.Create("doc1", "user1"); Assert.IsTrue(document.State == State.Created); Assert.IsTrue(document.Success); // open var result = manager.Open("doc1", "user1"); Assert.IsTrue(result.Success); Assert.IsTrue(result.State == State.Opened); // close while opened. result = manager.Close("doc1", "user1"); Assert.IsTrue(result.Success); Assert.IsTrue(result.State == State.Closed); // deleted closed. result = manager.Delete("doc1", "user1"); Assert.IsTrue(result.Success); Assert.IsTrue(result.State != State.Closed); }
public void AssumeWillOpenOpenBySameUser() { var repo = new DocumentsRepository(); repo.Create("doc1", "user1"); var result = repo.Open("doc1", "user1"); var result2 = repo.Open("doc1", "user1"); Assert.IsTrue(result.Success); Assert.IsTrue(result.State == State.Opened); Assert.IsTrue(result2.Success); Assert.IsTrue(result2.State == State.Opened); }
public void TryWriteOpened() { const string Text = "sdasdasdas"; var repo = new DocumentsRepository(); repo.Create("doc1", "user1"); var result = repo.Open("doc1", "user1"); var result2 = repo.Write("doc1", "user1", Text); var result3 = repo.Open("doc1", "user1"); Assert.IsTrue(result.Success); Assert.IsTrue(result.State == State.Opened); Assert.IsTrue(result2.Success); Assert.IsTrue(result2.State == State.Opened); Assert.IsTrue(result3.Success); Assert.IsTrue(result3.State == State.Opened); Assert.IsTrue(result3.Buffer == Text); }
public void TryOpenNotExisting() { var repo = new DocumentsRepository(); var result = repo.Open("dsds", "user1"); Assert.IsFalse(result.Success); Assert.IsTrue(result.State == State.Deleted); }
public void CreateLoadSaveLoad() { var repo = new DocumentsRepository(); var result = repo.Create("doc1", "user1"); result = repo.Open("doc1", "user1"); result = repo.Write("doc1", "user1", "sfsdfdfa"); result = repo.Open("doc1", "user1"); result = repo.Close("doc1", "user1"); }
public void AssumeWriteInCreated() { const string Text = "sdasdasdas"; var repo = new DocumentsRepository(); repo.Create("doc1", "user1"); var result = repo.Write("doc1", "user1", Text); Assert.IsTrue(result.Success); Assert.IsTrue(result.State == State.Opened); }
public void TestDeleteNotExisting() { var manager = new DocumentsRepository(); var result = manager.Delete("sda", "dsa"); Assert.IsFalse(result.Success); Assert.IsTrue(result.State == State.Deleted); }