Exemple #1
0
        public void UniqueIdIsAssignedForANewDocument()
        {
            var document = new TestDocument();

               Guid actual;
               var isGuid = Guid.TryParse(document.Id, out actual);

               Assert.That(isGuid, Is.True);
        }
Exemple #2
0
        public void ReturnsFalseWhenOneDocumentIsNullWhenEqualityIsChecked()
        {
            var guid = Guid.NewGuid().ToString();
            var document1 = new TestDocument(guid) { Revision = "1" };

            var documentsAreEqual = document1.Equals(null);

            Assert.That(documentsAreEqual, Is.False);
        }
Exemple #3
0
        public void HashCodeIsACombinationOfTheHashcodeAndRevision()
        {
            var guid = Guid.NewGuid().ToString();
            int expectedHashCode = (guid + "1").GetHashCode();
            var document1 = new TestDocument(guid) { Revision = "1" };

            var actualHashCode = document1.GetHashCode();

            Assert.That(actualHashCode, Is.EqualTo(expectedHashCode));
        }
Exemple #4
0
        public void DocumentsWithTheSameIdAndRevisionAreEqual()
        {
            var guid = Guid.NewGuid().ToString();
            var document1 = new TestDocument(guid) {Revision = "1"};
            var document2 = new TestDocument(guid) {Revision = "1"};

            var documentsAreEqual = document1.Equals(document2);

            Assert.That(documentsAreEqual, Is.True);
        }
        public void CreateDocumentCallsSendJsonWithPutToDocumentUri()
        {
            const string expectedJson = "{\"ok\":\"true\"}";
            var testDocument = new TestDocument("someid");
            mockJsonClient.Setup(c => c.SendJsonTo(documentUri, "{\"_id\":\"someid\",\"type\":\"TestDocument\"}", "PUT")).Returns(expectedJson);

            var json = documentRepository.Create(testDocument);

            mockCouchUriBuilder.Verify(s => s.DocumentUri(testDocument.Id));
            mockJsonClient.Verify(c => c.SendJsonTo(documentUri, "{\"_id\":\"someid\",\"type\":\"TestDocument\"}", "PUT"));
            Assert.That(json, Is.EqualTo(expectedJson) );
        }
Exemple #6
0
        public void DocumentTypeIsSubClassNameForANewDocument()
        {
            var document = new TestDocument();

            Assert.That(document.DocumentType, Is.EqualTo("TestDocument"));
        }