public void TryGetMetadataReturnsFalseIfNotFound() { string testKey = "test"; var metadata = new Dictionary <string, object>(); var descriptor = new CommandDescriptor(typeof(TestCommand), metadata); descriptor.TryGetMetadata(testKey, out int value) .Should() .BeFalse(); }
public void TryGetMetadataReturnsValue() { string testKey = "test"; int testValue = 1; var metadata = new Dictionary <string, object> { { testKey, testValue } }; var descriptor = new CommandDescriptor(typeof(TestCommand), metadata); descriptor.TryGetMetadata(testKey, out int value) .Should() .BeTrue(); value.Should() .Be(testValue); }
public void TryGetMetadataThrowsIfOfWrongType() { string testKey = "test"; int testValue = 1; var metadata = new Dictionary <string, object> { { testKey, testValue } }; var descriptor = new CommandDescriptor(typeof(TestCommand), metadata); Action action = () => { descriptor.TryGetMetadata(testKey, out string wrongTypeValue); }; action.Should() .Throw <InvalidCastException>(); }