Example #1
0
        public void Dont_add_education_with_overlapping_dates()
        {
            var developer = NewDeveloper();
            var add       = new DeveloperUpdateCommand
            {
                Educations = new[]
                {
                    new EducationEntry
                    {
                        Id         = "a",
                        Degree     = "BS",
                        University = "S&C",
                        StartDate  = "2010-1-1",
                        EndDate    = "2011-1-1"
                    },
                    new EducationEntry
                    {
                        Id         = "b",
                        Degree     = "MS",
                        University = "Other",
                        StartDate  = "2010-6-1",
                        EndDate    = "2012-1-1"
                    }
                }
            };

            developer.Update(add)
            .Errors
            .Should()
            .Contain("The education of 'S&C' overlaps with 'Other'");
        }
Example #2
0
        public void Dont_add_experience_with_duplicate_company_and_position()
        {
            var developer = NewDeveloper();
            var command   = new DeveloperUpdateCommand
            {
                Experiences = new[]
                {
                    new ExperienceEntry
                    {
                        Id        = "a",
                        Company   = "Parmis",
                        Position  = "C# Developer",
                        StartDate = "2015-1-1",
                        EndDate   = "2016-1-1",
                        Content   = "done tasks"
                    },
                    new ExperienceEntry
                    {
                        Id        = "b",
                        Company   = "Parmis",
                        Position  = "C# Developer",
                        StartDate = "2015-1-1",
                        EndDate   = "2016-1-1",
                        Content   = "done tasks"
                    }
                }
            };

            developer.Update(command)
            .Errors
            .Should()
            .Contain("The experience of 'C# Developer' at 'Parmis' is duplicated");
        }
Example #3
0
        public void Dont_add_side_projects_with_duplicate_titles()
        {
            var developer = NewDeveloper();
            var add       = new DeveloperUpdateCommand
            {
                SideProjects = new[]
                {
                    new SideProjectEntry
                    {
                        Id      = "a",
                        Title   = "Richtext",
                        Content = "web editor"
                    },
                    new SideProjectEntry
                    {
                        Id      = "b",
                        Title   = "Richtext",
                        Content = "web editor"
                    }
                }
            };

            developer.Update(add)
            .Errors
            .Should()
            .Contain("The side project of 'Richtext' is duplicated");
        }
Example #4
0
        public void Dont_add_education_with_same_degree_and_university()
        {
            var developer = NewDeveloper();
            var add       = new DeveloperUpdateCommand
            {
                Educations = new[]
                {
                    new EducationEntry
                    {
                        Id         = "a",
                        Degree     = "BS",
                        University = "S&C",
                        StartDate  = "2010-1-1",
                        EndDate    = "2011-1-1"
                    },
                    new EducationEntry
                    {
                        Id         = "b",
                        Degree     = "BS",
                        University = "S&C",
                        StartDate  = "2015-1-1",
                        EndDate    = "2016-1-1"
                    }
                }
            };

            developer.Update(add)
            .Errors
            .Should()
            .Contain("The education of 'BS' in 'S&C' is duplicated");
        }
