Ejemplo n.º 1
0
        public void SearchMusicByName_InsideTest()
        {
            ANative_SearchArg s = new ANative_SearchArg();

            s.Keywords = "bye bye bye";
            IntPtr sptr = Marshal.AllocHGlobal(Marshal.SizeOf(s));
            var    api  = new QQMusicAPI();

            //SearchResult result = api.SearchAsync(new SearchArg() { Keywords = "bye bye bye" }).Result;
            Marshal.StructureToPtr(s, sptr, false);
            byte[] buff = new byte[10000];
            unsafe
            {
                fixed(byte *v = &buff[0])
                {
                    IntPtr ptr = new IntPtr(v);

                    Wrapper.SearchMusicByName_Inside(sptr, ptr);
                    Native_SearchResult *f = (Native_SearchResult *)(ptr);
                    var songItem           = Marshal.PtrToStructure <Native_SongItem>(ptr + 12);

                    Assert.NotNull(songItem.singer_name);
                }
            }
        }
Ejemplo n.º 2
0
        public void DownloadMusic_InsideTest()
        {
            ANative_SearchArg s = new ANative_SearchArg();

            s.Keywords = "bye bye bye";
            IntPtr sptr = Marshal.AllocHGlobal(Marshal.SizeOf(s));
            var    api  = new QQMusicAPI();

            //SearchResult result = api.SearchAsync(new SearchArg() { Keywords = "bye bye bye" }).Result;
            Marshal.StructureToPtr(s, sptr, false);
            byte[] buff = new byte[10000];
            unsafe
            {
                fixed(byte *v = &buff[0])
                {
                    IntPtr ptr = new IntPtr(v);

                    Wrapper.SearchMusicByName_Inside(sptr, ptr);
                    Native_SearchResult *f = (Native_SearchResult *)(ptr);
                    var songItem           = Marshal.PtrToStructure <Native_SongItem>(ptr + 12);
                    //Assert.Equal("Lovestoned", songItem.singer_name);
                    string dir    = @"";
                    var    dirptr = Marshal.StringToCoTaskMemUni(dir);
                    var    r      = Wrapper.DownloadMusic_Inside(ptr + 12, EnumFileType.Mp3_128k, dirptr, dir.Length);

                    Assert.True(r);
                }
            }
        }