public void GetUniqueKeyIsMemoized()
        {
            var innerMapper = new MReadOnlyMappingManager();

            innerMapper.getUniqueKey += t => {
                Assert.AreEqual(typeof(TestDocument), t);
                return(new SolrFieldModel(property: typeof(TestDocument).GetProperty("Id"),
                                          fieldName: "id"));
            };
            var mapper = new MemoizingMappingManager(innerMapper);

            mapper.GetUniqueKey(typeof(TestDocument));
            mapper.GetUniqueKey(typeof(TestDocument));
            Assert.AreEqual(1, innerMapper.getUniqueKey.Calls);
        }
Exemplo n.º 2
0
        public void GetUniqueKeyIsMemoized()
        {
            var mocks       = new MockRepository();
            var innerMapper = mocks.StrictMock <IReadOnlyMappingManager>();

            With.Mocks(mocks)
            .Expecting(() => Expect.Call(innerMapper.GetUniqueKey(typeof(TestDocument)))
                       .Repeat.Once()
                       .Return(new SolrFieldModel {
                Property = typeof(TestDocument).GetProperty("Id"), FieldName = "id"
            }))
            .Verify(() => {
                var mapper = new MemoizingMappingManager(innerMapper);
                mapper.GetUniqueKey(typeof(TestDocument));
                mapper.GetUniqueKey(typeof(TestDocument));
            });
        }