public void GetProjectDetails_ProjectExist_ReturnCorrectCount() { var mockService = new Mock<IProjectDetailService>(MockBehavior.Strict); var list = new List<ProjectDetail> { new ProjectDetail { ProjectName = "Project1", Status = "Red" }, new ProjectDetail { ProjectName = "Project2", Status = "Green" } }; mockService.Setup(x => x.GetProjectDetails()).Returns(list); var target = new ProjectController(mockService.Object); var data = target.GetProjectDetails(new DataSourceRequest()) as JsonResult; var actualList = ((DataSourceResult)(data.Data)).Data as List<ProjectDetail>; //Assert Assert.AreEqual(list.Count, actualList.Count); }
public void Constructor_Invoked_Success() { var mockService = new Mock<IProjectDetailService>(MockBehavior.Strict); var target = new ProjectController(mockService.Object); Assert.IsNotNull(target); }
public void AddNotification_NotificationAdded_AddNotificationInDb() { var projectDetailService = new ProjectDetailService(new DataContextFactory()); var target = new ProjectController(projectDetailService); // Act target.CreateProject(new ProjectDetail { ProjectName = "Katana", Status = "Green" }); target.CreateProject(new ProjectDetail { ProjectName = "KRE", Status = "Yello" }); var data = target.GetProjectDetails(new DataSourceRequest()) as JsonResult; var actualList = ((DataSourceResult) (data.Data)).Data as List<ProjectDetail>; //Assert Assert.AreEqual(2, actualList.Count); }