From f6cadfc0dc032a3a2ef4bd82217036b6ce5a410e Mon Sep 17 00:00:00 2001 From: Joao Rua Date: Tue, 2 Apr 2024 20:14:50 +0100 Subject: [PATCH] tests for participant validator --- .../ParticipantValidatorTestFixture.cs | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 COMETwebapp.Tests/Validators/EngineeringModel/ParticipantValidatorTestFixture.cs diff --git a/COMETwebapp.Tests/Validators/EngineeringModel/ParticipantValidatorTestFixture.cs b/COMETwebapp.Tests/Validators/EngineeringModel/ParticipantValidatorTestFixture.cs new file mode 100644 index 00000000..f22e80c8 --- /dev/null +++ b/COMETwebapp.Tests/Validators/EngineeringModel/ParticipantValidatorTestFixture.cs @@ -0,0 +1,64 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) 2023-2024 RHEA System S.A. +// +// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Antoine Théate, João Rua +// +// This file is part of CDP4-COMET WEB Community Edition +// The CDP4-COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C. +// +// The CDP4-COMET WEB Community Edition is free software; you can redistribute it and/or +// modify it under the terms of the GNU Affero General Public +// License as published by the Free Software Foundation; either +// version 3 of the License, or (at your option) any later version. +// +// The CDP4-COMET WEB Community Edition is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace COMETwebapp.Tests.Validators.EngineeringModel +{ + using CDP4Common.SiteDirectoryData; + using CDP4Common.Validation; + + using COMETwebapp.Validators.EngineeringModel; + + using NUnit.Framework; + + [TestFixture] + public class ParticipantValidatorTestFixture + { + private ParticipantValidator validator; + + [SetUp] + public void SetUp() + { + var validationService = new ValidationService(); + this.validator = new ParticipantValidator(validationService); + } + + [Test] + public void VerifyValidationScenarios() + { + var participant = new Participant(); + Assert.That(this.validator.Validate(participant).IsValid, Is.EqualTo(false)); + + participant = new Participant() + { + Role = new ParticipantRole(), + Person = new Person() + }; + + Assert.That(this.validator.Validate(participant).IsValid, Is.EqualTo(false)); + + participant.Domain = [new DomainOfExpertise()]; + Assert.That(this.validator.Validate(participant).IsValid, Is.EqualTo(true)); + } + } +}