Example #1
0
        public void IsWindowsStore()
        {
            bool isWindowsStore = WindowsStore.IsWindowsStoreApplication();

#if WINRT
            isWindowsStore.Should().BeTrue();
#else
            isWindowsStore.Should().BeFalse();
#endif
        }
Example #2
0
        public void CreateStreamSystemIoDefines()
        {
            using var cleaner = new TestFileCleaner();
            string filePath = cleaner.GetTestPath();

            using var stream = Storage.CreateFileStream(
                      path: filePath,
                      fileAccess: FileAccess.Write,
                      fileShare: FileShare.ReadWrite,
                      fileMode: FileMode.Append,
                      fileAttributes: 0,
                      securityFlags: WindowsStore.IsWindowsStoreApplication()
                    ? SecurityQosFlags.None
                    : SecurityQosFlags.QosPresent | SecurityQosFlags.Anonymous);
            stream.Should().NotBeNull();
        }
Example #3
0
 public static void ValidateStoreGetsUnauthorizedAccess(Action action)
 {
     try
     {
         action();
         if (WindowsStore.IsWindowsStoreApplication())
         {
             throw new InvalidOperationException("Should not succeed if Windows Store app");
         }
     }
     catch (UnauthorizedAccessException)
     {
         if (!WindowsStore.IsWindowsStoreApplication())
         {
             throw new InvalidOperationException("Should succeed if not Windows Store app");
         }
     }
 }