<commit_before>﻿using System;
using System.Collections.Generic;
using Xunit;
using Zuehlke.Eacm.Web.Backend.DomainModel;
using Zuehlke.Eacm.Web.Backend.DomainModel.Events;

namespace Zuehlke.Eacm.Web.Backend.Tests.DomainModel
{
    public class ProjectFixture
    {
        [Fact]
        public void Constructor_WithEmptyHistory_CreatedDateNotInitialized()
        {
            // arrange
            var id = Guid.NewGuid();
            IEnumerable<IEvent> history = new List<IEvent>();

            // act
            var target = new Project(id, history);

            // assert
            Assert.Equal(DateTime.MinValue, target.Created);
        }

        [Fact]
        public void Constructor_WithEmptyHistory_ModifiedDateNotInitialized()
        {
            // arrange
            var id = Guid.NewGuid();
            IEnumerable<IEvent> history = new List<IEvent>();

            // act
            var target = new Project(id, history);

            // assert
            Assert.Null(target.Modified);
        }

        [Fact]
        public void Constructor_WithEmptyHistory_NameNotInitialized()
        {
            // arrange
            var id = Guid.NewGuid();
            IEnumerable<IEvent> history = new List<IEvent>();

            // act
            var target = new Project(id, history);

            // assert
            Assert.Null(target.Name);
        }

        [Fact]
        public void Constructor_WithEmptyHistory_DescritionNotInitialized()
        {
            // arrange
            var id = Guid.NewGuid();
            IEnumerable<IEvent> history = new List<IEvent>();

            // act
            var target = new Project(id, history);

            // assert
            Assert.Null(target.Description);
        }

        [Theory]
        [InlineData("any name", "any description")]
        [InlineData("any name", "")]
        public void SetProjectAttribute_WithValidParameters_SetsAttributes(string name, string description)
        {
            // arrange
            var id = Guid.NewGuid();
            IEnumerable<IEvent> history = new List<IEvent>();

            var target = new Project(id, history);

            // act
            target.SetProjectAttributes(name, description);

            // assert
            Assert.Equal(name, target.Name);
            Assert.Equal(description, target.Description);
        }

        [Theory]
        [InlineData(null, "any description")]
        [InlineData("", "any description")]
        [InlineData("any name", null)]
        public void SetProjectAttribute_WithInvalidParameters_ThrowsException(string name, string description)
        {
            // arrange
            var id = Guid.NewGuid();
            IEnumerable<IEvent> history = new List<IEvent>();

            var target = new Project(id, history);

            // act
            target.SetProjectAttributes(name, description);

            // assert
            Assert.Equal(name, target.Name);
            Assert.Equal(description, target.Description);
        }
    }
}<commit_msg>feat(configurationmodel): make the set project attributes with invalid parameters test green.<commit_after>﻿using System;
using System.Collections.Generic;
using Xunit;
using Zuehlke.Eacm.Web.Backend.DomainModel;
using Zuehlke.Eacm.Web.Backend.DomainModel.Events;

namespace Zuehlke.Eacm.Web.Backend.Tests.DomainModel
{
    public class ProjectFixture
    {
        [Fact]
        public void Constructor_WithEmptyHistory_CreatedDateNotInitialized()
        {
            // arrange
            var id = Guid.NewGuid();
            IEnumerable<IEvent> history = new List<IEvent>();

            // act
            var target = new Project(id, history);

            // assert
            Assert.Equal(DateTime.MinValue, target.Created);
        }

        [Fact]
        public void Constructor_WithEmptyHistory_ModifiedDateNotInitialized()
        {
            // arrange
            var id = Guid.NewGuid();
            IEnumerable<IEvent> history = new List<IEvent>();

            // act
            var target = new Project(id, history);

            // assert
            Assert.Null(target.Modified);
        }

        [Fact]
        public void Constructor_WithEmptyHistory_NameNotInitialized()
        {
            // arrange
            var id = Guid.NewGuid();
            IEnumerable<IEvent> history = new List<IEvent>();

            // act
            var target = new Project(id, history);

            // assert
            Assert.Null(target.Name);
        }

        [Fact]
        public void Constructor_WithEmptyHistory_DescritionNotInitialized()
        {
            // arrange
            var id = Guid.NewGuid();
            IEnumerable<IEvent> history = new List<IEvent>();

            // act
            var target = new Project(id, history);

            // assert
            Assert.Null(target.Description);
        }

        [Theory]
        [InlineData("any name", "any description")]
        [InlineData("any name", "")]
        public void SetProjectAttribute_WithValidParameters_SetsAttributes(string name, string description)
        {
            // arrange
            var id = Guid.NewGuid();
            IEnumerable<IEvent> history = new List<IEvent>();

            var target = new Project(id, history);

            // act
            target.SetProjectAttributes(name, description);

            // assert
            Assert.Equal(name, target.Name);
            Assert.Equal(description, target.Description);
        }

        [Theory]
        [InlineData(null, "any description")]
        [InlineData("", "any description")]
        [InlineData("any name", null)]
        public void SetProjectAttribute_WithInvalidParameters_ThrowsException(string name, string description)
        {
            // arrange
            var id = Guid.NewGuid();
            IEnumerable<IEvent> history = new List<IEvent>();

            var target = new Project(id, history);

            // act
            Assert.ThrowsAny<ArgumentException>(() => target.SetProjectAttributes(name, description));
        }
    }
}
{'fraction_non_alphanumeric': 0.10075360419397117, 'fraction_numerical': 0.0, 'mean_word_length': 1.7876712328767124, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '257867', 'n_tokens_mistral': 1547, 'n_tokens_neox': 1513, 'n_words': 340}