public void Should_return_cached_settings_when_node_equals_to_cached() { var cacheItem = new SourceCacheItem <object> { BindingCacheValue = new BindingCacheValue <object>(node, settings) }; cachingBinder.Bind(new ValueNode("value"), cacheItem).Should().Be(settings); binder.DidNotReceiveWithAnyArgs().Bind <object>(default);
public void Should_save_binding_result_to_cacheItem_when_binding_succeeds() { binder.Bind <object>(node).Returns(settings); var cacheItem = new SourceCacheItem <object>(); cachingBinder.Bind(node, cacheItem); cacheItem.BindingCacheValue.Should().BeEquivalentTo(new BindingCacheValue <object>(node, settings)); }
public void Should_use_underlying_binder_when_different_cached_value() { binder.Bind <object>(node).Returns(settings); var cacheItem = new SourceCacheItem <object> { BindingCacheValue = new BindingCacheValue <object>(Substitute.For <ISettingsNode>(), new object()) }; cachingBinder.Bind(node, cacheItem).Should().Be(settings); }
public void Should_save_binding_result_to_cacheItem_when_binding_fails() { var error = new Exception(); binder.Bind <object>(node).Throws(error); var cacheItem = new SourceCacheItem <object>(); try { cachingBinder.Bind(node, cacheItem); } catch (Exception) { // ignored } cacheItem.BindingCacheValue.Should().BeEquivalentTo(new BindingCacheValue <object>(node, error)); }