├── lib
├── Moq.dll
├── MSpec
│ ├── Spark.dll
│ ├── Spark.pdb
│ ├── mspec.exe
│ ├── mspec.pdb
│ ├── mspec-x86.exe
│ ├── mspec-x86.pdb
│ ├── CommandLine.dll
│ ├── mspec-clr4.exe
│ ├── mspec-clr4.pdb
│ ├── mspec-x86-clr4.exe
│ ├── mspec-x86-clr4.pdb
│ ├── Newtonsoft.Json.dll
│ ├── TestDriven.Framework.dll
│ ├── Machine.Specifications.dll
│ ├── Machine.Specifications.pdb
│ ├── ThoughtWorks.Selenium.Core.dll
│ ├── ThoughtWorks.Selenium.Core.pdb
│ ├── Machine.Specifications.TDNetRunner.dll
│ ├── Machine.Specifications.TDNetRunner.pdb
│ └── Machine.Specifications.dll.tdnet
├── Symbiote.Core.dll
├── Symbiote.Core.pdb
└── Reactive
│ ├── System.CoreEx.dll
│ ├── System.Reactive.dll
│ └── System.Interactive.dll
├── .gitignore
├── tests
├── Mocks
│ └── with_mock_repository.cs
├── Serialization
│ ├── Filtering
│ │ ├── ClassC.cs
│ │ ├── ClassE.cs
│ │ ├── ClassF.cs
│ │ ├── ClassD.cs
│ │ ├── ClassB.cs
│ │ └── ClassA.cs
│ ├── with_assimilation.cs
│ ├── Test.cs
│ ├── with_single_document.cs
│ ├── with_complex_document.cs
│ ├── ComplexDocument.cs
│ ├── when_deserializing_complex_document.cs
│ ├── when_deserializing_view_result_with_documents_included.cs
│ ├── when_deserializing_complex_view.cs
│ ├── when_deserializing_view_result_and_document_excluded.cs
│ ├── with_view_result_and_no_documents.cs
│ ├── with_view_result_and_documents_included.cs
│ ├── when_trying_custom_serializer.cs
│ └── with_bulk_insert.cs
├── Caching
│ ├── with_caching_provider.cs
│ ├── with_cache_provider.cs
│ ├── when_adding_cross_reference.cs
│ ├── with_couch_cache_provider.cs
│ ├── when_associating_keys.cs
│ ├── when_invalidating_item.cs
│ └── when_getting_cache_keys.cs
├── ViewFilter
│ ├── Request.cs
│ ├── when_filtering_design_documents_from_results.cs
│ └── with_test_json.cs
├── Relax.Lucene.Tests
│ ├── Car.cs
│ ├── with_lucene.cs
│ ├── with_domain_model.cs
│ ├── Person.cs
│ ├── when_searching_against_family.cs
│ ├── with_indexed_people.cs
│ └── Properties
│ │ └── AssemblyInfo.cs
├── Commands
│ ├── ParentDoc.cs
│ ├── with_configuration.cs
│ ├── GetCommand
│ │ ├── with_get_doc_by_id_and_rev_setup.cs
│ │ ├── with_get_all_docs_paged.cs
│ │ ├── when_getting_documents_by_key_range.cs
│ │ ├── with_get_doc_by_id_setup.cs
│ │ ├── when_getting_doc_by_id_and_rev.cs
│ │ ├── when_getting_doc_by_id.cs
│ │ └── with_get_doc_by_range.cs
│ ├── GettingDocuments
│ │ ├── with_get_doc_by_id_and_rev_setup.cs
│ │ ├── with_get_all_docs_paged.cs
│ │ ├── when_getting_documents_by_key_range.cs
│ │ ├── with_get_poco_by_id_setup.cs
│ │ ├── when_getting_doc_by_id_timed.cs
│ │ ├── when_getting_poco_by_id_timed.cs
│ │ ├── with_get_doc_by_id_setup.cs
│ │ ├── when_getting_all_pocos_by_ids_timed.cs
│ │ ├── when_getting_doc_by_id.cs
│ │ ├── when_getting_doc_by_id_and_rev.cs
│ │ ├── with_get_all_pocos_by_ids.cs
│ │ ├── when_getting_poco_by_id.cs
│ │ └── with_get_doc_by_range.cs
│ ├── with_command_factory.cs
│ ├── SaveCommand
│ │ ├── with_poco_persistence.cs
│ │ ├── with_poco_list_persistence.cs
│ │ ├── with_poco_list.cs
│ │ ├── with_serialized_bulk_persist.cs
│ │ ├── with_document_list.cs
│ │ ├── with_single_parent_document.cs
│ │ ├── when_saving_list_to_database.cs
│ │ ├── when_saving_poco_to_database.cs
│ │ └── when_persisting_list_with_breaking_documents.cs
│ ├── TestDoc.cs
│ ├── DeletingAttachments
│ │ └── when_deleting_attachment.cs
│ ├── SavingAttachments
│ │ ├── when_saving_document_attachment.cs
│ │ └── with_save_attachment_command.cs
│ ├── GettingAttachments
│ │ ├── when_getting_attachment.cs
│ │ └── with_get_attachment_command.cs
│ ├── with_mock_http_action.cs
│ └── FromView
│ │ ├── when_getting_from_view.cs
│ │ └── with_get_from_view_command.cs
├── Configuration
│ ├── with_couch_configuration.cs
│ ├── TestDatabaseResolver.cs
│ ├── with_couch_configurator.cs
│ ├── when_using_defaults.cs
│ ├── when_using_caching_with_no_expiration.cs
│ └── when_using_caching_with_time_limit.cs
├── URI
│ ├── with_basic_uri.cs
│ ├── when_creating_baseline_uri.cs
│ ├── with_basic_uri_without_db.cs
│ ├── when_retrieving_by_key.cs
│ ├── when_grouping.cs
│ ├── when_stale_records_are_ok.cs
│ ├── when_bulk_inserting.cs
│ ├── when_turning_off_reduce.cs
│ ├── when_using_attachments.cs
│ ├── when_compacting_database.cs
│ ├── when_retrieving_by_list_all.cs
│ ├── when_retrieving_by_view.cs
│ ├── when_cleaning_up_view.cs
│ ├── when_grouping_with_level.cs
│ ├── when_compacting_view.cs
│ ├── when_setting_up_replication.cs
│ ├── when_inclusive_end_in_view.cs
│ ├── when_retrieving_by_key_and_revision.cs
│ ├── when_retrieving_design_document.cs
│ ├── when_retrieving_by_range.cs
│ ├── when_getting_attachment_including_revision.cs
│ ├── when_retrieving_by_list_all_with_descending.cs
│ ├── when_retrieving_changes_continuously.cs
│ ├── when_retrieving_changes_via_longpolling.cs
│ ├── when_retrieving_by_list_all_with_descending_and_skip.cs
│ ├── when_retrieving_by_list_all_with_descending_and_limit.cs
│ ├── when_retrieving_by_named_list_with_descending_and_skip.cs
│ ├── when_retrieving_changes_continuously_including_documents.cs
│ ├── Encoding
│ │ ├── with_test_json.cs
│ │ ├── when_encoding_json_for_url.cs
│ │ └── UrlEncoder.cs
│ ├── ViewQuery
│ │ └── with_couch_uri.cs
│ ├── when_using_start_key_only.cs
│ └── when_using_end_key_only.cs
├── Repository
│ ├── with_test_document.cs
│ ├── when_saving_a_document.cs
│ ├── when_deleting_document_by_id.cs
│ ├── when_deleting_document_by_id_and_rev.cs
│ ├── with_delete_document_command.cs
│ ├── when_deleting_attachment.cs
│ ├── when_deleting_document.cs
│ ├── when_saving_documents.cs
│ ├── with_document_repository.cs
│ ├── when_getting_from_view.cs
│ ├── when_getting_a_document_by_key.cs
│ ├── when_getting_a_document_by_key_and_rev.cs
│ ├── when_getting_attachment.cs
│ ├── when_getting_all_documents.cs
│ ├── when_getting_all_docuemnts.cs
│ ├── when_getting_all_documents_with_paging.cs
│ ├── when_getting_all_docuemnts_with_paging.cs
│ ├── when_getting_documents_by_id.cs
│ ├── when_getting_documents_by_range.cs
│ └── with_delete_document_command_by_id_and_rev.cs
├── SimpleDocument.cs
├── Document
│ ├── when_using_custom_key.cs
│ ├── Driver.cs
│ ├── with_custom_document_complex_key.cs
│ ├── when_serializing_design_document.cs
│ ├── when_using_custom_complex_key.cs
│ ├── Person.cs
│ ├── with_custom_document_simple_key.cs
│ └── with_design_document.cs
├── Server
│ ├── with_create_database_command.cs
│ ├── when_compacting_db.cs
│ ├── when_cleaning_up_views.cs
│ ├── with_create_delete_database_command.cs
│ ├── when_compacting_view.cs
│ ├── with_check_database_exists_command.cs
│ ├── with_db_compaction.cs
│ ├── when_copying_from_any_database.cs
│ ├── when_copying_from_local_database.cs
│ ├── with_view_cleanup_command.cs
│ ├── with_view_compaction.cs
│ ├── when_starting_replication_from_any_database.cs
│ ├── when_starting_replication_from_local_database.cs
│ ├── with_list_databases_command.cs
│ ├── when_creating_database.cs
│ ├── when_deleteing_database.cs
│ ├── when_checking_database_existence.cs
│ ├── when_getting_list_of_databases.cs
│ ├── with_couch_server.cs
│ ├── with_copy_replication.cs
│ └── with_continuous_replication.cs
├── with_configuration.cs
├── TestDocument.cs
├── Assimilation
│ ├── when_assimilating_without_caching.cs
│ └── when_assimilating_with_caching.cs
└── Properties
│ └── AssemblyInfo.cs
├── demo
├── RelaxDemo
│ ├── app.config
│ ├── DatabaseDeleter.cs
│ ├── DocumentRetriever.cs
│ ├── BulkDataLoader.cs
│ ├── PagingDataLoader.cs
│ ├── DocumentSaver.cs
│ ├── LuceneSearchClient.cs
│ ├── ChangeWatcher.cs
│ ├── TestDocument.cs
│ ├── BulkDataPersister.cs
│ └── Properties
│ │ └── AssemblyInfo.cs
└── Relax.Overflow
│ ├── Comment.cs
│ ├── Users.cs
│ └── Properties
│ └── AssemblyInfo.cs
└── src
└── Relax
├── Config
├── RelaxConfigurationException.cs
├── CouchConfigurationException.cs
└── ICouchConfiguration.cs
├── IRelaxQueryService.cs
├── RelaxException.cs
├── Impl
├── Serialization
│ ├── DocumentConventions.cs
│ ├── IValueProviderCache.cs
│ ├── IProvideDocumentMetadata.cs
│ ├── ISerializationProvider.cs
│ └── DocumentMetadataProvider.cs
├── Json
│ ├── KeyList.cs
│ ├── SaveResponse.cs
│ └── ViewResult.cs
├── Feed.cs
├── Model
│ ├── IHaveDocumentId.cs
│ ├── IHaveDocumentRevision.cs
│ ├── IHaveAttachments.cs
│ ├── DesignView.cs
│ ├── JSONDocument.cs
│ ├── DocumentMetadata.cs
│ └── DesignDocument.cs
├── Commands
│ ├── ISaveDocument.cs
│ ├── ISaveDocuments.cs
│ └── CouchQueryCommand.cs
├── IDocumentSearchProvider.cs
├── Cache
│ ├── IKeyAssociationManager.cs
│ └── ICacheKeyBuilder.cs
├── Repository
│ └── DocumentRepository.cs
├── Http
│ └── IHttpAction.cs
└── Persistence
│ └── KeyValueStore.cs
├── IResolveDatabaseNames.cs
├── ICouchDocument.cs
├── ChangeRecord.cs
├── CouchAssimilation.cs
└── ICouchServer.cs
/lib/Moq.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code-attic/Relax/HEAD/lib/Moq.dll
--------------------------------------------------------------------------------
/lib/MSpec/Spark.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code-attic/Relax/HEAD/lib/MSpec/Spark.dll
--------------------------------------------------------------------------------
/lib/MSpec/Spark.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code-attic/Relax/HEAD/lib/MSpec/Spark.pdb
--------------------------------------------------------------------------------
/lib/MSpec/mspec.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code-attic/Relax/HEAD/lib/MSpec/mspec.exe
--------------------------------------------------------------------------------
/lib/MSpec/mspec.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code-attic/Relax/HEAD/lib/MSpec/mspec.pdb
--------------------------------------------------------------------------------
/lib/MSpec/mspec-x86.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code-attic/Relax/HEAD/lib/MSpec/mspec-x86.exe
--------------------------------------------------------------------------------
/lib/MSpec/mspec-x86.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code-attic/Relax/HEAD/lib/MSpec/mspec-x86.pdb
--------------------------------------------------------------------------------
/lib/Symbiote.Core.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code-attic/Relax/HEAD/lib/Symbiote.Core.dll
--------------------------------------------------------------------------------
/lib/Symbiote.Core.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code-attic/Relax/HEAD/lib/Symbiote.Core.pdb
--------------------------------------------------------------------------------
/lib/MSpec/CommandLine.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code-attic/Relax/HEAD/lib/MSpec/CommandLine.dll
--------------------------------------------------------------------------------
/lib/MSpec/mspec-clr4.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code-attic/Relax/HEAD/lib/MSpec/mspec-clr4.exe
--------------------------------------------------------------------------------
/lib/MSpec/mspec-clr4.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code-attic/Relax/HEAD/lib/MSpec/mspec-clr4.pdb
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | _ReSharper.*
2 | Debug*
3 | Release*
4 | bin*
5 | obj*
6 | *.cache
7 | *.user
8 | *.suo
9 | *~HEAD
--------------------------------------------------------------------------------
/lib/MSpec/mspec-x86-clr4.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code-attic/Relax/HEAD/lib/MSpec/mspec-x86-clr4.exe
--------------------------------------------------------------------------------
/lib/MSpec/mspec-x86-clr4.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code-attic/Relax/HEAD/lib/MSpec/mspec-x86-clr4.pdb
--------------------------------------------------------------------------------
/lib/MSpec/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code-attic/Relax/HEAD/lib/MSpec/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/lib/Reactive/System.CoreEx.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code-attic/Relax/HEAD/lib/Reactive/System.CoreEx.dll
--------------------------------------------------------------------------------
/lib/Reactive/System.Reactive.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code-attic/Relax/HEAD/lib/Reactive/System.Reactive.dll
--------------------------------------------------------------------------------
/lib/MSpec/TestDriven.Framework.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code-attic/Relax/HEAD/lib/MSpec/TestDriven.Framework.dll
--------------------------------------------------------------------------------
/lib/Reactive/System.Interactive.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code-attic/Relax/HEAD/lib/Reactive/System.Interactive.dll
--------------------------------------------------------------------------------
/lib/MSpec/Machine.Specifications.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code-attic/Relax/HEAD/lib/MSpec/Machine.Specifications.dll
--------------------------------------------------------------------------------
/lib/MSpec/Machine.Specifications.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code-attic/Relax/HEAD/lib/MSpec/Machine.Specifications.pdb
--------------------------------------------------------------------------------
/lib/MSpec/ThoughtWorks.Selenium.Core.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code-attic/Relax/HEAD/lib/MSpec/ThoughtWorks.Selenium.Core.dll
--------------------------------------------------------------------------------
/lib/MSpec/ThoughtWorks.Selenium.Core.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code-attic/Relax/HEAD/lib/MSpec/ThoughtWorks.Selenium.Core.pdb
--------------------------------------------------------------------------------
/tests/Mocks/with_mock_repository.cs:
--------------------------------------------------------------------------------
1 | namespace Relax.Tests.Mocks
2 | {
3 | class with_mock_repository
4 | {
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/lib/MSpec/Machine.Specifications.TDNetRunner.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code-attic/Relax/HEAD/lib/MSpec/Machine.Specifications.TDNetRunner.dll
--------------------------------------------------------------------------------
/lib/MSpec/Machine.Specifications.TDNetRunner.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code-attic/Relax/HEAD/lib/MSpec/Machine.Specifications.TDNetRunner.pdb
--------------------------------------------------------------------------------
/tests/Serialization/Filtering/ClassC.cs:
--------------------------------------------------------------------------------
1 | namespace Relax.Tests.Serialization.Filtering
2 | {
3 | public class ClassC : ClassB
4 | {
5 | }
6 | }
--------------------------------------------------------------------------------
/tests/Caching/with_caching_provider.cs:
--------------------------------------------------------------------------------
1 | namespace Relax.Tests.Caching
2 | {
3 | public abstract class with_caching_provider
4 | {
5 |
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/tests/Serialization/with_assimilation.cs:
--------------------------------------------------------------------------------
1 | namespace Relax.Tests.Serialization
2 | {
3 | public abstract class with_assimilation
4 | {
5 |
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/tests/Serialization/Filtering/ClassE.cs:
--------------------------------------------------------------------------------
1 | namespace Relax.Tests.Serialization.Filtering
2 | {
3 | public class ClassE
4 | {
5 | public string Message { get; set; }
6 | }
7 | }
--------------------------------------------------------------------------------
/tests/Serialization/Filtering/ClassF.cs:
--------------------------------------------------------------------------------
1 | namespace Relax.Tests.Serialization.Filtering
2 | {
3 | public class ClassF
4 | {
5 | public string Message { get; set; }
6 | }
7 | }
--------------------------------------------------------------------------------
/tests/Serialization/Filtering/ClassD.cs:
--------------------------------------------------------------------------------
1 | namespace Relax.Tests.Serialization.Filtering
2 | {
3 | public class ClassD : ClassC
4 | {
5 | public string Message { get; set; }
6 | }
7 | }
--------------------------------------------------------------------------------
/tests/Serialization/Filtering/ClassB.cs:
--------------------------------------------------------------------------------
1 | namespace Relax.Tests.Serialization.Filtering
2 | {
3 | public class ClassB : CouchDocument
4 | {
5 | public string Message { get; set; }
6 | }
7 | }
--------------------------------------------------------------------------------
/tests/Serialization/Test.cs:
--------------------------------------------------------------------------------
1 | namespace Relax.Tests.Serialization
2 | {
3 | public class Test
4 | {
5 | public string Id { get; set; }
6 | public string Rev { get; set; }
7 | }
8 | }
--------------------------------------------------------------------------------
/tests/ViewFilter/Request.cs:
--------------------------------------------------------------------------------
1 | namespace Relax.Tests.ViewFilter
2 | {
3 | public class Request : CouchDocument
4 | {
5 | public string Message { get; set; }
6 |
7 | public Request()
8 | {
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/demo/RelaxDemo/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/tests/Relax.Lucene.Tests/Car.cs:
--------------------------------------------------------------------------------
1 | namespace Relax.Lucene.Tests
2 | {
3 | public class Car : CouchDocument
4 | {
5 | public virtual string Make { get; set; }
6 | public virtual string Model { get; set; }
7 | public virtual int Year { get; set; }
8 | }
9 | }
--------------------------------------------------------------------------------
/tests/Commands/ParentDoc.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Relax.Tests.Commands
4 | {
5 | public class ParentDoc : CouchDocument
6 | {
7 | public virtual string Message { get; set; }
8 | public virtual List Children { get; set; }
9 | }
10 | }
--------------------------------------------------------------------------------
/lib/MSpec/Machine.Specifications.dll.tdnet:
--------------------------------------------------------------------------------
1 |
2 | Machine.Specifications 0.4.0-no SHA
3 | Machine.Specifications.TDNetRunner.dll
4 | Machine.Specifications.TDNetRunner.SpecificationRunner
5 |
6 |
--------------------------------------------------------------------------------
/src/Relax/Config/RelaxConfigurationException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Relax.Config
4 | {
5 | public class RelaxConfigurationException : Exception
6 | {
7 | public RelaxConfigurationException(string message) : base(message)
8 | {
9 |
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/src/Relax/IRelaxQueryService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Relax
7 | {
8 | public interface IRelaxQueryService
9 | {
10 | string[] GetDocumentIdsForQuery(string database, string luceneQuery);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/tests/Configuration/with_couch_configuration.cs:
--------------------------------------------------------------------------------
1 | using Relax.Config;
2 |
3 | namespace Relax.Tests.Configuration
4 | {
5 | public abstract class with_couch_configuration : with_couch_configurator
6 | {
7 | protected static ICouchConfiguration configuration { get { return configurator.Configuration; } }
8 | }
9 | }
--------------------------------------------------------------------------------
/tests/URI/with_basic_uri.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Relax.Impl.Http;
3 |
4 | namespace Relax.Tests.URI
5 | {
6 | public abstract class with_basic_uri
7 | {
8 | protected static CouchUri uri;
9 | private Establish context = () => uri = CouchUri.Build("http", "localhost", 5984, "relax");
10 | }
11 | }
--------------------------------------------------------------------------------
/tests/URI/when_creating_baseline_uri.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.URI
4 | {
5 | [Subject("Couch URI")]
6 | public class when_creating_baseline_uri : with_basic_uri
7 | {
8 | private It should_have_proper_format = () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax");
9 | }
10 | }
--------------------------------------------------------------------------------
/tests/URI/with_basic_uri_without_db.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Relax.Impl.Http;
3 |
4 | namespace Relax.Tests.URI
5 | {
6 | public abstract class with_basic_uri_without_db
7 | {
8 | protected static CouchUri uri;
9 | private Establish context = () => uri = CouchUri.Build("http", "localhost", 5984);
10 | }
11 | }
--------------------------------------------------------------------------------
/tests/Repository/with_test_document.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.Repository
4 | {
5 | public abstract class with_test_document : with_configuration
6 | {
7 | protected static TestDocument document;
8 | private Establish context = () => { document = new TestDocument() {Message = "hi"}; };
9 | }
10 | }
--------------------------------------------------------------------------------
/tests/SimpleDocument.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Relax.Tests
4 | {
5 | public class SimpleDocument : CouchDocument
6 | {
7 | public virtual string Message { get; set; }
8 | public virtual DateTime CreatedOn { get; set; }
9 |
10 | public SimpleDocument()
11 | {
12 | CreatedOn = DateTime.Now;
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/src/Relax/RelaxException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Relax
4 | {
5 | public class RelaxException : Exception
6 | {
7 | public RelaxException(string message) : base(message)
8 | {
9 | }
10 |
11 | public RelaxException(string message, Exception innerException) : base(message, innerException)
12 | {
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/tests/Configuration/TestDatabaseResolver.cs:
--------------------------------------------------------------------------------
1 | namespace Relax.Tests.Configuration
2 | {
3 | public class TestDatabaseResolver : IResolveDatabaseNames
4 | {
5 | public string GetDatabaseNameFor()
6 | {
7 | if (typeof(TModel).Equals(typeof(object)))
8 | return null;
9 | return typeof (TModel).Name.ToLower();
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/tests/URI/when_retrieving_by_key.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.URI
4 | {
5 | [Subject("Couch URI")]
6 | public class when_retrieving_by_key : with_basic_uri
7 | {
8 | private Because of = () => uri.Id("id");
9 |
10 | private It should_append_id_to_uri
11 | = () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax/id");
12 | }
13 | }
--------------------------------------------------------------------------------
/tests/Commands/with_configuration.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Symbiote.Core;
3 |
4 | namespace Relax.Tests.Commands
5 | {
6 | public abstract class with_configuration
7 | {
8 | private Establish context = () =>
9 | {
10 | Assimilate.Initialize();
11 | };
12 | }
13 | }
--------------------------------------------------------------------------------
/tests/URI/when_grouping.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.URI
4 | {
5 | [Subject("Couch URI")]
6 | public class when_grouping : with_basic_uri
7 | {
8 | private Because of = () => uri.Group();
9 |
10 | private It should_append_group_level_1
11 | = () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax?group=true&group_level=1");
12 | }
13 | }
--------------------------------------------------------------------------------
/tests/URI/when_stale_records_are_ok.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.URI
4 | {
5 | [Subject("Couch URI")]
6 | public class when_stale_records_are_ok : with_basic_uri
7 | {
8 | private Because of = () => uri.StaleOk();
9 |
10 | private It should_append_stale
11 | = () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax?stale=ok");
12 | }
13 | }
--------------------------------------------------------------------------------
/demo/RelaxDemo/DatabaseDeleter.cs:
--------------------------------------------------------------------------------
1 | using Relax;
2 |
3 | namespace RelaxDemo
4 | {
5 | public class DatabaseDeleter
6 | {
7 | private ICouchServer _couch;
8 |
9 | public void Nuke()
10 | {
11 | _couch.DeleteDatabase();
12 | }
13 |
14 | public DatabaseDeleter(ICouchServer couch)
15 | {
16 | _couch = couch;
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/tests/URI/when_bulk_inserting.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.URI
4 | {
5 | [Subject("Couch URI")]
6 | public class when_bulk_inserting : with_basic_uri
7 | {
8 | private Because of = () => uri.BulkInsert();
9 |
10 | private It should_append_bulk_docs
11 | = () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax/_bulk_docs");
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/tests/Serialization/Filtering/ClassA.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Relax.Tests.Serialization.Filtering
4 | {
5 | public class ClassA : CouchDocument
6 | {
7 | public ClassB B { get; set; }
8 | public List Cs { get; set; }
9 | public List Ds { get; set; }
10 | public ClassE E { get; set; }
11 | public List Fs { get; set; }
12 | }
13 | }
--------------------------------------------------------------------------------
/tests/URI/when_turning_off_reduce.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.URI
4 | {
5 | [Subject("Couch URI")]
6 | public class when_turning_off_reduce : with_basic_uri
7 | {
8 | private Because of = () => uri.NoReduce();
9 |
10 | private It should_append_reduce_false
11 | = () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax?reduce=false");
12 | }
13 | }
--------------------------------------------------------------------------------
/tests/URI/when_using_attachments.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.URI
4 | {
5 | [Subject("Couch URI")]
6 | public class when_using_attachments : with_basic_uri
7 | {
8 | private Because of = () => uri.Attachment("foo.txt");
9 |
10 | private It should_append_attachment
11 | = () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax/foo.txt");
12 | }
13 | }
--------------------------------------------------------------------------------
/src/Relax/Impl/Serialization/DocumentConventions.cs:
--------------------------------------------------------------------------------
1 | namespace Relax.Impl.Serialization
2 | {
3 | public class DocumentConventions
4 | {
5 | public string IdPropertyName { get; set; }
6 | public string RevisionPropertyName { get; set; }
7 |
8 | public DocumentConventions()
9 | {
10 | IdPropertyName = "Id";
11 | RevisionPropertyName = "Rev";
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/tests/URI/when_compacting_database.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.URI
4 | {
5 | [Subject("Couch URI")]
6 | public class when_compacting_database : with_basic_uri
7 | {
8 | private Because of = () => { uri.Compact(); };
9 |
10 | private It should_append_compact_to_uri =
11 | () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax/_compact");
12 | }
13 | }
--------------------------------------------------------------------------------
/tests/URI/when_retrieving_by_list_all.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.URI
4 | {
5 | [Subject("Couch URI")]
6 | public class when_retrieving_by_list_all : with_basic_uri
7 | {
8 | private Because of = () => uri.ListAll();
9 |
10 | private It should_append_all_docs_to_uri
11 | = () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax/_all_docs");
12 | }
13 | }
--------------------------------------------------------------------------------
/tests/URI/when_retrieving_by_view.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.URI
4 | {
5 | [Subject("Couch URI")]
6 | public class when_retrieving_by_view : with_basic_uri
7 | {
8 | private Because of = () => uri.View("myView");
9 |
10 | private It should_append_view_name_to_uri
11 | = () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax/_view/myView");
12 | }
13 | }
--------------------------------------------------------------------------------
/tests/URI/when_cleaning_up_view.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.URI
4 | {
5 | [Subject("Couch URI")]
6 | public class when_cleaning_up_view : with_basic_uri
7 | {
8 | private Because of = () => { uri.CleanupViews(); };
9 |
10 | private It should_append_view_cleanup_to_uri =
11 | () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax/_view_cleanup");
12 | }
13 | }
--------------------------------------------------------------------------------
/tests/URI/when_grouping_with_level.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.URI
4 | {
5 | [Subject("Couch URI")]
6 | public class when_grouping_with_level : with_basic_uri
7 | {
8 | private Because of = () => uri.Group(2);
9 |
10 | private It should_append_group_level_2
11 | = () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax?group=true&group_level=2");
12 | }
13 | }
--------------------------------------------------------------------------------
/tests/URI/when_compacting_view.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.URI
4 | {
5 | [Subject("Couch URI")]
6 | public class when_compacting_view : with_basic_uri
7 | {
8 | private Because of = () => { uri.CompactView("testView"); };
9 |
10 | private It should_append_compact_to_uri =
11 | () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax/_compact/testView");
12 | }
13 | }
--------------------------------------------------------------------------------
/tests/URI/when_setting_up_replication.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.URI
4 | {
5 | [Subject("Couch URI")]
6 | public class when_setting_up_replication : with_basic_uri_without_db
7 | {
8 | private Because of = () => { uri.Replicate(); };
9 |
10 | private It should_append_compact_to_uri =
11 | () => uri.ToString().ShouldEqual(@"http://localhost:5984/_replicate");
12 | }
13 | }
--------------------------------------------------------------------------------
/tests/Document/when_using_custom_key.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Symbiote.Core.Extensions;
3 |
4 | namespace Relax.Tests.Document
5 | {
6 | [Subject("custom document")]
7 | public class when_using_custom_key : with_custom_document_simple_key
8 | {
9 | private It should_have_expected_key = () => person.DocumentId.ShouldEqual("{0}, {1} born {2}".AsFormat(person.LastName, person.FirstName, person.DateOfBirth));
10 | }
11 | }
--------------------------------------------------------------------------------
/tests/URI/when_inclusive_end_in_view.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.URI
4 | {
5 | [Subject("Couch URI")]
6 | public class when_inclusive_end_in_view : with_basic_uri
7 | {
8 | private Because of = () => uri.NonInclusiveRange();
9 |
10 | private It should_append_inclusive_end_true
11 | = () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax?inclusive_end=false");
12 | }
13 | }
--------------------------------------------------------------------------------
/demo/Relax.Overflow/Comment.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Relax.Overflow
4 | {
5 | public class Comment
6 | {
7 | public virtual long Id { get; set; }
8 | public virtual long PostId { get; set; }
9 | public virtual decimal Score { get; set; }
10 | public virtual string Text { get; set; }
11 | public virtual DateTime CreationDate { get; set; }
12 | public virtual long UserId { get; set; }
13 | }
14 | }
--------------------------------------------------------------------------------
/tests/URI/when_retrieving_by_key_and_revision.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.URI
4 | {
5 | [Subject("Couch URI")]
6 | public class when_retrieving_by_key_and_revision : with_basic_uri
7 | {
8 | private Because of = () => uri.IdAndRev("id", 2);
9 |
10 | private It should_append_key_and_rev_to_uri
11 | = () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax/id?rev=2");
12 | }
13 | }
--------------------------------------------------------------------------------
/tests/URI/when_retrieving_design_document.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.URI
4 | {
5 | [Subject("Couch URI")]
6 | public class when_retrieving_design_document : with_basic_uri
7 | {
8 | private Because of = () => uri.Design("myDesign");
9 |
10 | private It should_append_design_document_to_uri
11 | = () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax/_design/myDesign");
12 | }
13 | }
--------------------------------------------------------------------------------
/tests/Serialization/with_single_document.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.Serialization
4 | {
5 | public abstract class with_single_document
6 | {
7 | protected static string json;
8 |
9 | private Establish context = () =>
10 | {
11 | json = @"{ _id:""test"", _rev:""10""}";
12 | };
13 | }
14 | }
--------------------------------------------------------------------------------
/tests/URI/when_retrieving_by_range.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.URI
4 | {
5 | [Subject("Couch URI")]
6 | public class when_retrieving_by_range : with_basic_uri
7 | {
8 | private Because of = () => uri.ByRange("id1", "id10");
9 |
10 | private It should_append_start_and_end_keys_to_uri
11 | = () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax?startkey=""id1""&endkey=""id10""");
12 | }
13 | }
--------------------------------------------------------------------------------
/demo/RelaxDemo/DocumentRetriever.cs:
--------------------------------------------------------------------------------
1 | using Relax;
2 |
3 | namespace RelaxDemo
4 | {
5 | public class DocumentRetriever
6 | {
7 | private IDocumentRepository _couch;
8 |
9 | public TestDocument GetById(object id, string rev)
10 | {
11 | return _couch.Get(id, rev);
12 | }
13 |
14 | public DocumentRetriever(IDocumentRepository couch)
15 | {
16 | _couch = couch;
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/tests/Commands/GetCommand/with_get_doc_by_id_and_rev_setup.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.Commands
4 | {
5 | public abstract class with_get_doc_by_id_and_rev_setup : with_get_doc_by_id_setup
6 | {
7 | private Establish context = () =>
8 | {
9 | url = @"http://localhost:5984/relax/1?rev=1";
10 | };
11 | }
12 | }
--------------------------------------------------------------------------------
/tests/Commands/GetCommand/with_get_all_docs_paged.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.Commands
4 | {
5 | public abstract class with_get_all_docs_paged : with_get_all_docs
6 | {
7 | private Establish context = () =>
8 | {
9 | url = @"http://localhost:5984/relax/_all_docs?include_docs=true&skip=4&limit=2";
10 | };
11 | }
12 | }
--------------------------------------------------------------------------------
/demo/RelaxDemo/BulkDataLoader.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Relax;
3 |
4 | namespace RelaxDemo
5 | {
6 | public class BulkDataLoader
7 | {
8 | private IDocumentRepository _couch;
9 |
10 | public IList GetAllDocuments()
11 | {
12 | return _couch.GetAll();
13 | }
14 |
15 | public BulkDataLoader(IDocumentRepository couch)
16 | {
17 | _couch = couch;
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/tests/Commands/GettingDocuments/with_get_doc_by_id_and_rev_setup.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.Commands.GettingDocuments
4 | {
5 | public abstract class with_get_doc_by_id_and_rev_setup : with_get_doc_by_id_setup
6 | {
7 | private Establish context = () =>
8 | {
9 | url = @"http://localhost:5984/relax/1?rev=1";
10 | };
11 | }
12 | }
--------------------------------------------------------------------------------
/tests/URI/when_getting_attachment_including_revision.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.URI
4 | {
5 | [Subject("Couch URI")]
6 | public class when_getting_attachment_including_revision : with_basic_uri
7 | {
8 | private Because of = () => uri.Id("id").Attachment("foo.txt").Revision("1-A");
9 |
10 | private It should_append_attachment
11 | = () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax/id/foo.txt?rev=1-A");
12 | }
13 | }
--------------------------------------------------------------------------------
/tests/URI/when_retrieving_by_list_all_with_descending.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.URI
4 | {
5 | [Subject("Couch URI")]
6 | public class when_retrieving_by_list_all_with_descending : with_basic_uri
7 | {
8 | private Because of = () => uri.ListAll().Descending();
9 |
10 | private It should_append_all_docs_and_descending_to_uri
11 | = () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax/_all_docs?descending=true");
12 | }
13 | }
--------------------------------------------------------------------------------
/tests/Commands/GettingDocuments/with_get_all_docs_paged.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.Commands.GettingDocuments
4 | {
5 | public abstract class with_get_all_docs_paged : with_get_all_docs
6 | {
7 | private Establish context = () =>
8 | {
9 | url = @"http://localhost:5984/relax/_all_docs?include_docs=true&skip=4&limit=2";
10 | };
11 | }
12 | }
--------------------------------------------------------------------------------
/tests/URI/when_retrieving_changes_continuously.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Relax.Impl;
3 |
4 | namespace Relax.Tests.URI
5 | {
6 | [Subject("Couch URI")]
7 | public class when_retrieving_changes_continuously : with_basic_uri
8 | {
9 | private Because of = () => uri.Changes(Feed.Continuous, 10);
10 |
11 | private It should_append_feed_and_since_to_uri
12 | = () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax/_changes?feed=continuous&since=10");
13 | }
14 | }
--------------------------------------------------------------------------------
/tests/URI/when_retrieving_changes_via_longpolling.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Relax.Impl;
3 |
4 | namespace Relax.Tests.URI
5 | {
6 | [Subject("Couch URI")]
7 | public class when_retrieving_changes_via_longpolling : with_basic_uri
8 | {
9 | private Because of = () => uri.Changes(Feed.LongPolling, 10);
10 |
11 | private It should_append_feed_and_since_to_uri
12 | = () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax/_changes?feed=longpoll&since=10");
13 | }
14 | }
--------------------------------------------------------------------------------
/demo/RelaxDemo/PagingDataLoader.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Relax;
3 |
4 | namespace RelaxDemo
5 | {
6 | public class PagingDataLoader
7 | {
8 | private IDocumentRepository _couch;
9 | private int _page = 0;
10 |
11 | public IList GetNext3Documents()
12 | {
13 | return _couch.GetAll(3, ++_page);
14 | }
15 |
16 | public PagingDataLoader(IDocumentRepository couch)
17 | {
18 | _couch = couch;
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/tests/URI/when_retrieving_by_list_all_with_descending_and_skip.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.URI
4 | {
5 | [Subject("Couch URI")]
6 | public class when_retrieving_by_list_all_with_descending_and_skip : with_basic_uri
7 | {
8 | private Because of = () => uri.ListAll().Descending().Skip(5);
9 |
10 | private It should_append_all_docs_and_descending_and_skip_to_uri
11 | = () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax/_all_docs?descending=true&skip=5");
12 | }
13 | }
--------------------------------------------------------------------------------
/tests/URI/when_retrieving_by_list_all_with_descending_and_limit.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.URI
4 | {
5 | [Subject("Couch URI")]
6 | public class when_retrieving_by_list_all_with_descending_and_limit : with_basic_uri
7 | {
8 | private Because of = () => uri.ListAll().Descending().Limit(100);
9 |
10 | private It should_append_all_docs_and_descending_and_limit_to_uri
11 | = () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax/_all_docs?descending=true&limit=100");
12 | }
13 | }
--------------------------------------------------------------------------------
/tests/URI/when_retrieving_by_named_list_with_descending_and_skip.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.URI
4 | {
5 | [Subject("Couch URI")]
6 | public class when_retrieving_by_named_list_with_descending_and_skip : with_basic_uri
7 | {
8 | private Because of = () => uri.List("myList").Descending().Skip(5);
9 |
10 | private It should_append_named_list_and_descending_and_skip_to_uri
11 | = () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax/_list/myList?descending=true&skip=5");
12 | }
13 | }
--------------------------------------------------------------------------------
/tests/Serialization/with_complex_document.cs:
--------------------------------------------------------------------------------
1 | namespace Relax.Tests.Serialization
2 | {
3 | public class with_complex_document
4 | {
5 | protected static string json =
6 | @"{
7 | ""_id"": ""0b29aa9a-589e-467e-869b-864968aa9532"",
8 | ""_rev"": ""1-39759d4fdfa5e162acec9551b741c82e"",
9 | ""$id"": ""7"",
10 | ""$type"": ""Relax.Tests.Serialization.ComplexDocument, Relax.Tests"",
11 | ""Message"": ""Document 3"",
12 | ""Time"": ""2010-06-02T14:07:35.2683188-05:00"",
13 | ""$doc_type"": ""ComplexDocument""
14 | }";
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/tests/Commands/with_command_factory.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Relax.Impl.Commands;
3 | using Symbiote.Core;
4 |
5 | namespace Relax.Tests.Commands
6 | {
7 | public abstract class with_command_factory : with_mock_http_action
8 | {
9 | protected static CouchCommandFactory factory;
10 |
11 | private Establish context = () =>
12 | {
13 | factory = Assimilate.GetInstanceOf();
14 | };
15 | }
16 | }
--------------------------------------------------------------------------------
/tests/Document/Driver.cs:
--------------------------------------------------------------------------------
1 | using Relax.Impl.Model;
2 |
3 | namespace Relax.Tests.Document
4 | {
5 | public class Driver : ComplexCouchDocument
6 | {
7 | public virtual Person Person { get; set; }
8 | public virtual string LicenseNumber { get; set; }
9 |
10 | protected void Init()
11 | {
12 | KeyGetter(x => x.Person);
13 | KeySetter((x,k) => x.Person = k);
14 | }
15 |
16 | public Driver(Person person)
17 | {
18 | Person = person;
19 | Init();
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/tests/Document/with_custom_document_complex_key.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Symbiote.Core;
3 |
4 | namespace Relax.Tests.Document
5 | {
6 | public class with_custom_document_complex_key : with_custom_document_simple_key
7 | {
8 | protected static Driver driver;
9 |
10 | private Establish context = () =>
11 | {
12 | Assimilate.Initialize();
13 | driver = new Driver(person);
14 | };
15 | }
16 | }
--------------------------------------------------------------------------------
/tests/Document/when_serializing_design_document.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Symbiote.Core.Serialization;
3 |
4 | namespace Relax.Tests.Document
5 | {
6 | public class when_serializing_design_document : with_design_document
7 | {
8 | protected static string json;
9 |
10 | private Because of = () =>
11 | {
12 | json = doc.ToJson(false);
13 | };
14 |
15 | private It should_not_be_empty = () =>
16 | json.ShouldNotBeEmpty();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/tests/URI/when_retrieving_changes_continuously_including_documents.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Relax.Impl;
3 |
4 | namespace Relax.Tests.URI
5 | {
6 | [Subject("Couch URI")]
7 | public class when_retrieving_changes_continuously_including_documents : with_basic_uri
8 | {
9 | private Because of = () => uri.Changes(Feed.Continuous, 10).IncludeDocuments();
10 |
11 | private It should_append_feed_and_since_to_uri
12 | = () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax/_changes?feed=continuous&since=10&include_docs=true");
13 | }
14 | }
--------------------------------------------------------------------------------
/tests/Configuration/with_couch_configurator.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Relax.Config;
3 | using Symbiote.Core;
4 |
5 | namespace Relax.Tests.Configuration
6 | {
7 | public abstract class with_couch_configurator
8 | {
9 | protected static CouchConfigurator configurator;
10 | private Establish context = () =>
11 | {
12 | configurator = new CouchConfigurator();
13 | Assimilate.Initialize();
14 | };
15 | }
16 | }
--------------------------------------------------------------------------------
/tests/Commands/SaveCommand/with_poco_persistence.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Relax.Impl.Commands;
3 | using Relax.Impl.Json;
4 |
5 | namespace Relax.Tests.Commands.SaveCommand
6 | {
7 | public abstract class with_poco_persistence : with_poco_list
8 | {
9 | protected static BulkPersist persist;
10 | protected static string json;
11 | protected static ISaveDocument command;
12 |
13 | private Establish context = () =>
14 | {
15 | persist = new BulkPersist(true, false, testDocs);
16 | command = factory.CreateSaveDocumentCommand();
17 | };
18 | }
19 | }
--------------------------------------------------------------------------------
/tests/Server/with_create_database_command.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Relax.Impl.Http;
3 |
4 | namespace Relax.Tests.Server
5 | {
6 | public abstract class with_create_database_command : with_couch_server
7 | {
8 | private Establish context = () =>
9 | {
10 | uri = new CouchUri("http", "localhost", 5984, "relax");
11 | commandMock.Setup(x => x.Put(couchUri));
12 | WireUpCommandMock(commandMock.Object);
13 | };
14 | }
15 | }
--------------------------------------------------------------------------------
/tests/Caching/with_cache_provider.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Moq;
3 | using Symbiote.Core.Cache;
4 |
5 | namespace Relax.Tests.Caching
6 | {
7 | public abstract class with_cache_provider : with_configuration
8 | {
9 | protected static Mock cacheProviderMock;
10 | protected static ICacheProvider CacheProvider { get { return cacheProviderMock.Object; } }
11 |
12 | private Establish context = () =>
13 | {
14 | cacheProviderMock = new Mock();
15 | };
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/tests/Commands/SaveCommand/with_poco_list_persistence.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Relax.Impl.Commands;
3 | using Relax.Impl.Json;
4 |
5 | namespace Relax.Tests.Commands.SaveCommand
6 | {
7 | public abstract class with_poco_list_persistence : with_poco_list
8 | {
9 | protected static BulkPersist persist;
10 | protected static string json;
11 | protected static ISaveDocuments command;
12 |
13 | private Establish context = () =>
14 | {
15 | persist = new BulkPersist(true, false, testDocs);
16 | command = factory.CreateSaveDocumentsCommand();
17 | };
18 | }
19 | }
--------------------------------------------------------------------------------
/tests/Server/when_compacting_db.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Machine.Specifications;
3 |
4 | namespace Relax.Tests.Server
5 | {
6 | public class when_compacting_db : with_db_compaction
7 | {
8 | private static Exception exception;
9 |
10 | private Because of = () =>
11 | {
12 | exception = Catch.Exception(() => server.CompactDatabase());
13 | };
14 |
15 | private It should_not_throw_exception = () => exception.ShouldBeNull();
16 | private It should_call_clean_view_command = () => commandMock.VerifyAll();
17 | }
18 | }
--------------------------------------------------------------------------------
/tests/Server/when_cleaning_up_views.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Machine.Specifications;
3 |
4 | namespace Relax.Tests.Server
5 | {
6 | public class when_cleaning_up_views : with_view_cleanup_command
7 | {
8 | private static Exception exception;
9 |
10 | private Because of = () =>
11 | {
12 | exception = Catch.Exception(() => server.CleanViews());
13 | };
14 |
15 | private It should_not_throw_exception = () => exception.ShouldBeNull();
16 | private It should_call_clean_view_command = () => commandMock.VerifyAll();
17 | }
18 | }
--------------------------------------------------------------------------------
/tests/Server/with_create_delete_database_command.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Relax.Impl.Http;
3 |
4 | namespace Relax.Tests.Server
5 | {
6 | public abstract class with_create_delete_database_command : with_couch_server
7 | {
8 | private Establish context = () =>
9 | {
10 | uri = new CouchUri("http", "localhost", 5984, "relax");
11 | commandMock.Setup(x => x.Delete(couchUri));
12 | WireUpCommandMock(commandMock.Object);
13 | };
14 | }
15 | }
--------------------------------------------------------------------------------
/tests/Server/when_compacting_view.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Machine.Specifications;
3 |
4 | namespace Relax.Tests.Server
5 | {
6 | public class when_compacting_view : with_view_compaction
7 | {
8 | private static Exception exception;
9 |
10 | private Because of = () =>
11 | {
12 | exception = Catch.Exception(() => server.CompactView("testView"));
13 | };
14 |
15 | private It should_not_throw_exception = () => exception.ShouldBeNull();
16 | private It should_call_clean_view_command = () => commandMock.VerifyAll();
17 | }
18 | }
--------------------------------------------------------------------------------
/tests/Server/with_check_database_exists_command.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Relax.Impl.Http;
3 |
4 | namespace Relax.Tests.Server
5 | {
6 | public abstract class with_check_database_exists_command : with_couch_server
7 | {
8 | private Establish context = () =>
9 | {
10 | uri = new CouchUri("http", "localhost", 5984, "relax");
11 | commandMock.Setup(x => x.Get(couchUri)).Returns("true");
12 | WireUpCommandMock(commandMock.Object);
13 | };
14 | }
15 | }
--------------------------------------------------------------------------------
/demo/RelaxDemo/DocumentSaver.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using Relax;
3 | using Symbiote.Core.Extensions;
4 |
5 | namespace RelaxDemo
6 | {
7 | public class DocumentSaver
8 | {
9 | private IDocumentRepository _couch;
10 |
11 | public void Save(TestDocument document)
12 | {
13 | var watch = Stopwatch.StartNew();
14 | _couch.Save(document);
15 | watch.Stop();
16 | "Save completed in {0}"
17 | .ToInfo(watch.ElapsedMilliseconds);
18 | }
19 |
20 | public DocumentSaver(IDocumentRepository couch)
21 | {
22 | _couch = couch;
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/tests/Serialization/ComplexDocument.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Relax.Impl.Model;
3 |
4 | namespace Relax.Tests.Serialization
5 | {
6 | [Serializable]
7 | public class ComplexDocument : ComplexCouchDocument
8 | {
9 | public virtual string Message { get; set; }
10 | public virtual DateTime Time { get; set; }
11 |
12 | public ComplexDocument()
13 | {
14 | _documentId = Guid.NewGuid();
15 | }
16 |
17 | public ComplexDocument(string message)
18 | {
19 | _documentId = Guid.NewGuid();
20 | Message = message;
21 | Time = DateTime.Now;
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/tests/Server/with_db_compaction.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Relax.Impl.Http;
3 |
4 | namespace Relax.Tests.Server
5 | {
6 | public abstract class with_db_compaction : with_couch_server
7 | {
8 | private Establish context = () =>
9 | {
10 | uri = new CouchUri("http", "localhost", 5984, "relax")
11 | .Compact();
12 | commandMock.Setup(x => x.Post(couchUri));
13 | WireUpCommandMock(commandMock.Object);
14 | };
15 | }
16 | }
--------------------------------------------------------------------------------
/tests/Server/when_copying_from_any_database.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Machine.Specifications;
3 |
4 | namespace Relax.Tests.Server
5 | {
6 | public class when_copying_from_any_database : with_copy_replication
7 | {
8 | protected static Exception exception;
9 |
10 | private Because of = () =>
11 | {
12 | exception = Catch.Exception(() => server.CopyDatabase(sourceUri, targetUri));
13 | };
14 |
15 | private It should_copy_without_exceptions = () => exception.ShouldBeNull();
16 | private It should_call_replicate_via_post = () => commandMock.VerifyAll();
17 | }
18 | }
--------------------------------------------------------------------------------
/tests/Commands/TestDoc.cs:
--------------------------------------------------------------------------------
1 | using Symbiote.Core;
2 |
3 | namespace Relax.Tests.Commands
4 | {
5 | public class TestDoc : CouchDocument
6 | {
7 | public virtual string Message { get; set; }
8 | }
9 |
10 | public class MyPocoKeyAccessor : IKeyAccessor
11 | {
12 | public string GetId( MyPoco actor )
13 | {
14 | return actor.MyId;
15 | }
16 |
17 | public void SetId( MyPoco actor, TKey key )
18 | {
19 | actor.MyId = key.ToString();
20 | }
21 | }
22 |
23 |
24 | public class MyPoco
25 | {
26 | public string MyId { get; set; }
27 | public string Message { get; set; }
28 | }
29 | }
--------------------------------------------------------------------------------
/tests/Server/when_copying_from_local_database.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Machine.Specifications;
3 |
4 | namespace Relax.Tests.Server
5 | {
6 | public class when_copying_from_local_database : with_copy_replication
7 | {
8 | protected static Exception exception;
9 |
10 | private Because of = () =>
11 | {
12 | exception = Catch.Exception(() => server.CopyDatabase(targetUri));
13 | };
14 |
15 | private It should_copy_without_exceptions = () => exception.ShouldBeNull();
16 | private It should_call_replicate_via_post = () => commandMock.VerifyAll();
17 | }
18 | }
--------------------------------------------------------------------------------
/demo/RelaxDemo/LuceneSearchClient.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Relax;
6 | using Symbiote.JsonRpc.Client;
7 |
8 | namespace RelaxDemo
9 | {
10 | public class LuceneSearchClient
11 | {
12 | protected IRemoteProxy queryService;
13 |
14 | public string[] GetMatchesForQuery()
15 | {
16 | return queryService.Call(x => x.GetDocumentIdsForQuery("testdocument", "Message:Doc*"));
17 | }
18 |
19 | public LuceneSearchClient(IRemoteProxy queryService)
20 | {
21 | this.queryService = queryService;
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/tests/Commands/DeletingAttachments/when_deleting_attachment.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using Machine.Specifications;
3 |
4 | namespace Relax.Tests.Commands.DeletingAttachments
5 | {
6 | public class when_deleting_attachment : with_delete_attachment_command
7 | {
8 | private Because of = () =>
9 | {
10 | command.DeleteAttachment(document, "myattachment");
11 | };
12 |
13 | private It should_update_revision = () => document.DocumentRevision.ShouldEqual("02");
14 | private It should_remove_attachment = () => ShouldExtensionMethods.ShouldEqual(document.Attachments.Count(), 0);
15 | }
16 | }
--------------------------------------------------------------------------------
/tests/Server/with_view_cleanup_command.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Relax.Impl.Http;
3 |
4 | namespace Relax.Tests.Server
5 | {
6 | public abstract class with_view_cleanup_command : with_couch_server
7 | {
8 | private Establish context = () =>
9 | {
10 | uri = new CouchUri("http", "localhost", 5984, "relax")
11 | .CleanupViews();
12 | commandMock.Setup(x => x.Post(couchUri));
13 | WireUpCommandMock(commandMock.Object);
14 | };
15 | }
16 | }
--------------------------------------------------------------------------------
/tests/Server/with_view_compaction.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Relax.Impl.Http;
3 |
4 | namespace Relax.Tests.Server
5 | {
6 | public abstract class with_view_compaction : with_couch_server
7 | {
8 | private Establish context = () =>
9 | {
10 | uri = new CouchUri("http", "localhost", 5984, "relax")
11 | .CompactView("testView");
12 | commandMock.Setup(x => x.Post(couchUri));
13 | WireUpCommandMock(commandMock.Object);
14 | };
15 | }
16 | }
--------------------------------------------------------------------------------
/tests/URI/Encoding/with_test_json.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Machine.Specifications;
3 | using Symbiote.Core.Serialization;
4 |
5 | namespace Relax.Tests.URI.Encoding
6 | {
7 | public abstract class with_test_json
8 | {
9 | protected static object[] keySource;
10 | protected static string testJson;
11 |
12 | private Establish context = () =>
13 | {
14 | keySource = new object[] {"a", 12, "ab+=.,[]<>", "123-123-4556", DateTime.Parse("6/17/1979"), 14.5,true};
15 | testJson = keySource.ToJson(false);
16 | };
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/tests/Relax.Lucene.Tests/with_lucene.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using StructureMap;
3 | using Symbiote.Core;
4 | using Symbiote.Lucene;
5 | using Symbiote.StructureMap;
6 |
7 | namespace Relax.Lucene.Tests
8 | {
9 | public abstract class with_lucene
10 | {
11 | protected static ILuceneServiceFactory luceneServiceFactory;
12 |
13 | private Establish context = () =>
14 | {
15 | Assimilate.Core().Relax().Lucene();
16 | luceneServiceFactory = ObjectFactory.GetInstance();
17 | };
18 | }
19 | }
--------------------------------------------------------------------------------
/tests/Repository/when_saving_a_document.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Machine.Specifications;
3 |
4 | namespace Relax.Tests.Repository
5 | {
6 | public class when_saving_a_document : with_save_model_command
7 | {
8 | private static Exception exception = null;
9 |
10 | private Because of = () => {
11 | exception = Catch.Exception(() =>
12 | repository.Save(document));
13 | };
14 |
15 | private It should_save_document_without_exception = () => exception.ShouldBeNull();
16 | private It should_update_revision = () => document.DocumentRevision.ShouldEqual("3");
17 | private It should_call_put_correctly = () => commandMock.VerifyAll();
18 | }
19 | }
--------------------------------------------------------------------------------
/tests/URI/ViewQuery/with_couch_uri.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Moq;
3 | using Relax.Impl.Http;
4 |
5 | namespace Relax.Tests.URI.ViewQuery
6 | {
7 | public abstract class with_couch_uri
8 | {
9 | protected static Mock uriMock;
10 | protected static CouchUri uri { get { return uriMock.Object; } }
11 | protected static Relax.Impl.Commands.ViewQuery query { get { return new Relax.Impl.Commands.ViewQuery(uri); } }
12 |
13 | private Establish context = () =>
14 | {
15 | uriMock = new Mock("http", "localhost", 5984);
16 | };
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/tests/Commands/SaveCommand/with_poco_list.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Machine.Specifications;
3 |
4 | namespace Relax.Tests.Commands.SaveCommand
5 | {
6 | public abstract class with_poco_list : with_command_factory
7 | {
8 | protected static List testDocs;
9 |
10 | private Establish context = () =>
11 | {
12 | testDocs = new List()
13 | {
14 | new MyPoco() { Message = "Message1", MyId = "1" },
15 | new MyPoco() { Message = "Message2", MyId = "2" },
16 | new MyPoco() { Message = "Message3", MyId = "3" },
17 | };
18 | };
19 | }
20 | }
--------------------------------------------------------------------------------
/tests/Serialization/when_deserializing_complex_document.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Symbiote.Core.Serialization;
3 |
4 | namespace Relax.Tests.Serialization
5 | {
6 | public class when_deserializing_complex_document : with_complex_document
7 | {
8 | protected static ComplexDocument document;
9 |
10 | private Because of = () =>
11 | {
12 | document = json.FromJson();
13 | };
14 |
15 | private It should_have_correct_revision = () =>
16 | document.DocumentRevision.ShouldEqual("1-39759d4fdfa5e162acec9551b741c82e");
17 | }
18 | }
--------------------------------------------------------------------------------
/tests/Server/when_starting_replication_from_any_database.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Machine.Specifications;
3 |
4 | namespace Relax.Tests.Server
5 | {
6 | public class when_starting_replication_from_any_database : with_continuous_replication
7 | {
8 | protected static Exception exception;
9 |
10 | private Because of = () =>
11 | {
12 | exception = Catch.Exception(() => server.Replicate(sourceUri, targetUri));
13 | };
14 |
15 | private It should_replication_without_exceptions = () => exception.ShouldBeNull();
16 | private It should_call_replicate_via_post = () => commandMock.VerifyAll();
17 | }
18 | }
--------------------------------------------------------------------------------
/tests/Document/when_using_custom_complex_key.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Symbiote.Core.Serialization;
3 |
4 | namespace Relax.Tests.Document
5 | {
6 | [Subject("custom document")]
7 | public class when_using_custom_complex_key : with_custom_document_complex_key
8 | {
9 | private static string jsonKey;
10 | private Because of = () =>
11 | {
12 | jsonKey = person.ToJson(false);
13 | };
14 |
15 | private It should_have_expected_key = () => driver.DocumentId.ShouldEqual(person);
16 | private It should_have_correct_json = () => driver.GetDocumentIdAsJson().ShouldEqual(jsonKey);
17 | }
18 | }
--------------------------------------------------------------------------------
/tests/Server/when_starting_replication_from_local_database.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Machine.Specifications;
3 |
4 | namespace Relax.Tests.Server
5 | {
6 | public class when_starting_replication_from_local_database : with_continuous_replication
7 | {
8 | protected static Exception exception;
9 |
10 | private Because of = () =>
11 | {
12 | exception = Catch.Exception(() => server.Replicate(targetUri));
13 | };
14 |
15 | private It should_replication_without_exceptions = () => exception.ShouldBeNull();
16 | private It should_call_replicate_via_post = () => commandMock.VerifyAll();
17 | }
18 | }
--------------------------------------------------------------------------------
/tests/Server/with_list_databases_command.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Relax.Impl.Http;
3 |
4 | namespace Relax.Tests.Server
5 | {
6 | public abstract class with_list_databases_command : with_couch_server
7 | {
8 | private Establish context = () =>
9 | {
10 | uri = new CouchUri("http", "localhost", 5984, "_all_dbs");
11 | commandMock.Setup(x => x.Get(couchUri))
12 | .Returns("[ \"one\", \"two\", \"three\" ]");
13 | WireUpCommandMock(commandMock.Object);
14 | };
15 | }
16 | }
--------------------------------------------------------------------------------
/tests/Document/Person.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Relax.Impl.Model;
3 | using Symbiote.Core.Extensions;
4 |
5 | namespace Relax.Tests.Document
6 | {
7 | public class Person : ComplexCouchDocument
8 | {
9 | public virtual string FirstName { get; set; }
10 | public virtual string LastName { get; set; }
11 | public virtual string Social { get; set; }
12 | public virtual DateTime DateOfBirth { get; set; }
13 |
14 | protected void Init()
15 | {
16 | KeyGetter(x => "{0}, {1} born {2}".AsFormat(LastName, FirstName, DateOfBirth));
17 | KeySetter((x,k) => {});
18 | }
19 |
20 | public Person()
21 | {
22 | Init();
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/tests/URI/when_using_start_key_only.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Machine.Specifications;
3 |
4 | namespace Relax.Tests.URI
5 | {
6 | [Subject("Couch URI")]
7 | public class when_using_start_key_only : with_basic_uri
8 | {
9 | private static DateTime date = DateTime.Now;
10 | private static string complexKey;
11 |
12 | private Because of = () =>
13 | {
14 | complexKey = "test+10";
15 | uri.StartKey(complexKey);
16 | };
17 |
18 | private It should_append_reduce_false
19 | = () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax?startkey=""test%2b10""");
20 | }
21 | }
--------------------------------------------------------------------------------
/tests/Relax.Lucene.Tests/with_domain_model.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using Machine.Specifications;
4 | using Symbiote.Core.Extensions;
5 |
6 | namespace Relax.Lucene.Tests
7 | {
8 | public abstract class with_domain_model : with_lucene
9 | {
10 | protected static List people;
11 | protected static List personDocuments;
12 |
13 | private Establish context = () =>
14 | {
15 | people = DomainHelper.Create_Family_With_Two_Cars();
16 | personDocuments = people.Select(x => x.ToJson(false)).ToList();
17 | };
18 | }
19 | }
--------------------------------------------------------------------------------
/tests/Relax.Lucene.Tests/Person.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Concurrent;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using Lucene.Net.Analysis;
5 | using Lucene.Net.Analysis.Standard;
6 | using Lucene.Net.Index;
7 | using Lucene.Net.QueryParsers;
8 | using Lucene.Net.Store;
9 | using Newtonsoft.Json.Linq;
10 | using Relax.Impl.Commands;
11 | using Relax.Impl.Http;
12 | using Relax.Impl.Model;
13 | using StructureMap.Pipeline;
14 |
15 | namespace Relax.Lucene.Tests
16 | {
17 | public class Person : CouchDocument
18 | {
19 | public virtual string FirstName { get; set; }
20 | public virtual string LastName { get; set; }
21 | public virtual int Age { get; set; }
22 | public virtual List Cars { get; set; }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/tests/Serialization/when_deserializing_view_result_with_documents_included.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Relax.Impl.Json;
3 | using Symbiote.Core.Serialization;
4 |
5 | namespace Relax.Tests.Serialization
6 | {
7 | public class when_deserializing_view_result_with_documents_included : with_view_result_and_documents_included
8 | {
9 | protected static ViewResult result;
10 |
11 | private Because of = () =>
12 | {
13 | result = viewResultJson.FromJson>();
14 | };
15 |
16 | private It should_have_document_message = () =>
17 | result.Rows[0].Model.Message.ShouldEqual("Howdy");
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/tests/URI/when_using_end_key_only.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Machine.Specifications;
3 |
4 | namespace Relax.Tests.URI
5 | {
6 | [Subject("Couch URI")]
7 | public class when_using_end_key_only : with_basic_uri
8 | {
9 | private static DateTime date = DateTime.Now;
10 | private static object complexKey;
11 |
12 | private Because of = () =>
13 | {
14 | complexKey = new object[] {"test", 10, "+"};
15 | uri.EndKey(complexKey);
16 | };
17 |
18 | private It should_append_reduce_false
19 | = () => uri.ToString().ShouldEqual(@"http://localhost:5984/relax?endkey=[""test"",10,""%2b""]");
20 | }
21 | }
--------------------------------------------------------------------------------
/tests/Server/when_creating_database.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Machine.Specifications;
3 |
4 | namespace Relax.Tests.Server
5 | {
6 | public class when_creating_database : with_create_database_command
7 | {
8 | private static Exception exception = null;
9 | private Because of = () =>
10 | {
11 | exception = Catch.Exception(
12 | () => server.CreateDatabase()
13 | );
14 | };
15 |
16 | private It should_create_database_without_exception = () => exception.ShouldBeNull();
17 | private It should_call_put_correctly = () => commandMock.VerifyAll();
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/tests/Serialization/when_deserializing_complex_view.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using Machine.Specifications;
3 | using Relax.Impl.Json;
4 | using Symbiote.Core.Serialization;
5 |
6 | namespace Relax.Tests.Serialization
7 | {
8 | public class when_deserializing_complex_view : with_complex_view_result
9 | {
10 | protected static ViewResult documents;
11 |
12 | private Because of = () =>
13 | {
14 | documents = json.FromJson>();
15 | };
16 |
17 | private It should_have_correct_revision = () =>
18 | documents.GetList().ToList()[0].DocumentRevision.ShouldEqual("1-39759d4fdfa5e162acec9551b741c82e");
19 | }
20 | }
--------------------------------------------------------------------------------
/tests/Server/when_deleteing_database.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Machine.Specifications;
3 |
4 | namespace Relax.Tests.Server
5 | {
6 | public class when_deleteing_database : with_create_delete_database_command
7 | {
8 | private static Exception exception = null;
9 | private Because of = () =>
10 | {
11 | exception = Catch.Exception(
12 | () => server.DeleteDatabase()
13 | );
14 | };
15 |
16 | private It should_delete_database_without_exception = () => exception.ShouldBeNull();
17 | private It should_call_delete_correctly = () => commandMock.VerifyAll();
18 | }
19 | }
--------------------------------------------------------------------------------
/tests/URI/Encoding/when_encoding_json_for_url.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Relax.Impl.Json;
3 |
4 | namespace Relax.Tests.URI.Encoding
5 | {
6 | public class when_encoding_json_for_url : with_test_json
7 | {
8 | protected static string result;
9 | protected static string expected = @"[""a"",12,""ab%2b%3d.%2c%5b%5d%3c%3e"",""123-123-4556"",""1979-06-17T00%3a00%3a00"",14.5,true]";
10 |
11 | private Because of = () =>
12 | {
13 | var encoder = new JsonUrlEncoder();
14 | result = encoder.Encode(testJson);
15 | };
16 |
17 | private It should_provide_expected_format = () => result.ShouldEqual(expected);
18 | }
19 | }
--------------------------------------------------------------------------------
/tests/Serialization/when_deserializing_view_result_and_document_excluded.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Relax.Impl.Json;
3 | using Symbiote.Core.Serialization;
4 |
5 | namespace Relax.Tests.Serialization
6 | {
7 | public class when_deserializing_view_result_and_document_excluded : with_view_result_and_no_documents
8 | {
9 | protected static ViewResult result;
10 |
11 | private Because of = () =>
12 | {
13 | result = viewResultJson.FromJson>();
14 | };
15 |
16 | private It should_have_document_message = () =>
17 | result.Rows[0].Model.Message.ShouldEqual("Hi");
18 | }
19 | }
--------------------------------------------------------------------------------
/src/Relax/Impl/Json/KeyList.cs:
--------------------------------------------------------------------------------
1 | // /*
2 | // Copyright 2008-2011 Alex Robson
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 | // */
16 | namespace Relax.Impl.Json
17 | {
18 | public class KeyList
19 | {
20 | public object[] keys { get; set; }
21 | }
22 | }
--------------------------------------------------------------------------------
/demo/RelaxDemo/ChangeWatcher.cs:
--------------------------------------------------------------------------------
1 | using Relax;
2 | using Symbiote.Core.Extensions;
3 |
4 | namespace RelaxDemo
5 | {
6 | public class ChangeWatcher
7 | {
8 | private IDocumentRepository _couch;
9 |
10 | public void Start()
11 | {
12 | _couch.HandleUpdates(0, Update, null);
13 | }
14 |
15 | private void Update(string database, ChangeRecord obj)
16 | {
17 | "An update was posted to couch: \r\n\t {0}"
18 | .ToInfo(obj.Document);
19 | }
20 |
21 | public void Stop()
22 | {
23 | _couch.StopChangeStreaming();
24 | }
25 |
26 | public ChangeWatcher(IDocumentRepository couch)
27 | {
28 | _couch = couch;
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/src/Relax/Impl/Feed.cs:
--------------------------------------------------------------------------------
1 | // /*
2 | // Copyright 2008-2011 Alex Robson
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 | // */
16 | namespace Relax.Impl
17 | {
18 | public enum Feed
19 | {
20 | Continuous,
21 | LongPolling,
22 | Simple
23 | }
24 | }
--------------------------------------------------------------------------------
/src/Relax/IResolveDatabaseNames.cs:
--------------------------------------------------------------------------------
1 | // /*
2 | // Copyright 2008-2011 Alex Robson
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 | // */
16 | namespace Relax
17 | {
18 | public interface IResolveDatabaseNames
19 | {
20 | string GetDatabaseNameFor();
21 | }
22 | }
--------------------------------------------------------------------------------
/tests/Repository/when_deleting_document_by_id.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Machine.Specifications;
3 | using Relax.Tests.Commands;
4 |
5 | namespace Relax.Tests.Repository
6 | {
7 | public class when_deleting_document_by_id : with_delete_document_command_by_id
8 | {
9 | private static Exception exception = null;
10 | private Because of = () =>
11 | {
12 | exception = Catch.Exception(
13 | () => repository.DeleteDocument(id)
14 | );
15 | };
16 |
17 | private It should_delete_document_without_exception = () => exception.ShouldBeNull();
18 | private It should_call_delete_correctly = () => commandMock.VerifyAll();
19 | }
20 | }
--------------------------------------------------------------------------------
/tests/Repository/when_deleting_document_by_id_and_rev.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Machine.Specifications;
3 |
4 | namespace Relax.Tests.Repository
5 | {
6 | public class when_deleting_document_by_id_and_rev : with_delete_document_command_by_id_and_rev
7 | {
8 | private static Exception exception = null;
9 | private Because of = () =>
10 | {
11 | exception = Catch.Exception(
12 | () => repository.DeleteDocument(id, "1")
13 | );
14 | };
15 |
16 | private It should_delete_document_without_exception = () => exception.ShouldBeNull();
17 | private It should_call_delete_correctly = () => commandMock.VerifyAll();
18 | }
19 | }
--------------------------------------------------------------------------------
/tests/Repository/with_delete_document_command.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Machine.Specifications;
3 | using Relax.Impl;
4 | using Relax.Impl.Http;
5 |
6 | namespace Relax.Tests.Repository
7 | {
8 | public abstract class with_delete_document_command : with_document_repository
9 | {
10 | protected static Guid id;
11 |
12 | private Establish context = () =>
13 | {
14 | id = Guid.NewGuid();
15 | uri = new CouchUri("http", "localhost", 5984, "relax").IdAndRev(id, "1");
16 | commandMock.Setup(x => x.Delete(couchUri));
17 | WireUpCommandMock(commandMock.Object);
18 | };
19 | }
20 | }
--------------------------------------------------------------------------------
/demo/Relax.Overflow/Users.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Relax.Overflow
4 | {
5 | public class Users
6 | {
7 | public virtual long Id { get; set; }
8 | public virtual decimal Reputation { get; set; }
9 | public virtual DateTime CreationDate { get; set; }
10 | public virtual string DisplayName { get; set; }
11 | public virtual string EmailHash { get; set; }
12 | public virtual DateTime LastAccessDate { get; set; }
13 | public virtual string WebSiteUrl { get; set; }
14 | public virtual string Location { get; set; }
15 | public virtual long Age { get; set; }
16 | public virtual string AboutMe { get; set; }
17 | public virtual long Views { get; set; }
18 | public virtual long UpVotes { get; set; }
19 | public virtual long DownVotes { get; set; }
20 | }
21 | }
--------------------------------------------------------------------------------
/tests/Repository/when_deleting_attachment.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Machine.Specifications;
3 | using Relax.Tests.Commands;
4 |
5 | namespace Relax.Tests.Repository
6 | {
7 | public class when_deleting_attachment : with_delete_attachment_command
8 | {
9 | private static Exception exception;
10 |
11 | private Because of = () =>
12 | {
13 | exception =
14 | Catch.Exception(
15 | () => repository.DeleteAttachment(document, attachmentName));
16 | };
17 |
18 | private It should_delete_attachment_without_exception = () => exception.ShouldBeNull();
19 | private It should_call_command_correctly = () => commandMock.VerifyAll();
20 | }
21 | }
--------------------------------------------------------------------------------
/tests/Commands/GetCommand/when_getting_documents_by_key_range.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Relax.Impl.Commands;
3 | using Relax.Impl.Json;
4 |
5 | namespace Relax.Tests.Commands
6 | {
7 | public class when_getting_documents_by_key_range : with_get_doc_by_range
8 | {
9 | protected static CommandResult result;
10 | protected static ViewResult viewResult;
11 | protected static string json;
12 |
13 | private Because of = () =>
14 | {
15 | result = command.GetDocumentsInRange("doc 1", "doc 2");
16 | viewResult = result.GetResultAs>();
17 | };
18 |
19 | private It should_have_one_document = () => viewResult.TotalRows.ShouldEqual(1);
20 | }
21 | }
--------------------------------------------------------------------------------
/src/Relax/Impl/Model/IHaveDocumentId.cs:
--------------------------------------------------------------------------------
1 | // /*
2 | // Copyright 2008-2011 Alex Robson
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 | // */
16 | namespace Relax.Impl.Model
17 | {
18 | public interface IHaveDocumentId
19 | {
20 | string GetDocumentIdAsJson();
21 | object GetDocumentId();
22 | }
23 | }
--------------------------------------------------------------------------------
/tests/Document/with_custom_document_simple_key.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Machine.Specifications;
3 |
4 | namespace Relax.Tests.Document
5 | {
6 | public class with_custom_document_simple_key
7 | {
8 | protected static Person person;
9 | protected static DateTime dob = DateTime.Parse("04/01/1980");
10 |
11 | private Establish context = () => person = new Person()
12 | {
13 | FirstName = "Dude",
14 | LastName = "Duderson",
15 | Social = "000-11-1234",
16 | DateOfBirth = dob
17 | };
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/tests/Repository/when_deleting_document.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Machine.Specifications;
3 | using Relax.Impl.Json;
4 |
5 | namespace Relax.Tests.Repository
6 | {
7 | public class when_deleting_document_by_id_and_rev : with_delete_document_command_by_id_and_rev
8 | {
9 | private static Exception exception = null;
10 | private Because of = () =>
11 | {
12 | exception = Catch.Exception(
13 | () => repository.DeleteDocument(id, "1")
14 | );
15 | };
16 |
17 | private It should_delete_document_without_exception = () => exception.ShouldBeNull();
18 | private It should_call_delete_correctly = () => commandMock.Verify(x => x.Delete(couchUri));
19 | }
20 | }
--------------------------------------------------------------------------------
/tests/with_configuration.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Relax.Config;
3 | using Relax.Impl.Http;
4 | using Symbiote.Core;
5 |
6 | namespace Relax.Tests
7 | {
8 | public abstract class with_configuration
9 | {
10 | protected static ICouchConfiguration configuration;
11 | private Establish context = () =>
12 | {
13 | Assimilate.Initialize();
14 | configuration = new CouchConfiguration();
15 | };
16 |
17 | protected static void WireUpCommandMock(IHttpAction commandMock)
18 | {
19 | var mock = Assimilate.GetAllInstancesOf();
20 |
21 | Assimilate.Dependencies( x => x.For().Use( commandMock ) );
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/src/Relax/Impl/Serialization/IValueProviderCache.cs:
--------------------------------------------------------------------------------
1 | // /*
2 | // Copyright 2008-2011 Alex Robson
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 | // */
16 | namespace Relax.Impl.Serialization
17 | {
18 | public interface IValueProviderCache
19 | {
20 | MetadataValueProvider GetValueProviderFor( string memberName );
21 | }
22 | }
--------------------------------------------------------------------------------
/tests/Commands/GettingDocuments/when_getting_documents_by_key_range.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Relax.Impl.Commands;
3 | using Relax.Impl.Json;
4 |
5 | namespace Relax.Tests.Commands.GettingDocuments
6 | {
7 | public class when_getting_documents_by_key_range : with_get_doc_by_range
8 | {
9 | protected static CommandResult result;
10 | protected static ViewResult viewResult;
11 | protected static string json;
12 |
13 | private Because of = () =>
14 | {
15 | result = command.GetDocumentsInRange("doc 1", "doc 2");
16 | viewResult = result.GetResultAs>();
17 | };
18 |
19 | private It should_have_one_document = () => viewResult.TotalRows.ShouldEqual(1);
20 | }
21 | }
--------------------------------------------------------------------------------
/tests/TestDocument.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Relax.Impl.Model;
3 | using Symbiote.Core;
4 |
5 | namespace Relax.Tests
6 | {
7 | public class TestDocument : ComplexCouchDocument
8 | {
9 | public virtual string Message { get; set; }
10 | public virtual DateTime CreatedOn { get; set; }
11 |
12 | public TestDocument()
13 | {
14 | _documentId = Guid.NewGuid();
15 | CreatedOn = DateTime.Now;
16 | }
17 | }
18 |
19 | public class TestDocumentKeyAccessor : IKeyAccessor
20 | {
21 | public string GetId( TestDocument actor )
22 | {
23 | return actor.DocumentId.ToString();
24 | }
25 |
26 | public void SetId( TestDocument actor, TKey key )
27 | {
28 | actor.DocumentId = Guid.Parse( key.ToString() );
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/tests/Repository/when_saving_documents.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Machine.Specifications;
3 |
4 | namespace Relax.Tests.Repository
5 | {
6 | public class when_saving_documents : with_save_models_command
7 | {
8 | private static Exception exception = null;
9 |
10 | private Because of = () =>
11 | {
12 | exception = Catch.Exception(
13 | () => repository.SaveAll(new [] {document})
14 | );
15 | };
16 |
17 | private It should_save_documents_without_exception = () => exception.ShouldBeNull();
18 | private It should_update_revision = () => document.DocumentRevision.ShouldEqual("3");
19 | private It should_call_post_correctly = () => commandMock.VerifyAll();
20 | }
21 | }
--------------------------------------------------------------------------------
/tests/Serialization/with_view_result_and_no_documents.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 |
3 | namespace Relax.Tests.Serialization
4 | {
5 | public abstract class with_view_result_and_no_documents
6 | {
7 | protected static string viewResultJson;
8 |
9 | private Establish context = () =>
10 | {
11 | viewResultJson = @"
12 | {
13 | rows:
14 | [
15 | {
16 | id: ""8dd62969-9070-4f34-b478-e3e7e1c792aa"",
17 | key: {thingy:""Test"",thingy2:1},
18 | value: {
19 | _id: ""8dd62969-9070-4f34-b478-e3e7e1c792aa"",
20 | _rev:""1-7b9bfed448e9339c7afdbfd42964b02e"",
21 | Message: ""Hi""
22 | }
23 | }
24 | ]
25 | }
26 | ";
27 | };
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Relax/Impl/Model/IHaveDocumentRevision.cs:
--------------------------------------------------------------------------------
1 | // /*
2 | // Copyright 2008-2011 Alex Robson
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 | // */
16 | namespace Relax.Impl.Model
17 | {
18 | public interface IHaveDocumentRevision
19 | {
20 | string DocumentRevision { get; set; }
21 | void UpdateRevFromJson( string jsonRev );
22 | }
23 | }
--------------------------------------------------------------------------------
/tests/Commands/SaveCommand/with_serialized_bulk_persist.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Relax.Impl.Commands;
3 | using Relax.Impl.Json;
4 | using Symbiote.Core.Serialization;
5 |
6 | namespace Relax.Tests.Commands.SaveCommand
7 | {
8 | public abstract class with_serialized_bulk_persist : with_single_parent_document
9 | {
10 | protected static BulkPersist persist;
11 | protected static string json;
12 | protected static ISaveDocuments command;
13 |
14 | private Establish context = () =>
15 | {
16 | persist = new BulkPersist(true, false, new [] {testDoc});
17 | json = persist.ToJson();
18 | command = factory.CreateSaveDocumentsCommand();
19 | };
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/Relax/Impl/Commands/ISaveDocument.cs:
--------------------------------------------------------------------------------
1 | // /*
2 | // Copyright 2008-2011 Alex Robson
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 | // */
16 | namespace Relax.Impl.Commands
17 | {
18 | public interface ISaveDocument
19 | {
20 | CommandResult Save( TModel model );
21 | CommandResult Save( string databaseName, object model );
22 | }
23 | }
--------------------------------------------------------------------------------
/tests/Server/when_checking_database_existence.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Machine.Specifications;
3 |
4 | namespace Relax.Tests.Server
5 | {
6 | public class when_checking_database_existence : with_check_database_exists_command
7 | {
8 | private static Exception exception = null;
9 | private static bool exists = false;
10 | private Because of = () =>
11 | {
12 | exception = Catch.Exception(
13 | () => exists = server.DatabaseExists()
14 | );
15 | };
16 |
17 | private It should_check_without_exception = () => exception.ShouldBeNull();
18 | private It should_find_database = () => exists.ShouldBeTrue();
19 | private It should_call_get_correctly = () => commandMock.VerifyAll();
20 | }
21 | }
--------------------------------------------------------------------------------
/tests/Commands/SavingAttachments/when_saving_document_attachment.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using Machine.Specifications;
3 |
4 | namespace Relax.Tests.Commands.SavingAttachments
5 | {
6 | public class when_saving_document_attachment : with_save_attachment_command
7 | {
8 | private Because of = () =>
9 | {
10 | command.SaveAttachment(document, "test", "text", bytes);
11 | };
12 |
13 | private It should_update_revision = () =>
14 | document.DocumentRevision.ShouldEqual("2");
15 |
16 | private It should_add_attachment_to_document = () => document.Attachments.Count().ShouldEqual(1);
17 | private It should_have_attachment = () => document.Attachments.First().ShouldEqual("test");
18 | private It should_call_action = () => mockAction.VerifyAll();
19 | }
20 | }
--------------------------------------------------------------------------------
/src/Relax/Impl/Model/IHaveAttachments.cs:
--------------------------------------------------------------------------------
1 | // /*
2 | // Copyright 2008-2011 Alex Robson
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 | // */
16 | namespace Relax.Impl.Model
17 | {
18 | public interface IHaveAttachments
19 | {
20 | void AddAttachment( string attachmentName, string contentType, long contentLength );
21 | void RemoveAttachment( string attachmentName );
22 | }
23 | }
--------------------------------------------------------------------------------
/src/Relax/Config/CouchConfigurationException.cs:
--------------------------------------------------------------------------------
1 | // /*
2 | // Copyright 2008-2011 Alex Robson
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 | // */
16 | using System;
17 |
18 | namespace Relax.Config
19 | {
20 | public class CouchConfigurationException : Exception
21 | {
22 | public CouchConfigurationException( string message ) : base( message )
23 | {
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/src/Relax/Impl/IDocumentSearchProvider.cs:
--------------------------------------------------------------------------------
1 | // /*
2 | // Copyright 2008-2011 Alex Robson
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 | // */
16 | using System;
17 | using System.Linq.Expressions;
18 |
19 | namespace Relax.Impl
20 | {
21 | public interface IDocumentSearchProvider
22 | {
23 | object[] GetDocumentIdsForQuery( Expression> criteria );
24 | }
25 | }
--------------------------------------------------------------------------------
/tests/ViewFilter/when_filtering_design_documents_from_results.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using Machine.Specifications;
4 | using Relax.Impl.Json;
5 | using Symbiote.Core.Serialization;
6 |
7 | namespace Relax.Tests.ViewFilter
8 | {
9 | public class when_filtering_design_documents_from_results : with_test_json
10 | {
11 | protected static List requests;
12 |
13 | private Because of = () =>
14 | {
15 | var filter = new DesignDocumentFilter();
16 | json = filter.Filter(json);
17 |
18 | var view = json.FromJson>();
19 | requests = view.GetList().ToList();
20 | };
21 |
22 | private It should_have_only_1_results = () => requests.Count.ShouldEqual(1);
23 | }
24 | }
--------------------------------------------------------------------------------
/demo/RelaxDemo/TestDocument.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Relax;
4 | using Relax.Impl;
5 | using Relax.Impl.Model;
6 |
7 | namespace RelaxDemo
8 | {
9 | [Serializable]
10 | public class TestDocument
11 | : ComplexCouchDocument
12 | {
13 | public virtual string Message { get; set; }
14 | public virtual DateTime Time { get; set; }
15 | public virtual int RandomNumber { get; set; }
16 |
17 | public TestDocument()
18 | {
19 | _documentId = Guid.NewGuid();
20 | var rnd = new Random();
21 | RandomNumber = rnd.Next(100);
22 | }
23 |
24 | public TestDocument(string message)
25 | {
26 | _documentId = Guid.NewGuid();
27 | Message = message;
28 | Time = DateTime.Now;
29 | var rnd = new Random();
30 | RandomNumber = rnd.Next(100);
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/tests/Commands/GettingAttachments/when_getting_attachment.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using Machine.Specifications;
4 |
5 | namespace Relax.Tests.Commands.GettingAttachments
6 | {
7 | public class when_getting_attachment : with_get_attachment_command
8 | {
9 | protected static Tuple expectedAttachment;
10 | protected static string content;
11 |
12 | private Because of = () =>
13 | {
14 | expectedAttachment = command.GetAttachment("test", "myattachment");
15 | content = Encoding.UTF8.GetString(expectedAttachment.Item2);
16 | };
17 |
18 | private It should_have_attachment_name = () => expectedAttachment.Item1.ShouldEqual("myattachment");
19 | private It should_have_correct_content = () => content.ShouldEqual("this is a lame attachment :(");
20 | }
21 | }
--------------------------------------------------------------------------------
/tests/Commands/SaveCommand/with_document_list.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Machine.Specifications;
3 |
4 | namespace Relax.Tests.Commands.SaveCommand
5 | {
6 | public abstract class with_document_list : with_command_factory
7 | {
8 | protected static List testDocs;
9 |
10 | private Establish context = () =>
11 | {
12 | testDocs = new List()
13 | {
14 | new TestDoc() { Message = "Message1"},
15 | new TestDoc() { Message = "Message2"},
16 | new TestDoc() { Message = "Message3"},
17 | };
18 | };
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/tests/Commands/with_mock_http_action.cs:
--------------------------------------------------------------------------------
1 | using Machine.Specifications;
2 | using Moq;
3 | using Relax.Impl.Http;
4 | using Symbiote.Core;
5 | using It = Machine.Specifications.It;
6 |
7 | namespace Relax.Tests.Commands
8 | {
9 | public abstract class with_mock_http_action : with_configuration
10 | {
11 | protected static Mock mockAction;
12 | protected static IHttpAction action { get { return mockAction.Object; }}
13 |
14 | private Establish context = () =>
15 | {
16 | mockAction = new Mock();
17 | Assimilate.Dependencies( x => x.For().CreateWith( c => action ) );
18 | };
19 | }
20 |
21 | public class when_testing_blank_action : with_mock_http_action
22 | {
23 | It should_not_be_null = () => { mockAction.ShouldNotBeNull(); };
24 | }
25 | }
--------------------------------------------------------------------------------
/src/Relax/Impl/Commands/ISaveDocuments.cs:
--------------------------------------------------------------------------------
1 | // /*
2 | // Copyright 2008-2011 Alex Robson
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 | // */
16 | using System.Collections.Generic;
17 |
18 | namespace Relax.Impl.Commands
19 | {
20 | public interface ISaveDocuments
21 | {
22 | CommandResult SaveAll( IEnumerable models );
23 | CommandResult SaveAll( string database, IEnumerable