public void Should_return_validation_error() { const string uniqueId = "ABC123"; var student = new global::EdFi.Ods.Entities.NHibernate.StaffAggregate.EdFi.Staff { Id = Guid.NewGuid(), StaffUniqueId = uniqueId + "XYZ" }; var personUniqueIdToIdCache = Stub <IPersonUniqueIdToIdCache>(); var validator = new UniqueIdNotChangedEntityValidator(personUniqueIdToIdCache); A.CallTo(() => personUniqueIdToIdCache.GetUniqueId(A <string> ._, A <Guid> ._)) .Returns(uniqueId); var result = validator.ValidateObject(student); result.IsValid() .ShouldBeFalse(); result.Count.ShouldBe(1); result.First() .ErrorMessage.ShouldBe("A person's UniqueId cannot be modified."); }
public void Should_pass_validation() { const string uniqueId = "ABC123"; var student = new global::EdFi.Ods.Entities.NHibernate.StaffAggregate.EdFi.Staff { Id = Guid.NewGuid(), StaffUniqueId = uniqueId }; var personUniqueIdToIdCache = Stub <IPersonUniqueIdToIdCache>(); var validator = new UniqueIdNotChangedEntityValidator(personUniqueIdToIdCache); A.CallTo(() => personUniqueIdToIdCache.GetUniqueId(A <string> ._, A <Guid> ._)) .Returns(uniqueId); var result = validator.ValidateObject(student); result.IsValid() .ShouldBeTrue(); }