コード例 #1
0
ファイル: HalGraphTests.cs プロジェクト: AndyBrennan1/CoreHal
        public void Constructing_WithSinglePropertyModelProvided_AddsProperty()
        {
            const string expectedKeyName = "StringProperty";
            const string expectedValue   = "I AM A STRING FIELD";

            var model = new SimpleModel {
                StringProperty = expectedValue
            };

            var graph = new HalGraph(model);

            Assert.True(graph.Contains(expectedKeyName));
            Assert.Equal(expected: expectedValue, actual: graph[expectedKeyName]);
        }
コード例 #2
0
ファイル: HalGraphTests.cs プロジェクト: AndyBrennan1/CoreHal
        public void Constructing_WithModelContainingNoOutputProperty_DoesNotAddProperty()
        {
            const string fieldExpectedToBeMissing = "Integer2";

            var model = new ExampleWithIgnoredProperty
            {
                Integer1 = 1,
                Integer2 = 2,
                Integer3 = 3
            };

            var graph = new HalGraph(model);

            Assert.True(!graph.Contains(fieldExpectedToBeMissing));
        }
コード例 #3
0
ファイル: HalGraphTests.cs プロジェクト: AndyBrennan1/CoreHal
        public void Constructing_WithModelHavingComplexPropertyProvided_AddsPropertyAsDictionary()
        {
            const string expectedKeyName = "ComplexProperty";
            const string expectedValue   = "I AM A STRING FIELD";

            var complexProperty = new SimpleModel {
                StringProperty = expectedValue
            };

            var expectedComplexPropertyDictionary = new Dictionary <string, object>
            {
                { "StringProperty", expectedValue }
            };

            var model = new ModelWith1ComplexProperty {
                ComplexProperty = complexProperty
            };

            var graph = new HalGraph(model);

            Assert.True(graph.Contains(expectedKeyName));
            Assert.Equal(expected: expectedComplexPropertyDictionary, actual: graph[expectedKeyName]);
        }