public void SideloadAppxPackageTest_SideLoadWorkingFile()
        {
            // create a dummy test file
            string path = Path.GetTempPath() + "workingTestFile.appx";

            if (File.Exists(path))
            {
                File.Delete(path);
            }
            using (FileStream fileStream = File.Create(path))
            {
                Byte[] content = new UTF8Encoding(true).GetBytes("Dummy content for test case.");
                fileStream.Write(content, 0, content.Length);
            }

            MsIotApiWrapper msIotApiWrapper = new MsIotApiWrapper("127.0.0.1", "user", "password", new MockHttpMessageHandler());

            msIotApiWrapper.SideloadSuccessPollIntervalMillisecs = 10;
            msIotApiWrapper.SideloadAppxPackage(path);
        }
        public void SideloadAppxPackageTest_SideLoadNotWorkingFile()
        {
            // create a dummy test file
            string path = Path.GetTempPath() + "notWorkingTestFile.appx";

            if (File.Exists(path))
            {
                File.Delete(path);
            }
            using (FileStream fileStream = File.Create(path))
            {
                Byte[] content = new UTF8Encoding(true).GetBytes("Dummy content for test case.");
                fileStream.Write(content, 0, content.Length);
            }

            MsIotApiWrapper msIotApiWrapper = new MsIotApiWrapper("127.0.0.1", "user", "password", new MockHttpMessageHandler());

            msIotApiWrapper.SideloadSuccessPollIntervalMillisecs = 10; // speed ups the poll a little
            AggregateException exception = Assert.Throws <AggregateException>(() => msIotApiWrapper.SideloadAppxPackage(path));

            Assert.That(exception.InnerException.Message.Contains("Uploaded file could not be processed"));
        }
        public void SideloadAppxPackageTest_SideLoadTimesOut()
        {
            // create a dummy test file
            string path = Path.GetTempPath() + "timeoutTestFile.appx";

            if (File.Exists(path))
            {
                File.Delete(path);
            }
            using (FileStream fileStream = File.Create(path))
            {
                Byte[] content = new UTF8Encoding(true).GetBytes("Dummy content for test case.");
                fileStream.Write(content, 0, content.Length);
            }

            MsIotApiWrapper msIotApiWrapper = new MsIotApiWrapper("127.0.0.1", "user", "password", new MockHttpMessageHandler());

            // make timeout occur earlier than normal
            msIotApiWrapper.SideloadSuccessPollIntervalMillisecs = 100; // polls every 100ms for success
            msIotApiWrapper.SideloadSuccessTimeoutMillisecs      = 500; // timeout after 500ms => 5 requests
            AggregateException exception = Assert.Throws <AggregateException>(() => msIotApiWrapper.SideloadAppxPackage(path));

            Assert.That(exception.InnerException.Message.Contains("The operation timed out"));
        }