Skip to content

Commit ce40ae0

Browse files
updated test cases
1 parent 6e87b44 commit ce40ae0

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed

src/LCT.APICommunications.UTest/MavenJFrogApiCommunicationUTest.cs

+12
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,17 @@ public void MavenJfrogApiCommunication_GetApiKey_ReturnsInvalidOperationExceptio
6262
//Assert
6363
Assert.ThrowsAsync<InvalidOperationException>(async () => await jfrogApicommunication.GetApiKey());
6464
}
65+
[Test]
66+
public void MavenJfrogApiCommunication_MoveFromRepo_ReturnsInvalidOperationException()
67+
{
68+
//Arrange
69+
ArtifactoryCredentials repoCredentials = new ArtifactoryCredentials();
70+
71+
//Act
72+
JfrogApicommunication jfrogApicommunication = new MavenJfrogApiCommunication("", "", repoCredentials, 100);
73+
74+
//Assert
75+
Assert.ThrowsAsync<InvalidOperationException>(async () => await jfrogApicommunication.MoveFromRepo(new ComponentsToArtifactory()));
76+
}
6577
}
6678
}

src/LCT.APICommunications.UTest/SW360ApicommunicationUTest.cs

+8
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,15 @@ public void SW360Apicommunication_GetComponentDetailsByUrl_ReturnsInvalidOperati
263263
//Assert
264264
Assert.ThrowsAsync<InvalidOperationException>(async () => await sW360Apicommunication.GetComponentDetailsByUrl(""));
265265
}
266+
[Test]
267+
public void SW360Apicommunication_GetComponentByName_ReturnsInvalidOperationException()
268+
{
269+
//Arrange & Act
270+
SW360Apicommunication sW360Apicommunication = new SW360Apicommunication(connectionSettings);
266271

272+
//Assert
273+
Assert.ThrowsAsync<InvalidOperationException>(async () => await sW360Apicommunication.GetComponentByName(""));
274+
}
267275
[Test]
268276
public void SW360Apicommunication_UpdateComponent_ReturnsInvalidOperationException()
269277
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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

Comments
 (0)