Exemple #1
0
            public void Should_return_validation_error()
            {
                const string uniqueId = "ABC123";

                var student = new global::EdFi.Ods.Entities.NHibernate.StudentAggregate.EdFi.Student
                {
                    Id = Guid.NewGuid(),
                    StudentUniqueId = 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.");
            }
Exemple #2
0
            public void Should_pass_validation()
            {
                const string uniqueId = "ABC123";

                var student = new global::EdFi.Ods.Entities.NHibernate.StudentAggregate.EdFi.Student
                {
                    Id = Guid.NewGuid(),
                    StudentUniqueId = 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();
            }