public void Test_LoadCustomCodecs() { MockRepository mocks = new MockRepository(); // Set new EsapiConfig.Instance.Encoder.Type = typeof(SurrogateEncoder).AssemblyQualifiedName; // Set codecs to load string[] codecNames = new [] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }; foreach (string codecName in codecNames) { CodecElement codecElement = new CodecElement(); codecElement.Name = codecName; codecElement.Type = typeof(SurrogateCodec).AssemblyQualifiedName; EsapiConfig.Instance.Encoder.Codecs.Add(codecElement); } // Set mock expectations IEncoder mockEncoder = mocks.StrictMock <IEncoder>(); // Custom codecs are loaded and are of proper type foreach (string codecName in codecNames) { Expect.Call(delegate { mockEncoder.AddCodec(codecName, null); }).Constraints(Is.Equal(codecName), Is.TypeOf <SurrogateCodec>()); } mocks.ReplayAll(); // Create and test SurrogateEncoder.DefaultEncoder = mockEncoder; IEncoder encoder = Esapi.Encoder; Assert.IsTrue(encoder.GetType().Equals(typeof(SurrogateEncoder))); mocks.VerifyAll(); }
/// <summary> /// Removes the specified <see cref="CodecElement"/>. /// </summary> /// <param name="codec">The <see cref="CodecElement"/> to remove.</param> public void Remove(CodecElement codec) { base.BaseRemove(codec); }
/// <summary> /// Adds the specified <see cref="CodecElement"/>. /// </summary> /// <param name="codec">The <see cref="CodecElement"/> to add.</param> public void Add(CodecElement codec) { base.BaseAdd(codec); }
public void Test_LoadCustomCodecs() { MockRepository mocks = new MockRepository(); // Set new EsapiConfig.Instance.Encoder.Type = typeof(SurrogateEncoder).AssemblyQualifiedName; // Set codecs to load string[] codecNames = new [] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }; foreach (string codecName in codecNames) { CodecElement codecElement = new CodecElement(); codecElement.Name = codecName; codecElement.Type = typeof(SurrogateCodec).AssemblyQualifiedName; EsapiConfig.Instance.Encoder.Codecs.Add(codecElement); } // Set mock expectations IEncoder mockEncoder = mocks.StrictMock<IEncoder>(); // Custom codecs are loaded and are of proper type foreach (string codecName in codecNames) { Expect.Call(delegate { mockEncoder.AddCodec(codecName, null); }).Constraints(Is.Equal(codecName), Is.TypeOf<SurrogateCodec>()); } mocks.ReplayAll(); // Create and test SurrogateEncoder.DefaultEncoder = mockEncoder; IEncoder encoder = Esapi.Encoder; Assert.IsTrue(encoder.GetType().Equals(typeof(SurrogateEncoder))); mocks.VerifyAll(); }
/// <summary> /// Removes the specified <see cref="CodecElement" />. /// </summary> /// <param name="codec">The <see cref="CodecElement" /> to remove.</param> public void Remove(CodecElement codec) { this.BaseRemove(codec); }
/// <summary> /// Adds the specified <see cref="CodecElement" />. /// </summary> /// <param name="codec">The <see cref="CodecElement" /> to add.</param> public void Add(CodecElement codec) { this.BaseAdd(codec); }