public void AddProject_ShouldAddAProject_WhenALegitimateProjectIsGiven() { // Arrange _mockProjectsRepository.Setup(x => x.AddProject(It.IsAny <ProjectsDTO>())).Callback( (ProjectsDTO project) => { if (project.ProjectId.Equals(default(int))) { project.ProjectId = ProjectList.Count() + 1; ProjectList.Add(project); } else { throw new Exception( "Project can not be added, make sure you enter the corresponding information"); } }); // Act _projectContainer.AddProject(3, "ProjectThree", "ProjectThreeDescription"); var addedProject = ProjectList.Last(); // Assert Assert.IsInstanceOfType(addedProject, typeof(ProjectsDTO)); Assert.AreEqual(3, addedProject.ProjectId); Assert.AreEqual("ProjectThree", addedProject.ProjectName); Assert.AreEqual("ProjectThreeDescription", addedProject.ProjectDescription); }