public void GetMetadataReturnsDefaultValueIfNotFound() { int defaultValue = 123; string testKey = "test"; var metadata = new Dictionary <string, object>(); var descriptor = new CommandDescriptor(typeof(TestCommand), metadata); descriptor.GetMetadata(testKey, defaultValue) .Should() .Be(defaultValue); }
public void GetMetadataThrowsIfNotFound() { var metadata = new Dictionary <string, object>(); var descriptor = new CommandDescriptor(typeof(TestCommand), metadata); Action action = () => { descriptor.GetMetadata <int>("key"); }; action.Should() .Throw <KeyNotFoundException>(); }
public void GetMetadataReturnsValue() { string testKey = "test"; int testValue = 1; var metadata = new Dictionary <string, object> { { testKey, testValue } }; var descriptor = new CommandDescriptor(typeof(TestCommand), metadata); descriptor.GetMetadata <int>(testKey) .Should() .Be(testValue); }