public void Parse(string userAgent) { HttpUserAgentInformation ua1 = HttpUserAgentParser.Parse(userAgent); HttpUserAgentInformation ua2 = HttpUserAgentInformation.Parse(userAgent); ua1.Should().BeEquivalentTo(ua2); }
public void Parse(string userAgent) { HttpUserAgentParserDefaultProvider provider = new(); HttpUserAgentInformation providerUserAgentInfo = provider.Parse(userAgent); HttpUserAgentInformation userAgentInfo = HttpUserAgentInformation.Parse(userAgent); providerUserAgentInfo.Should().BeEquivalentTo(userAgentInfo); }
public void Get(string userAgent) { HttpUserAgentInformation userAgentInformation = HttpUserAgentInformation.Parse(userAgent); Mock <IHttpContextAccessor> httpMock = new(); { DefaultHttpContext context = new DefaultHttpContext(); context.Request.Headers["User-Agent"] = userAgent; httpMock.Setup(_ => _.HttpContext).Returns(context); } Mock <IHttpUserAgentParserProvider> parserMock = new(); { parserMock.Setup(x => x.Parse(userAgent)).Returns(userAgentInformation); } HttpUserAgentParserAccessor accessor = new HttpUserAgentParserAccessor(httpMock.Object, parserMock.Object); HttpUserAgentInformation info = accessor.Get(); info.Should().Be(userAgentInformation); parserMock.Verify(x => x.Parse(userAgent), Times.Once); }