Exemple #1
0
        public void GetResourceStream()
        {
            var resourceStream = ResourceUtility.GetResourceStream(Assembly.GetExecutingAssembly(),
                                                                   "Remotion.Development.UnitTests.Core.UnitTesting.Resources.TestEmbeddedResource.txt");

            Assert.That(resourceStream.Length, Is.EqualTo(11));
        }
Exemple #2
0
        /// <summary>
        /// Loads an instance of <typeparamref name="T"/> asynchronously
        /// based on an existing file.
        /// </summary>
        /// <param name="file">The file name.</param>
        /// <param name="isInternal">Whether the file is embedded internally in the assembly
        /// or exists standalone on the file system.</param>
        /// <returns>Returns a task that represents an instance of <typeparamref name="T"/>.</returns>
        public async Task <T> LoadJsonAsync(string file, bool isInternal)
        {
            if (isInternal)
            {
                var stream = ResourceUtility.GetResourceStream(file);
                return(await SerializationUtility.DeserializeJsonAsync <T>(stream));
            }

            return(await SerializationUtility.DeserializeJsonAsync <T>(file));
        }
Exemple #3
0
        /// <summary>
        /// Loads an instance of <typeparamref name="T"/> based on
        /// an existing file.
        /// </summary>
        /// <param name="file">The file name.</param>
        /// <param name="isInternal">Whether the file is embedded internally in the assembly
        /// or exists standalone on the file system.</param>
        /// <returns>Returns an instance of <typeparamref name="T"/>.</returns>
        public T LoadJson(string file, bool isInternal)
        {
            if (isInternal)
            {
                var stream = ResourceUtility.GetResourceStream(file);
                return(SerializationUtility.DeserializeJson <T>(stream));
            }

            return(SerializationUtility.DeserializeJson <T>(file));
        }
Exemple #4
0
        public void GetResourceStream_WithType()
        {
            var resourceStream = ResourceUtility.GetResourceStream(GetType(), "TestEmbeddedResource.txt");

            Assert.That(resourceStream.Length, Is.EqualTo(11));
        }