Skip to content

Commit

Permalink
Updated DialogGenerator to match Rules set by validators
Browse files Browse the repository at this point in the history
Fixed CreateDialogCommandValidator check for TransmissionOpened
  • Loading branch information
Fargekritt committed Sep 10, 2024
1 parent e8c92d8 commit 480e770
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,22 @@ public CreateDialogDialogActivityDtoValidator(
// .WithMessage($"{nameof(DialogActivityType.Values.DialogOpened)} is not allowed on a transmission.")
.WithMessage($"A {nameof(DialogActivityType.Values.DialogOpened)} activity cannot reference a transmission.") // er det dette "rett" feilmelding?
.When(x => x.Type == DialogActivityType.Values.DialogOpened);
RuleFor(x => x.TransmissionId)
.NotNull()
.WithMessage($"A {nameof(DialogActivityType.Values.TransmissionOpened)} needs to reference a transmission.")
.When(x => x.Type == DialogActivityType.Values.TransmissionOpened);
// Testene feilet av denne. var den for streng?
// Sier jeg her at når transmissionId != null MÅ Type == TransmissionOpened?
// Sier ikke den fra notification det samme?
// RuleFor(x => x.TransmissionId)
// .NotNull()
// .WithMessage($"A {nameof(DialogActivityType.Values.TransmissionOpened)} needs to reference a transmission.")
// .When(x => x.Type == DialogActivityType.Values.TransmissionOpened);
// ====================== REF FRA NOTIFI =========
// RuleFor(x => x.TransmissionId)
// .NotNull()
// .NotEqual(default(Guid))
// .When(x => x.ActivityType == DialogActivityType.Values.TransmissionOpened);
// ===================== END REF ===================
RuleFor(x => x.Type)
.Equal(DialogActivityType.Values.TransmissionOpened)
.When(x => x.TransmissionId != null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,12 @@ public static List<CreateDialogDialogTransmissionDto> GenerateFakeDialogTransmis
public static List<CreateDialogDialogActivityDto> GenerateFakeDialogActivities(int? count = null, DialogActivityType.Values? type = null)
{
return new Faker<CreateDialogDialogActivityDto>()
.RuleFor(o => o.Id, f => Uuid7.NewUuid7().ToGuid(true))
.RuleFor(o => o.CreatedAt, f => f.Date.Past())
.RuleFor(o => o.ExtendedType, f => new Uri(f.Internet.UrlWithPath()))
.RuleFor(o => o.Type, f => type ?? f.PickRandom<DialogActivityType.Values>())
.RuleFor(o => o.PerformedBy, f => new CreateDialogDialogActivityPerformedByActorDto { ActorType = ActorType.Values.PartyRepresentative, ActorName = f.Name.FullName() })
.RuleFor(o => o.Description, (f, o) => o.Type == DialogActivityType.Values.Information ? GenerateFakeLocalizations(f.Random.Number(4, 8)) : null)
.RuleFor(o => o.Id, () => type == DialogActivityType.Values.DialogOpened ? null : Uuid7.NewUuid7().ToGuid(true))
.Generate(count ?? new Randomizer().Number(1, 4));
}

Expand Down

0 comments on commit 480e770

Please sign in to comment.