inital
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
using C4IT.FASD.Base;
|
||||
using FasdDesktopUi.Basics.Services.RelationService;
|
||||
using FasdDesktopUi.Basics.Services.SupportCase;
|
||||
using NSubstitute;
|
||||
|
||||
namespace F4SD.Cockpit.Client.Test.Basics.Sevices.SupportCase;
|
||||
|
||||
public class SupportCaseTest
|
||||
{
|
||||
private readonly ISupportCase _supportCase;
|
||||
private readonly IRelationService _relationService;
|
||||
|
||||
public SupportCaseTest()
|
||||
{
|
||||
_relationService = Substitute.For<IRelationService>();
|
||||
cF4sdIdentityEntry primaryIdentity = new() { Class = enumFasdInformationClass.User, Id = Guid.NewGuid() };
|
||||
_supportCase = SupportCaseFactory.Get(primaryIdentity, _relationService, null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetCaseRelations_Contains_AddCaseRelations()
|
||||
{
|
||||
var actualRelations = _supportCase.GetCaseRelations();
|
||||
Assert.Empty(actualRelations);
|
||||
|
||||
ILookup<enumFasdInformationClass, cF4sdApiSearchResultRelation> relations = new List<cF4sdApiSearchResultRelation>()
|
||||
{
|
||||
new() { Type = enumF4sdSearchResultClass.Computer, Name = "My computer", Identities = [
|
||||
new() { Id = Guid.NewGuid(), Class = enumFasdInformationClass.Computer }
|
||||
] }
|
||||
}.ToLookup(r => cF4sdIdentityEntry.GetFromSearchResult(r.Type), r => r);
|
||||
|
||||
_supportCase.AddCaseRelations(relations);
|
||||
|
||||
actualRelations = _supportCase.GetCaseRelations();
|
||||
Assert.Single(actualRelations);
|
||||
Assert.Contains(relations.FirstOrDefault(), actualRelations);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddCaseRelations_Raise_CaseRelationsAdded()
|
||||
{
|
||||
ILookup<enumFasdInformationClass, cF4sdApiSearchResultRelation> relations = new List<cF4sdApiSearchResultRelation>()
|
||||
{
|
||||
new()
|
||||
{
|
||||
Type = enumF4sdSearchResultClass.Computer,
|
||||
Name = "My computer",
|
||||
Identities =
|
||||
[
|
||||
new() { Id = Guid.NewGuid(), Class = enumFasdInformationClass.Computer }
|
||||
]
|
||||
}
|
||||
}.ToLookup(r => cF4sdIdentityEntry.GetFromSearchResult(r.Type), r => r);
|
||||
|
||||
var raisedEvent = Assert.Raises<RelationEventArgs>(
|
||||
h => _supportCase.CaseRelationsAdded += h,
|
||||
h => _supportCase.CaseRelationsAdded -= h,
|
||||
() => _supportCase.AddCaseRelations(relations));
|
||||
|
||||
Assert.NotNull(raisedEvent);
|
||||
Assert.Equal(_supportCase, raisedEvent.Sender);
|
||||
Assert.Equal(relations, raisedEvent.Arguments.Relations);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user