Ejemplo n.º 1
0
        public static IQueryable <Artist> GetArtistSample()
        {
            var artistBuilder = new ArtistBuilder();

            var testsArtists = new List <Artist>
            {
                artistBuilder
                .Details
                .FirstName("John")
                .LastName("Mick")
                .Build()
            };

            artistBuilder = new ArtistBuilder();

            testsArtists.Add(artistBuilder
                             .Details
                             .FirstName("Mark")
                             .LastName("Well")
                             .Build());


            artistBuilder = new ArtistBuilder();

            testsArtists.Add(artistBuilder
                             .Details
                             .FirstName("John")
                             .LastName("River")
                             .Build());

            return(testsArtists.AsQueryable());
        }
Ejemplo n.º 2
0
        public void Build_WithoutDescription_ValidCall()
        {
            var builder = new ArtistBuilder();
            var artist  = builder
                          .Details
                          .FirstName("Jan")
                          .LastName("Testowy")
                          .Build();

            Assert.NotNull(artist);
            Assert.False(artist.HasErrors);
        }
Ejemplo n.º 3
0
        public void Build_MissingProperty_ThrowsException()
        {
            var builder = new ArtistBuilder();
            var bc      = builder
                          .Details
                          .LastName("Testowy")
                          .Description("Desc");

            var ex = Assert.Throws <ValidationException>(() => bc.Build());

            Assert.Equal("First name cannot be empty.", ex.Message);
        }
Ejemplo n.º 4
0
        public void Build_InvalidName_ThrowsException()
        {
            var builder = new ArtistBuilder();
            var bc      = builder
                          .Details
                          .FirstName("-Jan")
                          .LastName("Testowy")
                          .Description("Random Desc");

            var ex = Assert.Throws <ValidationException>(() => bc.Build());

            Assert.Equal("First name cannot contain special characters.", ex.Message);
        }