private Upsert ( |
||
record | ||
Résultat |
public void should_store_valid_record_in_the_database() { var database = Mock.Of<IDocumentSession>(); var service = new RecordService(database, ValidatorStub()); var record = BasicRecord(); service.Upsert(record); Mock.Get(database).Verify(db => db.Store(record)); }
public void should_store_bounding_box_as_wkt() { var database = Mock.Of<IDocumentSession>(); var service = new RecordService(database, ValidatorStub()); var e = Library.Example(); var record = new Record { Gemini = e }; service.Upsert(record); string expectedWkt = BoundingBoxUtility.ToWkt(e.BoundingBox); Mock.Get(database).Verify(db => db.Store(It.Is((Record r) => r.Wkt == expectedWkt))); }
public void should_store_empty_bounding_box_as_null_wkt() { // to avoid raven / lucene indexing errors var database = Mock.Of<IDocumentSession>(); var service = new RecordService(database, ValidatorStub()); service.Upsert(BasicRecord()); Mock.Get(database).Verify(db => db.Store(It.Is((Record r) => r.Wkt == null))); }
public void should_standardise_unconditional_use_constraints() { var database = Mock.Of<IDocumentSession>(); var service = new RecordService(database, ValidatorStub()); var record = BasicRecord().With(r => r.Gemini.UseConstraints = " No conditions APPLY"); service.Upsert(record); Mock.Get(database).Verify(db => db.Store(It.Is((Record r) => r.Gemini.UseConstraints == "no conditions apply"))); }
public void should_set_security_to_official_by_default() { var database = Mock.Of<IDocumentSession>(); var service = new RecordService(database, ValidatorStub()); service.Upsert(BasicRecord()); Mock.Get(database).Verify(db => db.Store(It.Is((Record r) => r.Security == Security.Official))); }
public void should_save_keywords_in_correct_order() { // should be sorted by vocab, then value, but with distinguished jncc vocabs first! // finally, keywords with no namespace should be last var database = Mock.Of<IDocumentSession>(); var service = new RecordService(database, ValidatorStub()); var record = BasicRecord().With(r => { r.Gemini.Keywords = new StringPairList { { "a-vocab-beginning-with-a", "bravo" }, { "boring-vocab-beginning-with-b", "some-keyword" }, { "a-vocab-beginning-with-a", "alpha" }, { "http://vocab.jncc.gov.uk/jncc-category", "bravo" }, { "http://vocab.jncc.gov.uk/jncc-category", "alpha" }, { "http://vocab.jncc.gov.uk/jncc-domain", "some-domain" }, { "", "some-keyword" }, }.ToKeywordList(); }); service.Upsert(record); var expected = new StringPairList { { "http://vocab.jncc.gov.uk/jncc-domain", "some-domain" }, { "http://vocab.jncc.gov.uk/jncc-category", "alpha" }, { "http://vocab.jncc.gov.uk/jncc-category", "bravo" }, { "a-vocab-beginning-with-a", "alpha" }, { "a-vocab-beginning-with-a", "bravo" }, { "boring-vocab-beginning-with-b", "some-keyword" }, { "", "some-keyword" }, }.ToKeywordList(); Mock.Get(database).Verify(db => db.Store(It.Is((Record r) => r.Gemini.Keywords.IsEqualTo(expected)))); }
public void should_return_record_in_result() { // so we can pass the possibly modified record back to the client // without an unnecessary fetch from the database var database = Mock.Of<IDocumentSession>(); var service = new RecordService(database, ValidatorStub()); var record = BasicRecord(); var result = service.Upsert(record); result.Record.Should().Be(record); }
public void should_not_store_invalid_record_in_the_database() { var database = Mock.Of<IDocumentSession>(); var service = new RecordService(database, FailingValidatorStub()); service.Upsert(BasicRecord()); Mock.Get(database).Verify(db => db.Store(It.IsAny<Record>()), Times.Never); }