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);
        }
Пример #3
0
        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);
        }
Пример #6
0
        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);
        }
Пример #7
0
        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);
        }
Пример #8
0
 public void TryOpenNotExisting()
 {
     var repo = new DocumentsRepository();
     var result = repo.Open("dsds", "user1");
     Assert.IsFalse(result.Success);
     Assert.IsTrue(result.State == State.Deleted);
 }
Пример #9
0
 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");
 }
Пример #10
0
        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);
 }