Exemplo n.º 1
0
        public async Task FindBinaryAsyncTest()
        {
            IBinaryLocator locator = GetLocator();
            Task <string>  first   = locator.FindBinaryAsync(WellKnownDac, WellKnownDacTimeStamp, WellKnownDacImageSize, false);

            List <Task <string> > tasks = new List <Task <string> >();

            for (int i = 0; i < 10; i++)
            {
                tasks.Add(locator.FindBinaryAsync(WellKnownDac, WellKnownDacTimeStamp, WellKnownDacImageSize, false));
            }

            string dac = await first;

            Assert.NotNull(dac);
            Assert.True(File.Exists(dac));
            using (Stream stream = File.OpenRead(dac))
            {
                PEImage peimage = new PEImage(stream);
                Assert.True(peimage.IsValid);
            }

            // Ensure we got the same answer for everything.
            foreach (Task <string> task in tasks)
            {
                string taskDac = await task;
                Assert.Equal(dac, taskDac);
            }
        }
Exemplo n.º 2
0
        public async Task FindBinaryAsyncNegativeTest()
        {
            IBinaryLocator locator = GetLocator();

            List <Task <string> > tasks = new List <Task <string> >();

            for (int i = 0; i < 10; i++)
            {
                tasks.Add(locator.FindBinaryAsync(WellKnownDac, WellKnownDacTimeStamp + 1, WellKnownDacImageSize + 1, false));
            }

            // Ensure we got the same answer for everything.
            foreach (Task <string> task in tasks)
            {
                string dac = await task;
                Assert.Null(dac);
            }
        }