Exemplo n.º 1
0
        public void WriteAsFile_Throws_Expected_Exception_For_Invalid_resourceName()
        {
            // Arrange
            var invalidResourceName = Guid.NewGuid().ToString();
            var writeFileName       = Path.Combine(_diTestDir.FullName, "embedded_write.txt");

            // overload with only resource name

            // Arrange
            var testee = new EmbeddedResource(invalidResourceName);

            // Act & Assert
            testee.Invoking(t => t.WriteAsFile(writeFileName)).Should().Throw <MissingManifestResourceException>();


            // overload with AssemblyName and resource name

            // Arrange
            testee = new EmbeddedResource(_assembly.GetName(), invalidResourceName);

            // Act & Assert
            testee.Invoking(t => t.WriteAsFile(writeFileName)).Should().Throw <MissingManifestResourceException>();


            // overload with assembly name and resource name

            // Arrange
            testee = new EmbeddedResource(_assembly.GetName().Name, invalidResourceName);

            // Act & Assert
            testee.Invoking(t => t.WriteAsFile(writeFileName)).Should().Throw <MissingManifestResourceException>();


            // overload with assembly and resource name

            // Arrange
            testee = new EmbeddedResource(_assembly, invalidResourceName);

            // Act & Assert
            testee.Invoking(t => t.WriteAsFile(writeFileName)).Should().Throw <MissingManifestResourceException>();
        }
Exemplo n.º 2
0
        public void ReadContentsAsString_Throws_Expected_Exception_For_Invalid_resourceName()
        {
            // Arrange
            var invalidResourceName = Guid.NewGuid().ToString();

            // overload with only resource name

            // Arrange
            var testee = new EmbeddedResource(invalidResourceName);

            // Act & Assert
            testee.Invoking(t => t.ReadContentsAsString()).Should().Throw <MissingManifestResourceException>();


            // overload with AssemblyName and resource name

            // Arrange
            testee = new EmbeddedResource(_assembly.GetName(), invalidResourceName);

            // Act & Assert
            testee.Invoking(t => t.ReadContentsAsString()).Should().Throw <MissingManifestResourceException>();


            // overload with assembly name and resource name

            // Arrange
            testee = new EmbeddedResource(_assembly.GetName().Name, invalidResourceName);

            // Act & Assert
            testee.Invoking(t => t.ReadContentsAsString()).Should().Throw <MissingManifestResourceException>();


            // overload with assembly and resource name

            // Arrange
            testee = new EmbeddedResource(_assembly, invalidResourceName);

            // Act & Assert
            testee.Invoking(t => t.ReadContentsAsString()).Should().Throw <MissingManifestResourceException>();
        }