|
| 1 | +using Microsoft.VisualStudio.TestPlatform.Utilities; |
| 2 | +using NUnit.Framework; |
| 3 | +using System; |
| 4 | +using System.Collections.Generic; |
| 5 | +using System.IO; |
| 6 | +using System.Linq; |
| 7 | +using System.Text; |
| 8 | +using System.Threading.Tasks; |
| 9 | + |
| 10 | +namespace LCT.Common.UTest |
| 11 | +{ |
| 12 | + [TestFixture] |
| 13 | + public class TelemetryHelperTests |
| 14 | + { |
| 15 | + private TelemetryHelper telemetryHelper; |
| 16 | + private CommonAppSettings appSettings; |
| 17 | + private readonly StringWriter consoleOutput; |
| 18 | + [SetUp] |
| 19 | + public void Setup() |
| 20 | + { |
| 21 | + // Initialize real instances of your services |
| 22 | + appSettings = new CommonAppSettings |
| 23 | + { |
| 24 | + Telemetry=new Telemetry { ApplicationInsightInstrumentKey= "R1WvRUkY0I6Z" }, |
| 25 | + SW360 = new SW360 |
| 26 | + { |
| 27 | + ProjectName = "ProjectName", |
| 28 | + ProjectID = "ProjectID" |
| 29 | + }, |
| 30 | + ProjectType = "ProjectType" |
| 31 | + }; |
| 32 | + |
| 33 | + // Initialize your telemetry service (this will be the class under test) |
| 34 | + telemetryHelper = new TelemetryHelper(appSettings); |
| 35 | + } |
| 36 | + [TearDown] |
| 37 | + public void TearDown() |
| 38 | + { |
| 39 | + consoleOutput.Dispose(); |
| 40 | + Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = true }); |
| 41 | + |
| 42 | + } |
| 43 | + //[Test] |
| 44 | + //public void StartTelemetry_ShouldInitializeAndTrackEvent_WhenTelemetryIsEnabled() |
| 45 | + //{ |
| 46 | + // // Arrange |
| 47 | + // string catoolVersion = "1.0.0"; |
| 48 | + // var kpiData = new { Metric1 = 100, Metric2 = 200 }; // Example KPI data |
| 49 | + // string telemetryFor = "TestEvent"; |
| 50 | + // var consoleOutput = new System.IO.StringWriter(); |
| 51 | + // Console.SetOut(consoleOutput); |
| 52 | + // // Act |
| 53 | + // // This would normally start telemetry tracking in your system |
| 54 | + // telemetryHelper.StartTelemetry(catoolVersion, kpiData, telemetryFor); |
| 55 | + |
| 56 | + // string output = consoleOutput.ToString(); |
| 57 | + // Assert.AreEqual(output,""); |
| 58 | + //} |
| 59 | + } |
| 60 | +} |
0 commit comments