本文整理汇总了C#中Settings.SetEncryptedValue方法的典型用法代码示例。如果您正苦于以下问题:C# Settings.SetEncryptedValue方法的具体用法?C# Settings.SetEncryptedValue怎么用?C# Settings.SetEncryptedValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Settings
的用法示例。
在下文中一共展示了Settings.SetEncryptedValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UserSettingsExtentions_GetEncryptedValue
public void UserSettingsExtentions_GetEncryptedValue()
{
// Arrange
var mockFileSystem = new MockFileSystem();
Settings settings = new Settings(mockFileSystem);
settings.SetEncryptedValue("SectionName", "key", "value");
// Act
var result = settings.GetDecryptedValue("SectionName", "key");
// Assert
Assert.Equal("value", result);
}
示例2: UserSettingsExtentions_GetEncryptedValue
public void UserSettingsExtentions_GetEncryptedValue()
{
// Arrange
var mockFileSystem = new Mock<IFileSystem>();
var nugetConfigPath = "NuGet.Config";
mockFileSystem.Setup(m => m.FileExists(@"c:\users\bob\appdata\roaming\NuGet\Nuget.Config")).Returns(false);
var ms = new MemoryStream();
mockFileSystem.Setup(m => m.AddFile(nugetConfigPath, It.IsAny<Stream>())).Callback<string, Stream>((path, stream) =>
{
stream.CopyTo(ms);
ms.Seek(0, SeekOrigin.Begin);
});
Settings settings = new Settings(mockFileSystem.Object);
settings.SetEncryptedValue("SectionName", "key", "value");
// Act
var result = settings.GetDecryptedValue("SectionName", "key");
// Assert
Assert.Equal("value", result);
}
示例3: UserSettingsExtentions_SetEncryptedValue
public void UserSettingsExtentions_SetEncryptedValue()
{
// Arrange
var mockFileSystem = new MockFileSystem();
var nugetConfigPath = "NuGet.Config";
string config = @"<?xml version=""1.0"" encoding=""utf-8""?>
<configuration>
<SectionName>
<add key=""key"" value=""value"" />
</SectionName>
</configuration>";
mockFileSystem.AddFile(nugetConfigPath, config);
Settings settings = new Settings(mockFileSystem);
// Act
settings.SetEncryptedValue("SectionName", "key", "NewValue");
// Assert
var content = mockFileSystem.ReadAllText(nugetConfigPath);
Assert.False(content.Contains("NewValue"));
}
示例4: UserSettingsExtentions_SetEncryptedValue
public void UserSettingsExtentions_SetEncryptedValue()
{
// Arrange
var mockFileSystem = new Mock<IFileSystem>();
var nugetConfigPath = "NuGet.Config";
mockFileSystem.Setup(m => m.FileExists(nugetConfigPath)).Returns(true);
var ms = new MemoryStream();
mockFileSystem.Setup(m => m.AddFile(nugetConfigPath, It.IsAny<Stream>())).Callback<string, Stream>((path, stream) =>
{
stream.CopyTo(ms);
ms.Seek(0, SeekOrigin.Begin);
});
string config = @"<?xml version=""1.0"" encoding=""utf-8""?>
<configuration>
<SectionName>
<add key=""key"" value=""value"" />
</SectionName>
</configuration>";
mockFileSystem.Setup(m => m.OpenFile(nugetConfigPath)).Returns(config.AsStream());
Settings settings = new Settings(mockFileSystem.Object);
// Act
settings.SetEncryptedValue("SectionName", "key", "NewValue");
// Assert
Assert.False(ms.ReadToEnd().Contains("NewValue"), "Value Should Be Ecrypted and Base64 encoded.");
}