Example #5
0
        public void Dont_update_experiences_with_time_overlaps()
        {
            var developer = NewDeveloper();
            var command   = new DeveloperUpdateCommand
            {
                Experiences = new[]
                {
                    new ExperienceEntry
                    {
                        Id        = "a",
                        Company   = "Parmis",
                        Position  = "C# Developer",
                        StartDate = "2015-1-1",
                        EndDate   = "2016-1-1",
                        Content   = "done tasks"
                    },
                    new ExperienceEntry
                    {
                        Id        = "b",
                        Company   = "Lodgify",
                        Position  = "C# Developer",
                        StartDate = "2015-6-1",
                        EndDate   = "2017-1-1",
                        Content   = "done tasks"
                    }
                }
            };

            developer.Update(command)
            .Errors
            .Should()
            .Contain("The experiences of 'Parmis' overlaps with 'Lodgify'");
        }
        public async Task Sort_educations_by_date()
        {
            var command = new DeveloperUpdateCommand
            {
                Summary     = "The best developer ever!",
                Skills      = "C#, Javascript, React",
                Experiences = new[]
                {
                    new ExperienceEntry {
                        Company = "Lodgify", Position = "C# Developer", StartDate = "2010-1-1", EndDate = "2011-1-1", Content = "System Architect"
                    },
                    new ExperienceEntry {
                        Company = "Parmis", Position = "C# Developer", StartDate = "2016-1-1", EndDate = "2017-1-1", Content = "System Architect"
                    },
                },
                Educations = new[]
                {
                    new EducationEntry {
                        Degree = "MS", University = "S&C", StartDate = "2005-1-1", EndDate = "2006-1-1"
                    },
                    new EducationEntry {
                        Degree = "BS", University = "S&C", StartDate = "2010-1-1", EndDate = "2011-1-1"
                    },
                }
            };
            var developer = Developer.Create(command).Developer;

            using (var db = _context.GetDb())
            {
                db.Developers.Add(developer);
                db.SaveChanges();
            }

            var result = await _handler.Handle(new DeveloperSaveQuery(), default);

            result.Experiences
            .Select(x => x.StartDate)
            .Should()
            .ContainInOrder("2016-01-01", "2010-01-01");

            result.Educations
            .Select(x => x.StartDate)
            .Should()
            .ContainInOrder("2010-01-01", "2005-01-01");
        }
Example #7
0
        private Developer NewDeveloper()
        {
            var command = new DeveloperUpdateCommand
            {
                Summary     = "a passionate developer",
                Skills      = "C#\nJS",
                Experiences = new[]
                {
                    new ExperienceEntry
                    {
                        Company   = "Microsoft",
                        Position  = "Software Engineer",
                        StartDate = "1990-1-1",
                        EndDate   = "2000-1-1",
                        Content   = "worked for ten years"
                    }
                }
            };

            return(Developer.Create(command).Developer);
        }
Example #8
0
        public void Dont_add_experiences_with_startDates_that_are_greater_than_endDates()
        {
            var developer = NewDeveloper();
            var add       = new DeveloperUpdateCommand
            {
                Experiences = new[]
                {
                    new ExperienceEntry
                    {
                        Company   = "Lodgify",
                        Position  = "C# Developer",
                        StartDate = "2017-1-1",
                        EndDate   = "2015-1-1",
                        Content   = "done tasks"
                    }
                }
            };

            developer.Update(add)
            .Errors
            .Should()
            .Contain("StartDate of 'Lodgify' is greater than it's EndDate");
        }
        public async Task Return_developer_when_its_available()
        {
            var command = new DeveloperUpdateCommand
            {
                Summary     = "The best developer ever!",
                Skills      = "C#, Javascript, React",
                Experiences = new[]
                {
                    new ExperienceEntry {
                        Company = "Parmis", Position = "C# Developer", StartDate = "2016-1-1", EndDate = "2017-1-1", Content = "System Architect"
                    }
                },
                SideProjects = new[]
                {
                    new SideProjectEntry {
                        Title = "Richtext Editor", Content = "A simple richtext for web"
                    }
                },
                Educations = new[]
                {
                    new EducationEntry {
                        Degree = "BS", University = "S&C", StartDate = "2010-1-1", EndDate = "2011-1-1"
                    }
                }
            };
            var developer = Developer.Create(command).Developer;

            using (var db = _context.GetDb())
            {
                db.Developers.Add(developer);
                db.SaveChanges();
            }

            var result = await _handler.Handle(new DeveloperSaveQuery(), default);

            result.Should().BeEquivalentTo(new
            {
                Summary     = "The best developer ever!",
                Skills      = "C#, Javascript, React",
                Experiences = new[]
                {
                    new
                    {
                        Company   = "Parmis",
                        Position  = "C# Developer",
                        Content   = "System Architect",
                        StartDate = "2016-01-01",
                        EndDate   = "2017-01-01"
                    }
                },
                SideProjects = new[]
                {
                    new
                    {
                        Title   = "Richtext Editor",
                        Content = "A simple richtext for web"
                    },
                },
                Educations = new[]
                {
                    new
                    {
                        Degree     = "BS",
                        University = "S&C",
                        StartDate  = "2010-01-01",
                        EndDate    = "2011-01-01"
                    }
                }
            });
        }