예제 #1
0
        public void NativeTypedefStructsGenerator_NegativeMultipleInvalidHandleValues_ValidAttributesGenerated()
        {
            // Arrange
            var methodNameToNamespacesMap = new Dictionary <string, string>
            {
                { "FindVolumeClose", "Windows.Win32.Storage.FileSystem" },
            };

            var autoTypes = new AutoType[]
            {
                new AutoType
                {
                    Name                = "FindVolumeHandle",
                    ValueType           = "IntPtr",
                    CloseApi            = "FindVolumeClose",
                    InvalidHandleValues = new long[] { long.MinValue, -1 }
                }
            };

            using var stream = new MemoryStream();
            var expectedAttributes = new[] {
                "[InvalidHandleValue(-9223372036854775808)]",
                "[InvalidHandleValue(-1)]",
            };

            // Act
            NativeTypedefStructsCreator.WriteToStream(methodNameToNamespacesMap, autoTypes, stream);

            // Assert
            AssertGeneratedStructStreamContainsAttributes(stream, expectedAttributes);
        }
예제 #2
0
        public void NativeTypedefStructsGenerator_PositiveMultipleInvalidHandleValues_ValidAttributesGenerated()
        {
            // Arrange
            var methodNameToNamespacesMap = new Dictionary <string, string>
            {
                { "JET_INSTANCE", "Windows.Win32.Storage.StructuredStorage" },
            };

            var autoTypes = new AutoType[]
            {
                new AutoType
                {
                    Name                = "FAUX_HANDLE",
                    ValueType           = "IntPtr",
                    Namespace           = "Windows.Win32.Nonexistent",
                    InvalidHandleValues = new long[] { long.MinValue, 0, long.MaxValue }
                }
            };

            using var stream = new MemoryStream();
            var expectedAttributes = new[] {
                "[InvalidHandleValue(-9223372036854775808)]",
                "[InvalidHandleValue(0)]",
                "[InvalidHandleValue(9223372036854775807)]",
            };

            // Act
            NativeTypedefStructsCreator.WriteToStream(methodNameToNamespacesMap, autoTypes, stream);

            // Assert
            AssertGeneratedStructStreamContainsAttributes(stream, expectedAttributes);
        }
예제 #3
0
        public void NativeTypedefStructsGenerator_PositiveSingularInvalidHandleValue_ValidAttributeGenerated()
        {
            // Arrange
            var methodNameToNamespacesMap = new Dictionary <string, string>
            {
                { "JET_INSTANCE", "Windows.Win32.Storage.StructuredStorage" },
            };

            var autoTypes = new AutoType[]
            {
                new AutoType {
                    Name = "FAUX_HANDLE", ValueType = "IntPtr", Namespace = "Windows.Win32.Nonexistent", InvalidHandleValues = new long[] { 1 }
                }
            };

            using var stream = new MemoryStream();
            var expectedAttribute = "[InvalidHandleValue(1)]";

            // Act
            NativeTypedefStructsCreator.WriteToStream(methodNameToNamespacesMap, autoTypes, stream);

            // Assert
            AssertGeneratedStructStreamContainsAttribute(stream, expectedAttribute);
        }