Пример #1
0
 private static void Assert(UriMetadata result, Meta m)
 {
     Debug.Assert(m.SomeVar == "12314");
     Debug.Assert(m.SomeVarQueryString == "123");
     Debug.Assert(m.SomeVar2 == "xxx");
     Debug.Assert(result.UriType == "varTwoLink");
 }
Пример #2
0
        public void Equals_Fail()
        {
            // Arrange
            var metadata  = new UriMetadata("someType", new object());
            var metadata2 = new UriMetadata("someType", new object());

            // Act

            // Assert
            metadata.Equals(metadata2).Should().BeFalse();
        }
Пример #3
0
        public void Cast_ToModel_NonSuccess()
        {
            // Arrange
            var metadata = new UriMetadata("someType", new object());

            // Act
            var resultCast = metadata.TryCast <Meta>(out var result);

            // Assert
            result.Should().BeNull();
            resultCast.Should().BeFalse();
        }
Пример #4
0
        public void Cast_ToDictionary_Success()
        {
            // Arrange
            var metadata = new UriMetadata("someType", new Dictionary <string, string>());

            // Act
            var resultCast = metadata.TryCastToDict(out var result);

            // Assert
            result.Should().NotBeNull();
            resultCast.Should().BeTrue();
        }
Пример #5
0
        public void Equals_Success()
        {
            // Arrange
            var obj      = new object();
            var metadata = new UriMetadata("someType", obj)
            {
                Type = typeof(string)
            };
            var metadata2 = new UriMetadata("someType", obj)
            {
                Type = typeof(int)
            };

            // Act

            // Assert
            metadata.Equals(metadata2).Should().BeTrue();
        }
Пример #6
0
        public void TypedMetaTest(IEnumerable <UriPathDescriptor> linkDescriptors, string url, UriMetadata expectedResult)
        {
            // Arrange
            var urlParser = new UriPathScanf(linkDescriptors);

            // Act
            var result      = urlParser.ScanAll(url);
            var resultTyped = urlParser.Scan <UriPathScanfTestSource.TestTypedMetadata>(url);

            // Assert
            if (expectedResult != null)
            {
                result.UriType.Should().BeEquivalentTo(expectedResult.UriType);
                result.Type.Should().Be(expectedResult.Type);

                result.TryCast <UriPathScanfTestSource.TestTypedMetadata>(out var resultCasted);
                resultCasted.Should().BeEquivalentTo(expectedResult.Meta);

                resultTyped.Meta.Should().BeEquivalentTo(expectedResult.Meta);
            }
            else
            {
                result.Should().BeNull();
                resultTyped.Should().BeNull();
            }
        }
Пример #7
0
 private static void Assert(UriMetadata result, IDictionary <string, string> metaResult)
 {
     Debug.Assert(metaResult["varOne"] == "12314");
     Debug.Assert(metaResult["qs__x"] == "123");
     Debug.Assert(result.UriType == "varOneLink");
 }