Example #1
0
        public Team ConvertTeamFromWrapper(wrapper.Team entry)
        {
            var team = new Team
            {
                TeamId = entry.TeamId,
                Name   = entry.Name,
                Colour = entry.Colour,
            };

            foreach (wrapper.User member in entry.Members)
            {
                team.Members.Add(ConvertUserFromWrapper(member));
            }

            return(team);
        }
Example #2
0
        public void Convert_Team_From_Wrapper_To_View_Model()
        {
            //Arrange
            var converter = new ModelConversitions();
            var model     = new wrapper.Team
            {
                TeamId  = new Guid(),
                Name    = "BMC001",
                Colour  = "Yellow",
                Members = new List <wrapper.User>(),
            };

            model.Members.Add(new wrapper.User
            {
                UserId   = new Guid(),
                Forename = "Jamie",
                Surname  = "Matthews",
                JobTitle = "Placement Engineer",
            });

            model.Members.Add(new wrapper.User
            {
                UserId   = new Guid(),
                Forename = "Sarah",
                Surname  = "Jones",
                JobTitle = "Senior Engineer",
            });

            //Act
            var result = converter.ConvertTeamFromWrapper(model);

            //Assert
            Assert.IsAssignableFrom <Team>(result);
            Assert.AreEqual(2, result.Members.Count);
            Assert.AreEqual(result.TeamId, model.TeamId);
            Assert.AreEqual(result.Name, model.Name);
            Assert.AreEqual(result.Colour, model.Colour);
            Assert.IsAssignableFrom <List <User> >(result.Members);
        }