public static void Init() { AssemblyName assembly = typeof(ModuleInitializer).Assembly.GetName(); KissLogPackage package = new KissLogPackage(assembly.Name, assembly.Version); KissLogConfiguration.KissLogPackages.Add(package); }
public void GetPrimaryPackageReturnsUnknownKissLogPackageIfNoPackageWasFound() { var container = new KissLogPackagesContainer(); KissLogPackage package = container.GetPrimaryPackage(); Assert.AreEqual(Constants.UnknownKissLogPackage.Name, package.Name); Assert.AreEqual(Constants.UnknownKissLogPackage.Version, package.Version); }
public void ConstructorUpdatesProperties() { string packageName = $"KissLog-{Guid.NewGuid()}"; Version version = Version.Parse("1.2.0"); var package = new KissLogPackage(packageName, version); Assert.AreEqual(packageName, package.Name); Assert.AreEqual(version.ToString(), package.Version.ToString()); }
public void GetPrimaryPackageReturnsTheFirstMatchingNonKissLogPackage() { var container = new KissLogPackagesContainer(); container.Add(new KissLogPackage("KissLog.WebApi", new Version(1, 5, 0))); container.Add(new KissLogPackage("KissLog.AspNetCore", new Version(2, 0, 0))); container.Add(new KissLogPackage("KissLog", new Version(1, 0, 0))); KissLogPackage package = container.GetPrimaryPackage(); Assert.AreEqual("KissLog.AspNetCore", package.Name); Assert.AreEqual(new Version(2, 0, 0), package.Version); }
public static CreateRequestLogRequest Create(FlushLogArgs args) { if (args == null) { throw new ArgumentNullException(nameof(args)); } KissLogPackage kissLogPackage = KissLogConfiguration.KissLogPackages.GetPrimaryPackage(); CreateRequestLogRequest result = new CreateRequestLogRequest(); result.SdkName = kissLogPackage.Name; result.SdkVersion = kissLogPackage.Version.ToString(); DateTime startDateTime = args.HttpProperties.Request.StartDateTime; DateTime endDateTime = args.HttpProperties.Response.EndDateTime; result.StartDateTime = startDateTime; result.DurationInMilliseconds = Math.Max(0, (endDateTime - startDateTime).TotalMilliseconds); result.WebRequest = Create(args.HttpProperties); result.MachineName = args.HttpProperties.Request.MachineName; result.IsNewSession = args.HttpProperties.Request.IsNewSession; result.SessionId = args.HttpProperties.Request.SessionId; result.IsAuthenticated = args.HttpProperties.Request.IsAuthenticated; result.User = CreateUser(args.HttpProperties.Request); IEnumerable <KissLog.LogMessage> logMessages = args.MessagesGroups.SelectMany(p => p.Messages).OrderBy(p => p.DateTime).ToList(); result.LogMessages = logMessages.Select(p => Create(p, startDateTime)).ToList(); result.Exceptions = args.Exceptions?.Select(p => Create(p)).ToList(); result.CustomProperties = args.CustomProperties.ToList(); return(result); }
public void ThrowsExceptionForNullVersion() { var package = new KissLogPackage("KissLog", null); }
public void ThrowsExceptionForNullName(string name) { var package = new KissLogPackage(name, new Version()); }