Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ private protected HttpCapabilitiesBase(BrowserCapabilitiesFactory factory, strin
public string? Platform => _data["platform"];

public bool Crawler => _data.GetBoolean("crawler");

public bool IsMobileDevice => _data.GetBoolean("isMobileDevice");
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public partial class HttpBrowserCapabilitiesBase
public HttpBrowserCapabilitiesBase() { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
public virtual string Browser { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} }
public virtual bool Crawler { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} }
public virtual bool IsMobileDevice { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} }
public virtual int MajorVersion { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} }
public virtual double MinorVersion { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} }
public virtual string Platform { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} }
Expand All @@ -37,6 +38,7 @@ public partial class HttpBrowserCapabilitiesWrapper : System.Web.HttpBrowserCapa
public HttpBrowserCapabilitiesWrapper(System.Web.HttpBrowserCapabilities capabilities) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
public override string Browser { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} }
public override bool Crawler { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} }
public override bool IsMobileDevice { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} }
public override int MajorVersion { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} }
public override double MinorVersion { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} }
public override string Platform { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} }
Expand Down Expand Up @@ -511,6 +513,7 @@ public partial class HttpCapabilitiesBase
internal HttpCapabilitiesBase() { }
public string Browser { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} }
public bool Crawler { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} }
public bool IsMobileDevice { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} }
public int MajorVersion { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} }
public double MinorVersion { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} }
public string Platform { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ public class HttpBrowserCapabilitiesBase
public virtual string? Platform => throw new NotImplementedException();

public virtual bool Crawler => throw new NotImplementedException();

public virtual bool IsMobileDevice => throw new NotImplementedException();
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ public HttpBrowserCapabilitiesWrapper(HttpBrowserCapabilities capabilities)
public override string? Version => _capabilities.Version;

public override bool Crawler => _capabilities.Crawler;

public override bool IsMobileDevice => _capabilities.IsMobileDevice;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.Web.Configuration;
using Xunit;
Expand All @@ -26,6 +27,7 @@ public void VerifyCapabilities(TestData data)
Assert.Equal(data.MajorVersion, result["majorversion"]);
Assert.Equal(data.MinorVersion, result["minorversion"]);
Assert.Equal(data.Platform, result["platform"]);
Assert.Equal(data.IsMobileDevice, Convert.ToBoolean(result["isMobileDevice"]));
}

[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1034:Nested types should not be visible", Justification = "Used for tests")]
Expand All @@ -43,6 +45,8 @@ public record TestData(string UserAgent)

public string? Crawler { get; init; }

public bool IsMobileDevice { get; init; }

public override string ToString() => UserAgent;
}

Expand All @@ -59,6 +63,7 @@ public static IEnumerable<object[]> UserAgentTestData
MajorVersion = "102",
MinorVersion = "0",
Platform = "WinNT",
IsMobileDevice = false
}
};

Expand All @@ -71,6 +76,7 @@ public static IEnumerable<object[]> UserAgentTestData
MajorVersion = "102",
MinorVersion = "0",
Platform = "Unknown",
IsMobileDevice = false
}
};

Expand All @@ -83,6 +89,7 @@ public static IEnumerable<object[]> UserAgentTestData
MajorVersion = "0",
MinorVersion = "0",
Platform = "Unknown",
IsMobileDevice = true
}
};

Expand All @@ -95,6 +102,7 @@ public static IEnumerable<object[]> UserAgentTestData
MajorVersion = "0",
MinorVersion = "0",
Platform = "Unknown",
IsMobileDevice = true
}
};

Expand All @@ -107,6 +115,7 @@ public static IEnumerable<object[]> UserAgentTestData
MajorVersion = "0",
MinorVersion = "0",
Platform = "Unknown",
IsMobileDevice = true
}
};

Expand All @@ -119,6 +128,7 @@ public static IEnumerable<object[]> UserAgentTestData
MajorVersion = "102",
MinorVersion = "0",
Platform = "Unknown",
IsMobileDevice = true
}
};

Expand All @@ -131,6 +141,7 @@ public static IEnumerable<object[]> UserAgentTestData
MajorVersion = "102",
MinorVersion = "0",
Platform = "Unknown",
IsMobileDevice = true
}
};

Expand All @@ -144,6 +155,7 @@ public static IEnumerable<object[]> UserAgentTestData
MajorVersion = "53",
MinorVersion = "0",
Platform = "WinNT",
IsMobileDevice = false
}
};

Expand All @@ -156,6 +168,7 @@ public static IEnumerable<object[]> UserAgentTestData
MajorVersion = "101",
MinorVersion = "0",
Platform = "Unknown",
IsMobileDevice = false
}
};

Expand All @@ -168,6 +181,7 @@ public static IEnumerable<object[]> UserAgentTestData
MajorVersion = "9",
MinorVersion = "0",
Platform = "WinNT",
IsMobileDevice = false
}
};
yield return new object[]
Expand All @@ -179,6 +193,7 @@ public static IEnumerable<object[]> UserAgentTestData
MajorVersion = "10",
MinorVersion = "0",
Platform = "WinNT",
IsMobileDevice = false
}
};

Expand All @@ -191,6 +206,7 @@ public static IEnumerable<object[]> UserAgentTestData
MajorVersion = "51",
MinorVersion = "0",
Platform = "WinNT",
IsMobileDevice = false
}
};

Expand All @@ -203,6 +219,7 @@ public static IEnumerable<object[]> UserAgentTestData
MajorVersion = "102",
MinorVersion = "0",
Platform = "WinNT",
IsMobileDevice = false
}
};
}
Expand Down