public void TestBadGeneric() { UserAgentAnnotationAnalyzer <object> userAgentAnalyzer = new UserAgentAnnotationAnalyzer <object>(); Action a = new Action(() => userAgentAnalyzer.Map("Foo")); a.Should().Throw <InvalidParserConfigurationException>().WithMessage("[Map] The mapper instance is null."); }
public void TestAnnotationCacheSetting1() { var mapper = new MyMapper(); var userAgentAnnotationAnalyzer = new UserAgentAnnotationAnalyzer <TestRecord>(); // To make sure the internals behave as expected var userAgentAnalyzerField = userAgentAnnotationAnalyzer.GetType().GetField("userAgentAnalyzer", BindingFlags.NonPublic | BindingFlags.Instance); userAgentAnalyzerField.GetValue(userAgentAnnotationAnalyzer).Should().BeNull(); // Initial value userAgentAnnotationAnalyzer.CacheSize.Should().Be(UserAgentAnalyzer.DEFAULT_PARSE_CACHE_SIZE); // Setting and getting while no UserAgentAnalyzer exists userAgentAnnotationAnalyzer.SetCacheSize(1234); userAgentAnnotationAnalyzer.CacheSize.Should().Be(1234); userAgentAnnotationAnalyzer.DisableCaching(); userAgentAnnotationAnalyzer.CacheSize.Should().Be(0); userAgentAnnotationAnalyzer.SetCacheSize(4567); userAgentAnnotationAnalyzer.CacheSize.Should().Be(4567); userAgentAnnotationAnalyzer.Initialize(new MyMapper()); var userAgentAnalyzer = (UserAgentAnalyzer)userAgentAnalyzerField.GetValue(userAgentAnnotationAnalyzer); userAgentAnalyzer.Should().NotBeNull(); // Setting and getting while there IS a UserAgentAnalyzer userAgentAnnotationAnalyzer.SetCacheSize(1234); userAgentAnnotationAnalyzer.CacheSize.Should().Be(1234); userAgentAnalyzer.CacheSize.Should().Be(1234); userAgentAnnotationAnalyzer.DisableCaching(); userAgentAnnotationAnalyzer.CacheSize.Should().Be(0); userAgentAnalyzer.CacheSize.Should().Be(0); userAgentAnnotationAnalyzer.SetCacheSize(4567); userAgentAnnotationAnalyzer.CacheSize.Should().Be(4567); userAgentAnalyzer.CacheSize.Should().Be(4567); }
public void TestNoInit() { UserAgentAnnotationAnalyzer <string> userAgentAnalyzer = new UserAgentAnnotationAnalyzer <string>(); userAgentAnalyzer.Invoking(u => u.Map("Foo")).Should().Throw <InvalidParserConfigurationException>().Which.Message.Should().StartWith("[Map] The mapper instance is null."); }
public void TestNullInit() { UserAgentAnnotationAnalyzer <string> userAgentAnalyzer = new UserAgentAnnotationAnalyzer <string>(); userAgentAnalyzer.Map(null).Should().BeNull(); }
public UserAgentMapper() { userAgentAnalyzer = new UserAgentAnnotationAnalyzer <IUserAgentModel>(); userAgentAnalyzer.Initialize(this); }
/// <summary> /// Initializes a new instance of the <see cref="MyBaseMapper"/> class. /// </summary> public MyBaseMapper() { userAgentAnalyzer = new UserAgentAnnotationAnalyzer <TestRecord>(); userAgentAnalyzer.Initialize(this); }