Exemplo n.º 1
0
        public void ReadJsonShouldReturnEmptyPasswordStringWhenExceptionWasThrown()
        {
            // Arrange
            var sut    = new PasswordStringConverter();
            var reader = Substitute.For <JsonReader>();

            reader.Value.Throws(new Exception());

            // Act
            var actual = sut.ReadJson(reader, typeof(PasswordString), new PasswordString(), false, JsonSerializer.CreateDefault());

            // Assert
            Assert.Empty(actual.PlainText());
        }
Exemplo n.º 2
0
        public void ReadJsonShouldReturnValidPasswordString()
        {
            // Arrange
            var          sut      = new PasswordStringConverter();
            var          reader   = Substitute.For <JsonReader>();
            const string expected = "foobar";

            reader.Value.Returns(PasswordString.FromPlainText(expected).Encrypted());

            // Act
            var actual = sut.ReadJson(reader, typeof(PasswordString), new PasswordString(), false, JsonSerializer.CreateDefault());

            // Assert
            Assert.Equal(expected, actual.PlainText());
        }
Exemplo n.º 3
0
        public void ReadJsonShouldReturnEmptyPasswordStringWhenValueIsEmpty()
        {
            // Arrange
            var          sut      = new PasswordStringConverter();
            var          reader   = Substitute.For <JsonReader>();
            const string expected = "";

            reader.Value.Returns(expected);

            // Act
            var actual = sut.ReadJson(reader, typeof(PasswordString), new PasswordString(), false, JsonSerializer.CreateDefault());

            // Assert
            Assert.Empty(actual.PlainText());
        }