예제 #1
0
        public void GetEnumerator_ShouldEnumerate_WhenTypeIsNotSpecified()
        {
            // Arrange
            const string data = "Data with - oh no - UNICODE!!  이 테스트는 대단합니다";
            var          i    = 0;

            using (var secureData = new SecureString())
            {
                secureData.Append(data);
                secureData.MakeReadOnly();
                using (var subject = new InsecureCharArray(secureData))
                {
                    // Act
                    foreach (var o in (IEnumerable)subject)
                    {
                        // Assert
                        o.Should().BeOfType <char>();

                        var c = (char)o;
                        c.Should().Be(data[i]);
                        i++;
                    }

                    i.Should().Be(data.Length);
                }
            }
        }
예제 #2
0
 public void GetEnumerator_ShouldNotEnumerate_WhenSecureStringHasNoData()
 {
     // Arrange
     using (var secureData = new SecureString())
     {
         secureData.MakeReadOnly();
         using (var subject = new InsecureCharArray(secureData))
         {
             // Act
             foreach (var c in subject)
             {
                 // Assert
                 Assert.True(false, "Should not enumerate.");
             }
         }
     }
 }
예제 #3
0
        public void Constructor_ShouldDecryptSecureString_WhenUnicodeIsPresent()
        {
            // Arrange
            const string data = "This is some random data, including unicode characters: ѬѾ";

            using (var secureData = new SecureString())
            {
                secureData.Append(data);
                secureData.MakeReadOnly();

                // Act
                using (var subject = new InsecureCharArray(secureData))
                {
                    // Assert
                    subject.Value.Should().Equal(data.ToCharArray());
                }
            }
        }
예제 #4
0
        public void Constructor_ShouldDecryptSecureString()
        {
            // Arrange
            const string data = "This is some random data";

            using (var secureData = new SecureString())
            {
                secureData.Append(data);
                secureData.MakeReadOnly();

                // Act
                using (var subject = new InsecureCharArray(secureData))
                {
                    // Assert
                    subject.Value.Should().Equal(data.ToCharArray());
                }
            }
        }
예제 #5
0
        public void GetEnumerator_ShouldEnumerate()
        {
            // Arrange
            const string data = "Data with - oh no - UNICODE!!  이 테스트는 대단합니다";
            var          i    = 0;

            using (var secureData = new SecureString())
            {
                secureData.Append(data);
                secureData.MakeReadOnly();
                using (var subject = new InsecureCharArray(secureData))
                {
                    // Act
                    foreach (var c in subject)
                    {
                        // Assert
                        c.Should().Be(data[i]);
                        i++;
                    }

                    i.Should().Be(data.Length);
                }
            }
        }