コード例 #1
0
        public void When_TokenIsPassed_ReplaceToken_Should_ReplaceTokenInConfigXml()
        {
            LoadWebConfigAsXmlDocument();
            var token = new KeyValuePair <string, string>("BP_Token1", "TestValue");

            var xmlContent = @"
                <?xml version='1.0' encoding='utf - 8' ?>
                <configuration>
                    <foo>
                        <bar baz='#{BP_Token1}'></bar>
                      </ foo >
                </configuration>
            ";

            _xmlDocumentWrapperMock
            .Setup(x => x.ConvertXmlDocToString(It.IsAny <XmlDocument>()))
            .Returns(xmlContent);

            _writer.InitializeWebConfigForTokenReplacements();
            _writer.ReplaceToken(token.Key, token.Value);

            var actual = _writer.ValueExistsInXmlDoc(token.Key);

            actual.Should().BeFalse();

            actual = _writer.ValueExistsInXmlDoc(token.Value);
            actual.Should().BeTrue();
        }