Exemplo n.º 1
0
        public void AddTeamMemberAsyncShouldReturnTeamMemberCorrectly()
        {
            var options = new DbContextOptionsBuilder <IntillegioContext>()
                          .UseInMemoryDatabase(databaseName: "Add_TeamMember_Db")
                          .Options;

            var dbContext = new IntillegioContext(options);

            var teamMemberBindingModel = new AdminTeamMemberBindingModel
            {
                Name         = "Jack Semper",
                Position     = "Majority Owner",
                About        = "Born and raised in Pretoria, South Africa, Jack moved to Canada when he was 17 to attend Queen\'s University.",
                PhoneNumber  = "(+123) 123 456 789",
                Email        = "*****@*****.**",
                Image350X290 = "http://specthemes.com/redbiz/redbiz-5/img/team/team-05.jpg",
                Facebook     = "https://www.facebook.com/baianodesalvadorBA",
                Twitter      = "https://twitter.com/jpsemper",
                Instagram    = "https://www.instagram.com/tennillejack/",
                Skype        = "AnnSmith",
                Linkedin     = "https://www.linkedin.com/company/semper/"
            };

            var mapper = new Mock <IMapper>();

            mapper.Setup(m => m.Map <TeamMember>(teamMemberBindingModel))
            .Returns(new TeamMember
            {
                Name         = "Jack Semper",
                Position     = "Majority Owner",
                About        = "Born and raised in Pretoria, South Africa, Jack moved to Canada when he was 17 to attend Queen\'s University.",
                PhoneNumber  = "(+123) 123 456 789",
                Email        = "*****@*****.**",
                Image350X290 = "http://specthemes.com/redbiz/redbiz-5/img/team/team-05.jpg",
                Facebook     = "https://www.facebook.com/baianodesalvadorBA",
                Twitter      = "https://twitter.com/jpsemper",
                Instagram    = "https://www.instagram.com/tennillejack/",
                Skype        = "AnnSmith",
                Linkedin     = "https://www.linkedin.com/company/semper/"
            });

            var service = new AboutService(dbContext, mapper.Object);

            service.AddTeamMemberAsync(teamMemberBindingModel);
            Assert.True(dbContext.TeamMembers.Any(n => n.Name == teamMemberBindingModel.Name));
            Assert.True(dbContext.TeamMembers.Any(a => a.Position == teamMemberBindingModel.Position));
            Assert.True(dbContext.TeamMembers.Any(b => b.About == teamMemberBindingModel.About));
            Assert.True(dbContext.TeamMembers.Any(c => c.Facebook == teamMemberBindingModel.Facebook));
        }