Esempio n. 1
0
        public IRule?Construct(ProjectReferenceRuleData data)
        {
            if (string.IsNullOrEmpty(data.Name))
            {
                return(null);
            }

            return(new ProjectReferenceRule(data));
        }
Esempio n. 2
0
        public void ProjectReferenceShouldNotBeConstructableWhenNameIsMissing()
        {
            // Arrange
            var data = new ProjectReferenceRuleData();
            var sut  = new RuleFactory();

            // Act
            var actual = sut.Construct(data);

            // Assert
            Assert.Null(actual);
        }
Esempio n. 3
0
        public void ProjectReferenceRuleShouldBeConstructable()
        {
            // Arrange
            var data = new ProjectReferenceRuleData
            {
                Name = Guid.NewGuid().ToString()
            };
            var sut = new RuleFactory();

            // Act
            var actual = sut.Construct(data);

            // Assert
            Assert.NotNull(actual);
        }
        public async Task ValidateShouldFailWhenRequiredReferenceIsMissing()
        {
            // Arrange
            var project = new ProjectBuilder().Build();

            var data = new ProjectReferenceRuleData
            {
                Required = true,
                Name     = "Project"
            };

            var sut = new ProjectReferenceRule(data);

            // Act
            var actual = await sut.Validate(project);

            // Assert
            Assert.True(actual.IsError);
        }
        public async Task ValidateShouldSucceedWhenOptionalReferenceIsMissing()
        {
            // Arrange
            var project = new ProjectBuilder().Build();

            var data = new ProjectReferenceRuleData
            {
                Required = false,
                Name     = "Project"
            };

            var sut = new ProjectReferenceRule(data);

            // Act
            var actual = await sut.Validate(project);

            // Assert
            Assert.False(actual.IsError);
        }
        public async Task ValidateShouldSucceedWhenOptionalProjectIsReferenced()
        {
            // Arrange
            var project = new ProjectBuilder()
                          .WithItemGroup()
                          .WithProjectReference("Project")
                          .Build();

            var data = new ProjectReferenceRuleData
            {
                Name     = "Project",
                Required = false
            };

            var sut = new ProjectReferenceRule(data);

            // Act
            var actual = await sut.Validate(project);

            // Assert
            Assert.False(actual.IsError);
        }
        public async Task ValidateShouldSucceedWhenNameMatchesButPathDoesNot()
        {
            // Arrange
            var project = new ProjectBuilder()
                          .WithItemGroup()
                          .WithProjectReference("Path/Project")
                          .Build();

            var data = new ProjectReferenceRuleData
            {
                Name     = "Project",
                Required = true
            };

            var sut = new ProjectReferenceRule(data);

            // Act
            var actual = await sut.Validate(project);

            // Assert
            Assert.False(actual.IsError);
        }
        public async Task ValidateShouldFailWhenForbiddenReferenceExists()
        {
            // Arrange
            var project = new ProjectBuilder()
                          .WithItemGroup()
                          .WithProjectReference("Project")
                          .Build();

            var data = new ProjectReferenceRuleData
            {
                Forbidden = true,
                Name      = "Project"
            };

            var sut = new ProjectReferenceRule(data);

            // Act
            var actual = await sut.Validate(project);

            // Assert
            Assert.True(actual.IsError);
        }
Esempio n. 9
0
 public ConfigBuilder WithProjectReference(ProjectReferenceRuleData data)
 {
     _projectReferences.Add(data);
     return(this);
 }
Esempio n. 10
0
 public ProjectReferenceRule(ProjectReferenceRuleData data)
 {
     _data = data;
 }