Welcome to mirror list, hosted at ThFree Co, Russian Federation.

SignatureFixture.cs « LibGit2Sharp.Tests - github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 978141837163803b36de58b745a456cc62c922c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
using Xunit.Extensions;

namespace LibGit2Sharp.Tests
{
    public class SignatureFixture : BaseFixture
    {
        [Theory]
        [InlineData("\0Leading zero")]
        [InlineData("Trailing zero\0")]
        [InlineData("Zero \0inside")]
        [InlineData("\0")]
        [InlineData("\0\0\0")]
        public void CreatingASignatureWithANameContainingZerosThrows(string name)
        {
            Assert.Throws<ArgumentException>(() => new Signature(name, "me@there.com", DateTimeOffset.Now));
        }

        [Theory]
        [InlineData("\0Leading@zero.com")]
        [InlineData("Trailing@zero.com\0")]
        [InlineData("Zero@\0inside.com")]
        [InlineData("\0")]
        [InlineData("\0\0\0")]
        public void CreatingASignatureWithAnEmailContainingZerosThrows(string email)
        {
            Assert.Throws<ArgumentException>(() => new Signature("Me", email, DateTimeOffset.Now));
        }

        [Fact]
        public void CreatingASignatureWithBadParamsThrows()
        {
            Assert.Throws<ArgumentNullException>(() => new Signature(null, "me@there.com", DateTimeOffset.Now));
            Assert.Throws<ArgumentException>(() => new Signature(string.Empty, "me@there.com", DateTimeOffset.Now));
            Assert.Throws<ArgumentNullException>(() => new Signature("Me", null, DateTimeOffset.Now));
        }

        [Fact]
        public void CanCreateASignatureWithAnEmptyEmail()
        {
            var sig = new Signature("Me", string.Empty, DateTimeOffset.Now);
            Assert.Equal(string.Empty, sig.Email);
        }
    }
}